WXK
2024-12-16 78e84fcf264afd731cd66c807d9fcb690fe12126
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
/****************************************************************************
 * @file     pan_wwdt.h
 * @version  V1.00
 * $Revision: 2$
 * $Date: 2023/11/08 $  
 * @brief    Panchip series WWDT driver header file
 *
 * @note
 * Copyright (C) 2023 Panchip Technology Corp. All rights reserved.
 *****************************************************************************/
 
#ifndef __PAN_WWDT_H__
#define __PAN_WWDT_H__
 
/**
 * @brief Wwdt Interface
 * @defgroup wwdt_interface Wwdt Interface
 * @{
 */
 
#ifdef __cplusplus
extern "C"
{
#endif
 
 
/**@defgroup WWDT_PRESCARE_FLAG Wdt prescare 
 * @brief       Wdt prescare definition
 * @{ */
typedef enum _WWDT_Prescale
{
    WWDT_PRESCALER_1        = (0UL << WWDT_CTL_PSCSEL_Pos),   /*!< WWDT setting prescaler to 1     \hideinitializer */
    WWDT_PRESCALER_2        = (1UL << WWDT_CTL_PSCSEL_Pos),   /*!< WWDT setting prescaler to 2     \hideinitializer */
    WWDT_PRESCALER_4        = (2UL << WWDT_CTL_PSCSEL_Pos),   /*!< WWDT setting prescaler to 4     \hideinitializer */
    WWDT_PRESCALER_8        = (3UL << WWDT_CTL_PSCSEL_Pos),   /*!< WWDT setting prescaler to 8     \hideinitializer */
    WWDT_PRESCALER_16       = (4UL << WWDT_CTL_PSCSEL_Pos),   /*!< WWDT setting prescaler to 16    \hideinitializer */
    WWDT_PRESCALER_32       = (5UL << WWDT_CTL_PSCSEL_Pos),   /*!< WWDT setting prescaler to 32    \hideinitializer */
    WWDT_PRESCALER_64       = (6UL << WWDT_CTL_PSCSEL_Pos),   /*!< WWDT setting prescaler to 64    \hideinitializer */
    WWDT_PRESCALER_128      = (7UL << WWDT_CTL_PSCSEL_Pos),   /*!< WWDT setting prescaler to 128   \hideinitializer */
    WWDT_PRESCALER_192      = (8UL << WWDT_CTL_PSCSEL_Pos),   /*!< WWDT setting prescaler to 192   \hideinitializer */
    WWDT_PRESCALER_256      = (9UL << WWDT_CTL_PSCSEL_Pos),   /*!< WWDT setting prescaler to 256   \hideinitializer */
    WWDT_PRESCALER_384      = (0xAUL << WWDT_CTL_PSCSEL_Pos), /*!< WWDT setting prescaler to 384   \hideinitializer */
    WWDT_PRESCALER_512      = (0xBUL << WWDT_CTL_PSCSEL_Pos), /*!< WWDT setting prescaler to 512   \hideinitializer */
    WWDT_PRESCALER_768      = (0xCUL << WWDT_CTL_PSCSEL_Pos), /*!< WWDT setting prescaler to 768   \hideinitializer */
    WWDT_PRESCALER_1024     = (0xDUL << WWDT_CTL_PSCSEL_Pos), /*!< WWDT setting prescaler to 1024  \hideinitializer */
    WWDT_PRESCALER_1536     = (0xEUL << WWDT_CTL_PSCSEL_Pos), /*!< WWDT setting prescaler to 1536  \hideinitializer */
    WWDT_PRESCALER_2048     = (0xFUL << WWDT_CTL_PSCSEL_Pos)  /*!< WWDT setting prescaler to 2048  \hideinitializer */
} WWDT_PrescaleDef;
/**@} */
 
#define WWDT_RELOAD_WORD          (0x00005AA5)                     ///< Fill this value to RLD register to reload WWDT counter  \hideinitializer 
 
 
/**
  * @brief This function clear WWDT time-out reset system flag.
  * @param None
  * @return None
  * \hideinitializer
  */
__STATIC_INLINE void WWDT_ClearResetFlag(void)
{
    WWDT->STATUS = WWDT_STATUS_WWDTRF_Msk;
}
 
/**
  * @brief This function clear WWDT compare match interrupt flag.
  * @param None
  * @return None
  * \hideinitializer
  */
__STATIC_INLINE void WWDT_ClearIntFlag(void)
{
    WWDT->STATUS = WWDT_STATUS_WWDTIF_Msk;
}
 
/**
  * @brief This function clear WWDT compare match event flag.
  * @param None
  * @return None
  * \hideinitializer
  */
__STATIC_INLINE void WWDT_ClearWWDTFFlag(void)
{
    WWDT->STATUS = WWDT_STATUS_WWDTF_Msk;
}
 
/**
  * @brief This function is use to get WWDT time-out reset system flag.
  * @return WWDT reset system or not
  * @retval false WWDT did not cause system reset
  * @retval true  WWDT caused system reset
  * \hideinitializer
  */
__STATIC_INLINE bool WWDT_GetResetFlag(void)
{
    return (WWDT->STATUS & WWDT_STATUS_WWDTRF_Msk) ? true : false;
}
 
/**
  * @brief This function is used to indicate WWDT compare match interrupt flag.
  * @return WWDT compare match interrupt occurred or not
  * @retval false WWDT compare match interrupt did not occur
  * @retval true  WWDT compare match interrupt occurred
  * \hideinitializer
  */
__STATIC_INLINE bool WWDT_GetIntFlag(void)
{
    return (WWDT->STATUS & WWDT_STATUS_WWDTIF_Msk) ? true : false;
}
 
/**
  * @brief This function is used to indicate WWDT compare match event flag.
  * @return WWDT compare match interrupt occurred or not
  * @retval false WWDT compare match interrupt did not occur
  * @retval true  WWDT compare match interrupt occurred
  * \hideinitializer
  */
__STATIC_INLINE bool WWDT_GetWWDTFFlag(void)
{
    return (WWDT->STATUS & WWDT_STATUS_WWDTF_Msk) ? true : false;
}
 
/**
  * @brief This function to reflects current WWDT counter value
  * @param None
  * @return Return current WWDT counter value
  * \hideinitializer
  */
__STATIC_INLINE uint32_t WWDT_GetCounter(void)
{
    return WWDT->CNT;
}
 
/**
  * @brief This function reflects current WWDT compare value (CMPDAT)
  * @param None
  * @return Return current WWDT compare value
  * \hideinitializer
  */
__STATIC_INLINE uint32_t WWDT_GetCompareValue(void)
{
    return (WWDT->CTL & WWDT_CTL_CMPDAT_Msk) >> WWDT_CTL_CMPDAT_Pos;
}
 
/**
  * @brief This function is used to reload the WWDT counter value to 0x3F.
  * @param None
  * @return None
  * @details After WWDT enabled, application must reload WWDT counter while
  *          current counter is less than compare value and larger than 0,
  *          otherwise WWDT will cause system reset.
  * \hideinitializer
  */
__STATIC_INLINE void WWDT_ReloadCounter(void)
{
    WWDT->RLDCNT  = WWDT_RELOAD_WORD;
}
 
/**
 * @brief This function make WWDT module start counting with different counter period and compared window value
 * @param[in] preScale  Prescale period for the WWDT counter period. Valid values are:
 *              - \ref WWDT_PRESCALER_1
 *              - \ref WWDT_PRESCALER_2
 *              - \ref WWDT_PRESCALER_4
 *              - \ref WWDT_PRESCALER_8
 *              - \ref WWDT_PRESCALER_16
 *              - \ref WWDT_PRESCALER_32
 *              - \ref WWDT_PRESCALER_64
 *              - \ref WWDT_PRESCALER_128
 *              - \ref WWDT_PRESCALER_192
 *              - \ref WWDT_PRESCALER_256
 *              - \ref WWDT_PRESCALER_384
 *              - \ref WWDT_PRESCALER_512
 *              - \ref WWDT_PRESCALER_768
 *              - \ref WWDT_PRESCALER_1024
 *              - \ref WWDT_PRESCALER_1536
 *              - \ref WWDT_PRESCALER_2048
 * @param[in] u32CmpValue Window compared value. Valid values are between 0x0 to 0x3F
 * @param[in] u32EnableInt Enable WWDT interrupt or not. Valid values are TRUE and  FALSE
 * @return None
 * @note Application can call this function can only once after boot up
 */
void WWDT_Open(WWDT_PrescaleDef preScale, uint32_t u32CmpValue, uint32_t u32EnableInt);
 
/**
 * @brief This function stops WWDT counting 
 * @return None
 */
void WWDT_Close(void);
 
/*@}*/ /* end of group wwdt_interface Wwdt Interface */
 
#ifdef __cplusplus
}
#endif
 
#endif //__PAN_WWDT_H__
 
/*** (C) COPYRIGHT 2016 Panchip Technology Corp. ***/