| BlueNRG-1 Peripherals drivers Examples

- Main Page
- Modules
- Classes
- Files

- File List
- File Members

WDG_Wakeup_main.c
Go to the documentation of this file.
1
2 /******************** (C) COPYRIGHT 2016 STMicroelectronics ********************
3 * File Name : WDG_WakeUp_main.c
4 * Author : VMA DIVISION
5 * Version : 1.0.0
6 * Date : 21-September-2015
7 * Description : Code demostrating the watchdog wakeup functionality
8 ********************************************************************************
9 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
10 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
11 * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
12 * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
13 * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
14 * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
15 *******************************************************************************/
16
157 /* Includes ------------------------------------------------------------------*/
158 #include "BlueNRG1.h"
159 #include "SDK_EVAL_Config.h"
160
173 /* Private typedef -----------------------------------------------------------*/
174 /* Private define ------------------------------------------------------------*/
175
176
177 /* Private macro -------------------------------------------------------------*/
178
180 #define RC32K_FREQ 32768
181 #define RELOAD_TIME(sec) ((sec*RC32K_FREQ)-3)
182
183 /* Private variables ---------------------------------------------------------*/
184 /* Private function prototypes -----------------------------------------------*/
185 void WDG_Configuration(void);
186
187 /* Private functions ---------------------------------------------------------*/
188
194 int main(void)
195 {
196 /* System initialization function */
197 SystemInit();
198
199 /* Identify BlueNRG1 platform */
200 SdkEvalIdentification();
201
202 /* LEDs initialization function */
203 SdkEvalLedInit(LED1);
204
205 /* WDG configuration */
206 WDG_Configuration();
207
208 /* Watchdog enable */
209 WDG_ITConfig(ENABLE);
210
211 /* Cortex will enter in deep sleep mode when WFI command start */
212 SystemSleepCmd(ENABLE);
213 __WFI();
214
215 /* Once waked-up enter the sleep mode again */
216 while(1) {
217 /* Toggle LED1 */
218 SdkEvalLedToggle(LED1);
219
220 /* Go to sleep mode again */
221 __WFI();
222 }
223
224 }
225
231 void WDG_Configuration(void)
232 {
233 NVIC_InitType NVIC_InitStructure;
234
235 /* Enable watchdog clock */
236 SysCtrl_PeripheralClockCmd(CLOCK_PERIPH_WDG, ENABLE);
237
238 /* WDG reload time configuration */
239 WDG_SetReload(RELOAD_TIME(1));
240
241 /* Clear pending interrupt on cortex */
242 NVIC->ICPR[0] = 0xFFFFFFFF;
243
244 /* Enable the RTC interrupt */
245 NVIC_InitStructure.NVIC_IRQChannel = WDG_IRQn;
246 NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = LOW_PRIORITY;
247 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
248 NVIC_Init(&NVIC_InitStructure);
249 }
250
251
252 #ifdef USE_FULL_ASSERT
253
260 void assert_failed(uint8_t* file, uint32_t line)
261 {
262 /* User can add his own implementation to report the file name and line number,
263 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
264
265 /* Infinite loop */
266 while (1)
267 {
268 }
269 }
270
271 #endif
272
285 /******************* (C) COPYRIGHT 2015 STMicroelectronics *****END OF FILE****/
WDG_Configuration
void WDG_Configuration(void)
NVIC configuration.
Definition: WDG_Wakeup_main.c:231
main
int main(void)
Main program code.
Definition: WDG_Wakeup_main.c:194
RELOAD_TIME
#define RELOAD_TIME(sec)
Definition: WDG_Wakeup_main.c:181