blob: 92f822515aed4086efe15370638d18a60db0abd4 (
plain)
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
|
/*!
* @file apm32e10x_iwdt.c
*
* @brief This file provides all the IWDT firmware functions
*
* @version V1.0.2
*
* @date 2022-12-31
*
* @attention
*
* Copyright (C) 2021-2023 Geehy Semiconductor
*
* You may not use this file except in compliance with the
* GEEHY COPYRIGHT NOTICE (GEEHY SOFTWARE PACKAGE LICENSE).
*
* The program is only for reference, which is distributed in the hope
* that it will be useful and instructional for customers to develop
* their software. Unless required by applicable law or agreed to in
* writing, the program is distributed on an "AS IS" BASIS, WITHOUT
* ANY WARRANTY OR CONDITIONS OF ANY KIND, either express or implied.
* See the GEEHY SOFTWARE PACKAGE LICENSE for the governing permissions
* and limitations under the License.
*/
#include "apm32e10x_iwdt.h"
/** @addtogroup APM32E10x_StdPeriphDriver
@{
*/
/** @addtogroup IWDT_Driver
* @brief IWDT driver modules
@{
*/
/** @defgroup IWDT_Functions Functions
@{
*/
/*!
* @brief Enable IWDT
*
* @param None
*
* @retval None
*/
void IWDT_Enable(void)
{
IWDT->KEY = IWDT_KEYWORD_ENABLE;
}
/*!
* @brief Reload the IWDT counter with value
*
* @param None
*
* @retval None
*/
void IWDT_Refresh(void)
{
IWDT->KEY = IWDT_KEYWORD_RELOAD;
}
/*!
* @brief Set IWDT count reload values
*
* @param reload: IWDT count reload values
*
* @retval None
*/
void IWDT_ConfigReload(uint16_t reload)
{
IWDT->CNTRLD = reload;
}
/*!
* @brief Enable the IWDT write access
*
* @param None
*
* @retval None
*/
void IWDT_EnableWriteAccess(void)
{
IWDT->KEY_B.KEY = IWDT_WRITEACCESS_ENABLE;
}
/*!
* @brief Disable the IWDT write access
*
* @param None
*
* @retval None
*/
void IWDT_DisableWriteAccess(void)
{
IWDT->KEY_B.KEY = IWDT_WRITEACCESS_DISABLE;
}
/*!
* @brief Set IWDT frequency divider values
*
* @param div: IWDT frequency divider values
* This parameter can be one of the following values:
* @arg IWDT_DIVIDER_4 : prescaler divider equal to 4
* @arg IWDT_DIVIDER_8 : prescaler divider equal to 8
* @arg IWDT_DIVIDER_16 : prescaler divider equal to 16
* @arg IWDT_DIVIDER_32 : prescaler divider equal to 32
* @arg IWDT_DIVIDER_64 : prescaler divider equal to 64
* @arg IWDT_DIVIDER_128: prescaler divider equal to 128
* @arg IWDT_DIVIDER_256: prescaler divider equal to 256
*
* @retval None
*/
void IWDT_ConfigDivider(uint8_t div)
{
IWDT->PSC = div;
}
/*!
* @brief Read the specified IWDT flag
*
* @param flag: specifies the flag to read
* This parameter can be one of the following values:
* @arg IWDT_FLAG_PSCU : Watchdog Prescaler Factor Update flag
* @arg IWDT_FLAG_CNTU : Watchdog Counter Reload Value Update flag
*
* @retval status of IWDT_FLAG (SET or RESET)
*
* @note
*/
uint8_t IWDT_ReadStatusFlag(uint16_t flag)
{
uint8_t bitStatus = RESET;
if((IWDT->STS & flag) != (uint32_t)RESET)
{
bitStatus = SET;
}
else
{
bitStatus = RESET;
}
return bitStatus;
}
/**@} end of group IWDT_Functions */
/**@} end of group IWDT_Driver */
/**@} end of group APM32E10x_StdPeriphDriver */
|