bsp_wdt.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include "sdk_common.h"
  2. #include "SEGGER_RTT.h"
  3. #include "nrf_drv_pwm.h"
  4. #include "usr_config.h"
  5. #include "nrf_drv_wdt.h"
  6. #include "system.h"
  7. #include "bsp_time.h"
  8. #if WATCHDOG_ENANBLE
  9. nrf_drv_wdt_channel_id m_channel_id;
  10. void feed_watchdog(void)
  11. {
  12. nrf_drv_wdt_channel_feed(m_channel_id);
  13. }
  14. /**
  15. * @brief WDT events handler.
  16. */
  17. void wdt_event_handler(void)
  18. {
  19. SEGGER_RTT_printf(0,"wdt_event_handler:%d\n",TIME_GetTicks());
  20. }
  21. static void WatchDog_Process(void)
  22. {
  23. feed_watchdog();
  24. SEGGER_RTT_printf(0,"WatchDog_Process:%d\n",TIME_GetTicks());
  25. }
  26. void watchdog_init(void){
  27. uint32_t err_code;
  28. nrf_drv_wdt_config_t config = NRF_DRV_WDT_DEAFULT_CONFIG;
  29. config.interrupt_priority = WDT_IRQ_PRIORITY;
  30. config.reload_value = WDT_RELOAD_VALUE;
  31. err_code = nrf_drv_wdt_init(&config, wdt_event_handler);
  32. APP_ERROR_CHECK(err_code);
  33. err_code = nrf_drv_wdt_channel_alloc(&m_channel_id);
  34. APP_ERROR_CHECK(err_code);
  35. nrf_drv_wdt_enable();
  36. Process_Start(1000,"WatchDog_Process",WatchDog_Process);
  37. }
  38. #endif