HAL_WDT.h 3.7 KB
Newer Older
Z
ze9hyr 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118

/***********************************************************************
 * Filename    : HAL_WDT.h
 * Description : HAL WDT driver header file
 * Author(s)   : CWT
 * version     : V1.0
 * Modify date : 2020-04-17
 ***********************************************************************/

#ifndef __HAL_WDT_H__
#define __HAL_WDT_H__

#include "ACM32Fxx_HAL.h"


/****************  Bit definition for WDT CTRL register  ********************/
#define WDT_CTRL_EN                         BIT7
#define WDT_CTRL_MODE                       BIT6
#define WDT_CTRL_INTEN                      BIT4
#define WDT_CTRL_DIVISOR                    (BIT0|BIT1|BIT2)

/****************  Bit definition for WDTRIS register  ********************/
#define WDT_WDTRIS                          BIT0

typedef enum
{
    WDT_MODE_RST = 0x00U,
    WDT_MODE_INT = 0x01U,
} WDT_MODE;

typedef enum
{
    WDT_DIVISOR_NONE = 0x00U,
    WDT_DIVISOR_2 = 0x01U,
    WDT_DIVISOR_4 = 0x02U,
    WDT_DIVISOR_8 = 0x03U,
    WDT_DIVISOR_16 = 0x04U,
    WDT_DIVISOR_32 = 0x05U,
    WDT_DIVISOR_64 = 0x06U,
    WDT_DIVISOR_128 = 0x07U,
} WDT_DIVISOR;

typedef struct
{
    WDT_DIVISOR WDTDivisor;
    WDT_MODE WDTMode;
    uint32_t WDTLoad;
    uint32_t WDTINTCLRTIME;
} WDT_InitTypeDef;

typedef struct
{
    WDT_TypeDef            *Instance;                /*!< WDT registers base address        */
    WDT_InitTypeDef         Init;                    /*!< WDT communication parameters      */
}WDT_HandleTypeDef;

#define WDT_ENABLE                      (0x01 << 7)
#define WDT_DISABLE                     (~WDT_ENABLE)
#define WDT_INT_ENABLE                  (0x01 << 4)
#define WDT_INT_DISABLE                 (~WDT_INT_ENABLE)
/************************************************************************
 * function   : HAL_WDT_Feed
 * Description: WDT feed.
 * input :
 *         none
 * return: none
 ************************************************************************/
 void HAL_WDT_Feed(WDT_HandleTypeDef* hwdt);
/************************************************************************
 * function   : WDT_IRQHandler
 * Description: WDT interrupt service routine.
 * input :
 *         none
 * return: none
 ************************************************************************/
 void HAL_WDT_IRQHandler(WDT_HandleTypeDef* hwdt);
/************************************************************************
 * function   : HAL_WDT_Init
 * Description: WDT initiation.
 * input :
 *         pinit initiation parameters
 * return: none
 ************************************************************************/
 void HAL_WDT_Init(WDT_HandleTypeDef* hwdt);
/************************************************************************
 * function   : WDT_Start
 * Description: WDT start
 * input : none
 *
 * return: none
 ************************************************************************/
 void HAL_WDT_Start(WDT_HandleTypeDef* hwdt);
/************************************************************************
 * function   : WDT_Stop
 * Description: WDT stop
 * input : none
 *
 * return: none
 ************************************************************************/
 void HAL_WDT_Stop(WDT_HandleTypeDef* hwdt);
/************************************************************************
 * function   : WDT_Int_Enable
 * Description: WDT int enable
 * input : none
 *
 * return: none
 ************************************************************************/
 void HAL_WDT_Int_Enable(WDT_HandleTypeDef* hwdt);
/************************************************************************
 * function   : WDT_Int_Disable
 * Description: WDT int disable
 * input : none
 *
 * return: none
 ************************************************************************/
 void HAL_WDT_Int_Disable(WDT_HandleTypeDef* hwdt);

#endif