This is a RTC additional function. This is only for Nucleo F401RE & F411RE mbed(Added L152RE, F334R8, L476RG & F746xx). If you connected battery backup circuit for internal RTC, you can make a power-off and reset condition. RTC still has proper time and date.

Dependents:   Nucleo_rtos_sample PB_Emma_Ethernet

Please refer following NOTE information.
/users/kenjiArai/notebook/nucleo-series-rtc-control-under-power-onoff-and-re/

Revision:
1:3129de8d50ea
Parent:
0:e4c20fd769f1
diff -r e4c20fd769f1 -r 3129de8d50ea SetRTC.cpp
--- a/SetRTC.cpp	Sat Feb 07 02:19:57 2015 +0000
+++ b/SetRTC.cpp	Sat Feb 14 11:31:51 2015 +0000
@@ -7,7 +7,7 @@
  *  http://www.page.sannet.ne.jp/kenjia/index.html
  *  http://mbed.org/users/kenjiArai/
  *      Created:  October   24th, 2014
- *      Revised:  Feburary   7th, 2015
+ *      Revised:  Feburary  14th, 2015
  *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
@@ -340,7 +340,7 @@
     // Show Time with several example
     // ex.1
     pcr.printf("Date: %04d/%02d/%02d, %02d:%02d:%02d\r\n",
-           t.tm_year + 1900, t.tm_mon + 1, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec);
+               t.tm_year + 1900, t.tm_mon + 1, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec);
 #if 0
     time_t seconds;
     char buf[40];
@@ -373,7 +373,32 @@
     chk_and_set_time(ptr);
 }
 
-#else
+#if defined(TARGET_NUCLEO_L152RE)
+void deepsleep_preparation(void)
+{
+    GPIO_InitTypeDef GPIO_InitStruct;
+
+    // Port C sets analog mode except Xtal 32.768kHz pins
+    GPIO_InitStruct.Pin = (uint16_t)0x3FFF; // 32.768kHz Xtal, PC15 & PC14
+    GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
+    GPIO_InitStruct.Pull = GPIO_NOPULL;
+    GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
+    HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
+    // All other ports are analog input mode
+    GPIO_InitStruct.Pin = GPIO_PIN_All;
+    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+    HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
+    HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
+    HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
+    HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
+    HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);
+}
+#else   // defined(TARGET_NUCLEO_L152RE)
+void deepsleep_preparation(void)
+{
+    ;   // No implementation
+}
+#endif  // defined(TARGET_NUCLEO_L152RE)
+#else   // defined(TARGET_NUCLEO_F401RE,TARGET_NUCLEO_F411RE,TARGET_NUCLEO_L152RE)
 #error "No suport this mbed, only for Nucleo mbed"
-#endif
-// defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F411RE) || defined(TARGET_NUCLEO_L152RE)
+#endif  // defined(TARGET_NUCLEO_F401RE,TARGET_NUCLEO_F411RE,TARGET_NUCLEO_L152RE)