/**----------------------------------------------------------------------------- * @brief Initialisation du watchdog Windows. * * param[in] Timeout_ms Duree du timeout watchdog en ms. */ void WDG_InitWWDG(uint16_t Timeout_ms){ RCC_ClocksTypeDef xRCC_Clocks; uint32_t ulClock_kHz; WWDG_DeInit(); // Initialisation des variables WWDG_Reload = Timeout_ms; WWDG_Cnt = Timeout_ms; // Activation horloges RCC_APB1PeriphResetCmd(RCC_APB1Periph_WWDG, DISABLE); RCC_APB1PeriphClockCmd(RCC_APB1Periph_WWDG, ENABLE); // Configuration interruption WWDG_EnableIT(); #ifdef configLIBRARY_KERNEL_INTERRUPT_PRIORITY NVIC_InitStructure.NVIC_IRQChannel = WWDG_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = configLIBRARY_KERNEL_INTERRUPT_PRIORITY; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init( &NVIC_InitStructure ); #else NVIC_EnableIRQ(WWDG_IRQn); #endif // Configuration timeout WWDG_SetPrescaler(WWDG_Prescaler_8); WWDG_SetWindowValue(0x7F); // Activation WWDG_Enable(0x7F); WDG_Refresh(); }
/************************************************************* * WWDT Initialization **************************************************************/ void WWDG_Init() { RCC_APB1PeriphClockCmd(RCC_APB1Periph_WWDG, ENABLE); // Deinitializes WWDG peripheral registers #if(STRCMP($ResetEn$, DISABLE) == 0) WWDG_DeInit(); #endif // Sets Prescaler value of the WWDG. WWDG_SetPrescaler($PreValue$); // Sets Window value of the WWDG. WWDG_SetWindowValue($WindowValue$); // Sets Counter value of the WWDG. WWDG_SetCounter($CounterValue$); // Enable WWDG and set counter value WWDG_Enable($CounterValue$); //Enable EW interrupt #if((STRCMP($IntEn$,DISABLE)) == 0) WWDG_ClearFlag(); WWDG_EnableIT(); #endif }
void PhotonWdgs::_tickleWDGs() { if(_aliveCount < PhotonWdgs::_timeoutval) { if(PhotonWdgs::_wwdgRunning) { WWDG_SetCounter(0x7F); } if(PhotonWdgs::_iwdgRunning) { IWDG_ReloadCounter(); } PhotonWdgs::_aliveCount++; } // deactivate WWDG if OTA updates pending if(System.updatesPending()) { if(PhotonWdgs::_wwdgRunning) { WWDG_DeInit(); } System.enableUpdates(); PhotonWdgs::_wdgTimer.end(); } }
void setup() { NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE); GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE); WWDG_DeInit(); time_setup(); debug_setup(); rtc_setup(); spi_setup(); sdcard_setupGpio(); cc3000_setupGpio(); button_setup(); if (!sdcard_setup()) { printf("Failed to setup SDCard\n"); } else { if (!sdcard_fat_setup()) { printf("Failed to setup SDCard Fat\n"); } } if (config_read()) { printf("read config success\n"); } else { printf("read config FAILED\n"); while (1); } network_setup(); uint32_t ntpTime = ntp_getTime(); printf("ntp time %lu\n", ntpTime); if (ntpTime > 0) { rtc_setTime(ntpTime); } }
/**----------------------------------------------------------------------------- * @brief Desactivation du watchdog. * */ void WDG_Disable(){ WWDG_DeInit(); WDG_Refresh(); }