Fwdgt.c 483 B

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