fwdgt.c 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*********************************************************************************************************
  2. * Module : fwdgt
  3. * Abstract :
  4. * Version : 1.0.0
  5. * Author : Leopul(COPYRIGHT 2025 ~ 2027 Leopul. All rights reserved.)
  6. * Complete : 2025-04-09
  7. * Content : None
  8. * Note : None
  9. *********************************************************************************************************/
  10. #include "fwdgt.h"
  11. #include "common.h"
  12. #include "board_cfg.h"
  13. #include "gd32e23x.h"
  14. static void feed_dog(void);
  15. void fwdgt_Init(void)
  16. {
  17. board_t * board = get_board();
  18. #if OPEN_WATCH_DOG
  19. uint16_t timeout = 0xFFFFU;
  20. rcu_osci_on(RCU_IRC40K);
  21. while(SUCCESS != rcu_osci_stab_wait(RCU_IRC40K))
  22. {
  23. if(timeout > 0)
  24. timeout--;
  25. else
  26. break;
  27. }
  28. fwdgt_config(2000,FWDGT_PSC_DIV64); //800ms
  29. fwdgt_write_disable();
  30. fwdgt_enable();
  31. #endif
  32. board->feed_dog = feed_dog;
  33. }
  34. static void feed_dog(void)
  35. {
  36. #if OPEN_WATCH_DOG
  37. fwdgt_write_enable();
  38. fwdgt_counter_reload();
  39. #endif
  40. }