gd32f3x0_wwdgt.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*!
  2. \file gd32f3x0_wwdgt.h
  3. \brief definitions for the WWDGT
  4. */
  5. /*
  6. Copyright (C) 2017 GigaDevice
  7. 2017-06-06, V1.0.0, firmware for GD32F3x0
  8. */
  9. #ifndef GD32F3X0_WWDGT_H
  10. #define GD32F3X0_WWDGT_H
  11. #include "gd32f3x0.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) /*!< WWDGT early wakeup interrupt enable */
  26. /* WWDGT_STAT */
  27. #define WWDGT_STAT_EWIF BIT(0) /*!< WWDGT early wakeup interrupt flag */
  28. /* constants definitions */
  29. /* WWDGT_CTL register value */
  30. #define CTL_CNT(regval) (BITS(0,6) & ((uint32_t)(regval) << 0U)) /*!< write value to WWDGT_CTL_CNT bit field */
  31. /* WWDGT_CFG register value */
  32. #define CFG_WIN(regval) (BITS(0,6) & ((uint32_t)(regval) << 0U)) /*!< write value to WWDGT_CFG_WIN bit field */
  33. #define CFG_PSC(regval) (BITS(7,8) & ((uint32_t)(regval) << 7U)) /*!< write value to WWDGT_CFG_PSC bit field */
  34. #define WWDGT_CFG_PSC_DIV1 ((uint32_t)CFG_PSC(0)) /*!< the time base of WWDGT = (PCLK1/4096)/1 */
  35. #define WWDGT_CFG_PSC_DIV2 ((uint32_t)CFG_PSC(1)) /*!< the time base of WWDGT = (PCLK1/4096)/2 */
  36. #define WWDGT_CFG_PSC_DIV4 ((uint32_t)CFG_PSC(2)) /*!< the time base of WWDGT = (PCLK1/4096)/4 */
  37. #define WWDGT_CFG_PSC_DIV8 ((uint32_t)CFG_PSC(3)) /*!< the time base of WWDGT = (PCLK1/4096)/8 */
  38. /* function declarations */
  39. /* reset the window watchdog timer configuration */
  40. void wwdgt_deinit(void);
  41. /* start the window watchdog timer counter */
  42. void wwdgt_enable(void);
  43. /* configure the window watchdog timer counter value */
  44. void wwdgt_counter_update(uint16_t counter_value);
  45. /* configure counter value, window value, and prescaler divider value */
  46. void wwdgt_config(uint16_t counter, uint16_t window, uint32_t prescaler);
  47. /* enable early wakeup interrupt of WWDGT */
  48. void wwdgt_interrupt_enable(void);
  49. /* check early wakeup interrupt state of WWDGT */
  50. FlagStatus wwdgt_flag_get(void);
  51. /* clear early wakeup interrupt state of WWDGT */
  52. void wwdgt_flag_clear(void);
  53. #endif /* GD32F3X0_WWDGT_H */