scooter / Mbed 2 deprecated Nucleo_sleep

Dependencies:   mbed

Committer:
thorb3n
Date:
Tue Dec 08 14:27:53 2015 +0000
Revision:
1:053449444c29
Parent:
0:8e1b0b607dc3
gghghjv

Who changed what in which revision?

UserRevisionLine numberNew contents of line
iFoxtec 0:8e1b0b607dc3 1 #include "mbed.h"
thorb3n 1:053449444c29 2
thorb3n 1:053449444c29 3 #define IWDG_START 0x0000CCCC
thorb3n 1:053449444c29 4 #define IWDG_WRITE_ACCESS 0x00005555
thorb3n 1:053449444c29 5 #define IWDG_PR_PR_0 7
thorb3n 1:053449444c29 6 #define IWDG_RELOAD 512*60
thorb3n 1:053449444c29 7 #define IWDG_REFRESH 0xAAAA
thorb3n 1:053449444c29 8 DigitalOut myled(LED1);
iFoxtec 0:8e1b0b607dc3 9 int main()
iFoxtec 0:8e1b0b607dc3 10 {
thorb3n 1:053449444c29 11 /* (1) Activate IWDG (not needed if done in option bytes) */
thorb3n 1:053449444c29 12 /* (2) Enable write access to IWDG registers */
thorb3n 1:053449444c29 13 /* (3) Set prescaler by 8 */
thorb3n 1:053449444c29 14 /* (4) Set reload value to have a rollover each 100ms */
thorb3n 1:053449444c29 15 /* (5) Check if flags are reset */
thorb3n 1:053449444c29 16 /* (6) Refresh counter */
thorb3n 1:053449444c29 17 RCC_OscInitTypeDef RCC_OscInitStruct;
thorb3n 1:053449444c29 18 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI;
thorb3n 1:053449444c29 19 RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_0;
thorb3n 1:053449444c29 20 HAL_RCC_OscConfig(&RCC_OscInitStruct);
iFoxtec 0:8e1b0b607dc3 21
thorb3n 1:053449444c29 22 IWDG->KR=IWDG_START;
thorb3n 1:053449444c29 23 wait(5);
thorb3n 1:053449444c29 24 IWDG->KR=IWDG_WRITE_ACCESS;
thorb3n 1:053449444c29 25 IWDG->PR=IWDG_PR_PR_0;
thorb3n 1:053449444c29 26 IWDG->RLR=IWDG_RELOAD;
thorb3n 1:053449444c29 27 while(IWDG->SR) {
thorb3n 1:053449444c29 28 wait(0.1);
iFoxtec 0:8e1b0b607dc3 29 }
thorb3n 1:053449444c29 30 //SwitchFromPLLtoHSI();
thorb3n 1:053449444c29 31 //RCC->CFGR = (
thorb3n 1:053449444c29 32 //0x00008000
thorb3n 1:053449444c29 33 myled = 1;
thorb3n 1:053449444c29 34 wait(3);
thorb3n 1:053449444c29 35 myled = 0;
thorb3n 1:053449444c29 36 wait(10);
thorb3n 1:053449444c29 37 IWDG->KR=IWDG_REFRESH;/* (6) */
thorb3n 1:053449444c29 38 //HAL_PWR_EnterSTOPMode(PWR_MAINREGULATOR_ON, PWR_STOPENTRY_WFI);
thorb3n 1:053449444c29 39 deepsleep();
thorb3n 1:053449444c29 40 while(1) {
thorb3n 1:053449444c29 41
thorb3n 1:053449444c29 42 }
thorb3n 1:053449444c29 43 }