In the past, you need modify rtc_api.c in mbed-dev source code. From this revision, you can just use RTC function all of conditions (Normal, Reset, Stand-by, Power OFF).
Note
From now on, you do NOT need any modification for mbed-dev library because STM team updates rtc_api.c source code and support RTC function under reset & standby condition includes power off condition (You need additional VBAT back-up hardware).
Please refer following NOTE information.
/users/kenjiArai/notebook/nucleo-series-rtc-control-under-power-onoff-and-re/
Diff: check_revision.cpp
- Revision:
- 10:806cfec92eb6
- Child:
- 11:2e514d955a2b
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/check_revision.cpp Sat Jul 18 22:46:14 2020 +0000 @@ -0,0 +1,27 @@ +/* + * Check Mbed revision + * + * Copyright (c) 2019,'20 Kenji Arai / JH1PJL + * http://www7b.biglobe.ne.jp/~kenjia/ + * https://os.mbed.com/users/kenjiArai/ + * Created: July 17th, 2019 + * Revised: July 19th, 2020 + */ + +#include "mbed.h" + +// RUN ONLY ON mbed-os-6.2.0 +// https://github.com/ARMmbed/mbed-os/releases/tag/mbed-os-6.2.0 +#if (MBED_MAJOR_VERSION == 6) &&\ + (MBED_MINOR_VERSION == 2) &&\ + (MBED_PATCH_VERSION == 0) +#else +# warning "if you see a version 5.15.4 looks 6.2.0 (as of July 19,'20)" +#endif + +void print_revision(void) +{ + printf("MBED_MAJOR_VERSION = %d, ", MBED_MAJOR_VERSION); + printf("MINOR = %d, ", MBED_MINOR_VERSION); + printf("PATCH = %d\r\n", MBED_PATCH_VERSION); +}