watchdog.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /**
  2. * @file watchdog.h
  3. * @author chipsea
  4. * @brief
  5. * @version 0.1
  6. * @date 2020-11-30
  7. * @copyright Copyright (c) 2020, CHIPSEA Co., Ltd.
  8. * @note
  9. */
  10. #ifndef __WATCHDOG_H__
  11. #define __WATCHDOG_H__
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. #include "types.h"
  16. typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState_t;
  17. /// Callback function pointer type
  18. typedef void (*pfnHdlCB_t)(void);
  19. /**
  20. * @brief wdt 溢出时间选择.
  21. */
  22. typedef enum{
  23. WDG_2S = 0,
  24. WDG_4S = 1,
  25. WDG_8S = 2,
  26. WDG_16S = 3,
  27. WDG_32S = 4,
  28. WDG_64S = 5,
  29. WDG_128S = 6,
  30. WDG_256S = 7
  31. }WDG_CYCLE_Type_e;
  32. /**
  33. * @enum WdtRspMode_t
  34. * @brief wdt response mode struct
  35. */
  36. typedef enum
  37. {
  38. WDG_USE_POLLING_MODE = 0, //this mode is recommended
  39. WDG_USE_INT_MODE = 1, //when timeout, first generate an interrupt and if it is not cleared by the time a second timeout occurs,
  40. //then generate a system reset.timeout:about 4s(32.768Khz,0xffff~0,twice + Reset pulse length(pclk))
  41. } WdtRspMode_t;
  42. /* wdt overflow timer config*/
  43. #define HAL_WDG_CFG_CYCLE WDG_2S
  44. /**
  45. * @fn void HalWdtInit(FunctionalState_t newState, WdtRspMode_t mode, pfnHdlCB_t irqHdlCallback)
  46. * @brief wdt initialize
  47. * @param[in] newState: ENABLE or DISABLE
  48. * @param[in] mode: WDT_RSP_MODE_NO_INT or WDT_RSP_MODE_INT
  49. * @param[in] irqHdlCallback: interrupt handle callback
  50. * @return none.
  51. */
  52. void HalWdtInit(FunctionalState_t newState, WdtRspMode_t mode,pfnHdlCB_t irqHdlCallback);
  53. /**
  54. * @fn void HalWdtFeed(void)
  55. * @brief wdt feed
  56. * @param[in] none
  57. * @return none.
  58. */
  59. void HalWdtFeed(void);
  60. #ifdef __cplusplus
  61. }
  62. #endif
  63. #endif