/*---------------------------------------------------------------------------*/ void watchdog_init(void) { ret_code_t err_code; err_code = nrf_drv_wdt_init(NULL, &wdt_event_handler); APP_ERROR_CHECK(err_code); err_code = nrf_drv_wdt_channel_alloc(&wdt_channel_id); APP_ERROR_CHECK(err_code); wdt_initialized = 1; }
EN_STATUSCODE Watchdog_Init(void) { #ifndef _CLING_PC_SIMULATION_ I32U err_code; //Configure WDT. nrf_drv_wdt_config_t config = NRF_DRV_WDT_DEAFULT_CONFIG; err_code = nrf_drv_wdt_init(&config, wdt_event_handler); APP_ERROR_CHECK(err_code); err_code = nrf_drv_wdt_channel_alloc(&m_channel_id); APP_ERROR_CHECK(err_code); nrf_drv_wdt_enable(); #endif Y_SPRINTF("[WDG] Watchdog init"); return STATUSCODE_SUCCESS; }
/** * @brief Function for main application entry. */ int main(void) { uint32_t err_code = NRF_SUCCESS; //BSP configuration for button support: button pushing will feed the dog. err_code = nrf_drv_clock_init(NULL); APP_ERROR_CHECK(err_code); nrf_drv_clock_lfclk_request(); APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, false); err_code = bsp_init(BSP_INIT_BUTTONS, APP_TIMER_TICKS(100, APP_TIMER_PRESCALER), bsp_event_callback); APP_ERROR_CHECK(err_code); //Configure all LEDs on board. LEDS_CONFIGURE(LEDS_MASK); LEDS_OFF(LEDS_MASK); //Indicate program start on LEDs. for(uint32_t i = 0; i < LEDS_NUMBER; i++) { nrf_delay_ms(200); LEDS_ON(BSP_LED_0_MASK << i); } err_code = bsp_buttons_enable(); APP_ERROR_CHECK(err_code); //Configure WDT. nrf_drv_wdt_config_t config = NRF_DRV_WDT_DEAFULT_CONFIG; err_code = nrf_drv_wdt_init(&config, wdt_event_handler); APP_ERROR_CHECK(err_code); err_code = nrf_drv_wdt_channel_alloc(&m_channel_id); APP_ERROR_CHECK(err_code); nrf_drv_wdt_enable(); while(1) { __SEV(); __WFE(); __WFE(); } }