annotate Small_CPU/Src/rtc.c @ 217:ce05c801b002 Improve_IPC_Sync

Moved display refresh and button action function from tim callback to main loop The update of the display, especially for log book pages, may take some time causing problem because the execution of other functions (like SPI) was shifted => SPI errors.
author ideenmodellierer
date Sun, 31 Mar 2019 15:39:44 +0200
parents 5f11787b4f42
children f0069f002c55
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3 * @file rtc.c
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4 * @author heinrichs weikamp gmbh
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5 * @version V0.0.1
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
6 * @date 10-Oct-2014
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
7 * @brief Source code for rtc control
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
8 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
9 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
10 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
11 ##### How to use #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
12 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
13 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
14 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
15 * @attention
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
16 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
17 * <h2><center>&copy; COPYRIGHT(c) 2015 heinrichs weikamp</center></h2>
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
18 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
19 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
20 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
21 /* Includes ------------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
22 #include "rtc.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
23 #include "stm32f4xx_hal.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
24 #include "stm32f4xx_hal_conf.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
25 #include "baseCPU2.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
26
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
27 RTC_HandleTypeDef RTCHandle;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
28
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
29 static void RTC_Error_Handler(void);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
30
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
31
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
32 void RTC_SetTime(RTC_TimeTypeDef stimestructure)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
33 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
34
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
35 stimestructure.SubSeconds = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
36 stimestructure.TimeFormat = RTC_HOURFORMAT12_AM;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
37 stimestructure.DayLightSaving = RTC_DAYLIGHTSAVING_NONE ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
38 stimestructure.StoreOperation = RTC_STOREOPERATION_RESET;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
39
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
40 if(HAL_RTC_SetTime(&RTCHandle, &stimestructure, FORMAT_BIN) != HAL_OK)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
41 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
42 RTC_Error_Handler();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
43 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
44 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
45
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
46
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
47 void RTC_SetDate(RTC_DateTypeDef sdatestructure)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
48 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
49 if(HAL_RTC_SetDate(&RTCHandle, &sdatestructure, FORMAT_BIN) != HAL_OK)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
50 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
51 RTC_Error_Handler();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
52 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
53 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
54
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
55
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
56 /*
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
57 static void RTC_CalendarConfig(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
58 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
59 RTC_DateTypeDef sdatestructure;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
60 RTC_TimeTypeDef stimestructure;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
61
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
62 //##-1- Configure the Date #################################################
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
63 // Set Date: Monday April 14th 2014
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
64 sdatestructure.Year = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
65 sdatestructure.Month = RTC_MONTH_JANUARY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
66 sdatestructure.Date = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
67 sdatestructure.WeekDay = RTC_WEEKDAY_MONDAY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
68
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
69 if(HAL_RTC_SetDate(&RTCHandle,&sdatestructure,FORMAT_BCD) != HAL_OK)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
70 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
71 RTC_Error_Handler();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
72 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
73
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
74 //##-2- Configure the Time #################################################
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
75 // Set Time: 02:00:00
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
76 stimestructure.Hours = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
77 stimestructure.Minutes = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
78 stimestructure.Seconds = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
79 stimestructure.DayLightSaving = RTC_DAYLIGHTSAVING_NONE ;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
80 stimestructure.StoreOperation = RTC_STOREOPERATION_RESET;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
81
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
82 if(HAL_RTC_SetTime(&RTCHandle,&stimestructure,FORMAT_BCD) != HAL_OK)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
83 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
84 RTC_Error_Handler();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
85 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
86
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
87 //##-3- Writes a data in a RTC Backup data Register0 #######################
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
88 // HAL_RTCEx_BKUPWrite(&RTCHandle,RTC_BKP_DR0,0x32F2);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
89 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
90 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
91
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
92
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
93 /* ##-1- Configure the RTC peripheral #######################################
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
94 Configure RTC prescaler and RTC data registers
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
95 RTC configured as follow:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
96 - Hour Format = Format 24
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
97 - Asynch Prediv = Value according to source clock
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
98 - Synch Prediv = Value according to source clock
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
99 - OutPut = Output Disable
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
100 - OutPutPolarity = High Polarity
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
101 - OutPutType = Open Drain
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
102 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
103
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
104
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
105 void MX_RTC_init(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
106 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
107
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
108 RTC_TimeTypeDef sTime;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
109 RTC_DateTypeDef sDate;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
110 // RTC_AlarmTypeDef sAlarm;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
111
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
112 /**Initialize RTC and set the Time and Date
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
113 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
114 RTCHandle.Instance = RTC;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
115 RTCHandle.Init.HourFormat = RTC_HOURFORMAT_24;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
116 RTCHandle.Init.AsynchPrediv = 127;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
117 RTCHandle.Init.SynchPrediv = 255;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
118 RTCHandle.Init.OutPut = RTC_OUTPUT_DISABLE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
119 RTCHandle.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
120 RTCHandle.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
121 HAL_RTC_Init(&RTCHandle);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
122
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
123 sTime.Hours = 11;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
124 sTime.Minutes = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
125 sTime.Seconds = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
126 sTime.SubSeconds = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
127 sTime.TimeFormat = RTC_HOURFORMAT12_AM;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
128 sTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
129 sTime.StoreOperation = RTC_STOREOPERATION_RESET;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
130 HAL_RTC_SetTime(&RTCHandle, &sTime, FORMAT_BCD);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
131
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
132 sDate.WeekDay = RTC_WEEKDAY_SUNDAY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
133 sDate.Month = RTC_MONTH_FEBRUARY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
134 sDate.Date = 15;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
135 sDate.Year = 17;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
136 HAL_RTC_SetDate(&RTCHandle, &sDate, FORMAT_BCD);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
137
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
138
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
139 /*
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
140 RTCHandle.Instance = RTC;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
141 RTCHandle.Init.HourFormat = RTC_HOURFORMAT_24;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
142 RTCHandle.Init.AsynchPrediv = RTC_ASYNCH_PREDIV;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
143 RTCHandle.Init.SynchPrediv = RTC_SYNCH_PREDIV;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
144 RTCHandle.Init.OutPut = RTC_OUTPUT_DISABLE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
145 RTCHandle.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
146 RTCHandle.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
147
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
148 HAL_RTC_Init(&RTCHandle);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
149 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
150 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
151
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
152
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
153 void RTC_StopMode_2seconds(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
154 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
155 /* Enable Power Control clock */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
156 __HAL_RCC_PWR_CLK_ENABLE();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
157
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
158 /* Disable Wake-up timer */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
159 HAL_RTCEx_DeactivateWakeUpTimer(&RTCHandle);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
160
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
161 /* Enable Wake-up timer */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
162 HAL_RTCEx_SetWakeUpTimer_IT(&RTCHandle, (0x1000-1), RTC_WAKEUPCLOCK_RTCCLK_DIV16);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
163
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
164 /* FLASH Deep Power Down Mode enabled */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
165 HAL_PWREx_EnableFlashPowerDown();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
166
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
167 /*## Enter Stop Mode #######################################################*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
168 HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
169
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
170 /* Configures system clock after wake-up from STOP: enable HSI, PLL and select
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
171 PLL as system clock source (HSI and PLL are disabled in STOP mode) */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
172 SYSCLKConfig_STOP();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
173
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
174 HAL_RTCEx_DeactivateWakeUpTimer(&RTCHandle);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
175 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
176
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
177
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
178 void RTC_Stop_11ms(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
179 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
180 /* Disable Wake-up timer */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
181 HAL_RTCEx_DeactivateWakeUpTimer(&RTCHandle);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
182
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
183 /* Enable Wake-up timer */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
184 HAL_RTCEx_SetWakeUpTimer_IT(&RTCHandle, (0x18-1), RTC_WAKEUPCLOCK_RTCCLK_DIV16);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
185
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
186 /* FLASH Deep Power Down Mode enabled */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
187 HAL_PWREx_DisableFlashPowerDown();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
188
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
189 /*## Enter Stop Mode #######################################################*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
190 HAL_PWR_EnterSTOPMode(PWR_MAINREGULATOR_ON, PWR_STOPENTRY_WFI);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
191
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
192 /* Configures system clock after wake-up from STOP: enable HSI, PLL and select
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
193 PLL as system clock source (HSI and PLL are disabled in STOP mode) */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
194 SYSCLKConfig_STOP();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
195
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
196 HAL_RTCEx_DeactivateWakeUpTimer(&RTCHandle);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
197 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
198
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
199
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
200 static void RTC_Error_Handler(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
201 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
202 while(1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
203 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
204
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
205
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
206 /************************ (C) COPYRIGHT heinrichs weikamp *****END OF FILE****/