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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
|
/**
*********************************************************************************
*
* @file ald_wdt.c
* @brief WDT module driver.
*
* @version V1.0
* @date 18 Dec 2019
* @author AE Team
* @note
* Change Logs:
* Date Author Notes
* 18 Dec 2019 AE Team The first version
*
* Copyright (C) Shanghai Eastsoft Microelectronics Co. Ltd. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**********************************************************************************
*/
#include "ald_conf.h"
/** @addtogroup ES32FXXX_ALD
* @{
*/
/** @defgroup WDT WDT
* @brief WDT module driver
* @{
*/
#ifdef ALD_WDT
/** @defgroup WWDT_Public_Functions WWDT Public Functions
* @brief Init and configure WWDT function
* @{
*/
/**
* @brief Initializes the WWDT according to the specified parameters.
* @param load: Specifies the free-running downcounter value.
* @param win: specifics the no dog windows,
* the parameter can be one of the following values:
* @arg @ref WWDT_WIN_25 No dog window size: 25%
* @arg @ref WWDT_WIN_50 No dog window size: 50%
* @arg @ref WWDT_WIN_75 No dog window size: 75%
* @arg @ref WWDT_WIN_00 No dog window size: 0%
* @param interrupt: Enable or disable interrupt.
* @retval None
*/
void ald_wwdt_init(uint32_t load, wwdt_win_t win, type_func_t interrupt)
{
assert_param(IS_WWDT_WIN_TYPE(win));
assert_param(IS_FUNC_STATE(interrupt));
WWDT_UNLOCK();
WRITE_REG(WWDT->LOAD, load);
MODIFY_REG(WWDT->CON, WWDT_CON_WWDTWIN_MSK, win << WWDT_CON_WWDTWIN_POSS);
SET_BIT(WWDT->CON, WWDT_CON_CLKS_MSK);
SET_BIT(WWDT->CON, WWDT_CON_RSTEN_MSK);
MODIFY_REG(WWDT->CON, WWDT_CON_IE_MSK, interrupt << WWDT_CON_IE_POS);
WWDT_LOCK();
return;
}
/**
* @brief Start the WWDT
* @retval None
*/
void ald_wwdt_start(void)
{
WWDT_UNLOCK();
SET_BIT(WWDT->CON, WWDT_CON_EN_MSK);
WWDT_LOCK();
return;
}
/**
* @brief Get the free-running downcounter value
* @retval Value
*/
uint32_t ald_wwdt_get_value(void)
{
return WWDT->VALUE;
}
/**
* @brief Get interrupt state
* @retval Value
*/
it_status_t ald_wwdt_get_flag_status(void)
{
if (READ_BIT(WWDT->RIS, WWDT_RIS_WWDTIF_MSK))
return SET;
return RESET;
}
/**
* @brief Clear interrupt state
* @retval None
*/
void ald_wwdt_clear_flag_status(void)
{
WRITE_REG(WWDT->INTCLR, 1);
return;
}
/**
* @brief Refreshes the WWDT
* @retval None
*/
void ald_wwdt_feed_dog(void)
{
uint16_t i = 0;
WWDT_UNLOCK();
WRITE_REG(WWDT->INTCLR, 0x1);
WWDT_LOCK();
for (i = 0; i < 0x2ff; ++i)
__NOP();
return;
}
/**
* @}
*/
/** @defgroup IWDT_Public_Functions IWDT Public Functions
* @brief Init and configure IWDT function
* @{
*/
/**
* @brief Initializes the IWDG according to the specified parameters.
* @param load: Specifies the free-running downcounter value.
* @param interrupt: Enable or disable interrupt.
* @retval None
*/
void ald_iwdt_init(uint32_t load, type_func_t interrupt)
{
assert_param(IS_FUNC_STATE(interrupt));
IWDT_UNLOCK();
WRITE_REG(IWDT->LOAD, load);
SET_BIT(IWDT->CON, IWDT_CON_CLKS_MSK);
SET_BIT(IWDT->CON, IWDT_CON_RSTEN_MSK);
MODIFY_REG(IWDT->CON, IWDT_CON_IE_MSK, interrupt << IWDT_CON_IE_POS);
IWDT_LOCK();
return;
}
/**
* @brief Start the IWDT
* @retval None
*/
void ald_iwdt_start(void)
{
IWDT_UNLOCK();
SET_BIT(IWDT->CON, IWDT_CON_EN_MSK);
IWDT_LOCK();
return;
}
/**
* @brief Get the free-running downcounter value
* @retval Value
*/
uint32_t ald_iwdt_get_value(void)
{
return IWDT->VALUE;
}
/**
* @brief Get interrupt state
* @retval Value
*/
it_status_t ald_iwdt_get_flag_status(void)
{
if (READ_BIT(IWDT->RIS, IWDT_RIS_WDTIF_MSK))
return SET;
return RESET;
}
/**
* @brief Clear interrupt state
* @retval None
*/
void ald_iwdt_clear_flag_status(void)
{
IWDT_UNLOCK();
WRITE_REG(IWDT->INTCLR, 1);
IWDT_LOCK();
return;
}
/**
* @brief Refreshes the WWDT
* @retval None
*/
void ald_iwdt_feed_dog(void)
{
uint16_t i = 0;
IWDT_UNLOCK();
WRITE_REG(IWDT->INTCLR, 1);
IWDT_LOCK();
for (i = 0; i < 0x2ff; ++i)
__NOP();
return;
}
/**
* @}
*/
#endif /* ALD_WDT */
/**
* @}
*/
/**
* @}
*/
|