Fwdgt.c 458 B

12345678910111213141516171819202122232425262728293031
  1. #include "Fwdgt.h"
  2. #include "stdint.h"
  3. #include "gd32f30x_libopt.h"
  4. void Fwdgt_Init(void)
  5. {
  6. uint16_t timeout = 0xFFFFU;
  7. rcu_osci_on(RCU_IRC40K);
  8. while(SUCCESS != rcu_osci_stab_wait(RCU_IRC40K))
  9. {
  10. if(timeout > 0)
  11. timeout--;
  12. else
  13. break;
  14. }
  15. fwdgt_config(2000,FWDGT_PSC_DIV64); //800ms
  16. fwdgt_write_disable();
  17. fwdgt_enable();
  18. }
  19. void Fwdgt_reload(void)
  20. {
  21. fwdgt_write_enable();
  22. fwdgt_counter_reload();
  23. }