gd32f30x_wwdgt.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*!
  2. \file gd32f30x_wwdgt.h
  3. \brief definitions for the WWDGT
  4. */
  5. /*
  6. Copyright (C) 2017 GigaDevice
  7. 2017-02-10, V1.0.0, firmware for GD32F30x
  8. */
  9. #ifndef GD32F30X_WWDGT_H
  10. #define GD32F30X_WWDGT_H
  11. #include "gd32f30x.h"
  12. /* WWDGT definitions */
  13. #define WWDGT WWDGT_BASE
  14. /* registers definitions */
  15. #define WWDGT_CTL REG32((WWDGT) + 0x00U) /*!< WWDGT control register */
  16. #define WWDGT_CFG REG32((WWDGT) + 0x04U) /*!< WWDGT configuration register */
  17. #define WWDGT_STAT REG32((WWDGT) + 0x08U) /*!< WWDGT status register */
  18. /* bits definitions */
  19. /* WWDGT_CTL */
  20. #define WWDGT_CTL_CNT BITS(0,6) /*!< WWDGT counter value */
  21. #define WWDGT_CTL_WDGTEN BIT(7) /*!< WWDGT counter enable */
  22. /* WWDGT_CFG */
  23. #define WWDGT_CFG_WIN BITS(0,6) /*!< WWDGT counter window value */
  24. #define WWDGT_CFG_PSC BITS(7,8) /*!< WWDGT prescaler divider value */
  25. #define WWDGT_CFG_EWIE BIT(9) /*!< early wakeup interrupt enable */
  26. /* WWDGT_STAT */
  27. #define WWDGT_STAT_EWIF BIT(0) /*!< early wakeup interrupt flag */
  28. /* constants definitions */
  29. #define CFG_PSC(regval) (BITS(7,8) & ((uint32_t)(regval) << 7)) /*!< write value to WWDGT_CFG_PSC bit field */
  30. #define WWDGT_CFG_PSC_DIV1 CFG_PSC(0) /*!< the time base of WWDGT = (PCLK1/4096)/1 */
  31. #define WWDGT_CFG_PSC_DIV2 CFG_PSC(1) /*!< the time base of WWDGT = (PCLK1/4096)/2 */
  32. #define WWDGT_CFG_PSC_DIV4 CFG_PSC(2) /*!< the time base of WWDGT = (PCLK1/4096)/4 */
  33. #define WWDGT_CFG_PSC_DIV8 CFG_PSC(3) /*!< the time base of WWDGT = (PCLK1/4096)/8 */
  34. /* function declarations */
  35. /* reset the window watchdog timer configuration */
  36. void wwdgt_deinit(void);
  37. /* start the window watchdog timer counter */
  38. void wwdgt_enable(void);
  39. /* configure the window watchdog timer counter value */
  40. void wwdgt_counter_update(uint16_t counter_value);
  41. /* configure counter value, window value, and prescaler divider value */
  42. void wwdgt_config(uint16_t counter, uint16_t window, uint32_t prescaler);
  43. /* enable early wakeup interrupt of WWDGT */
  44. void wwdgt_interrupt_enable(void);
  45. /* check early wakeup interrupt state of WWDGT */
  46. FlagStatus wwdgt_flag_get(void);
  47. /* clear early wakeup interrupt state of WWDGT */
  48. void wwdgt_flag_clear(void);
  49. #endif /* GD32F30X_WWDGT_H */