1 /*!
2  * @file        apm32f0xx_iwdt.h
3  *
4  * @brief       This file contains all the functions prototypes for the IWDT firmware library
5  *
6  * @version     V1.0.3
7  *
8  * @date        2022-09-20
9  *
10  * @attention
11  *
12  *  Copyright (C) 2020-2022 Geehy Semiconductor
13  *
14  *  You may not use this file except in compliance with the
15  *  GEEHY COPYRIGHT NOTICE (GEEHY SOFTWARE PACKAGE LICENSE).
16  *
17  *  The program is only for reference, which is distributed in the hope
18  *  that it will be useful and instructional for customers to develop
19  *  their software. Unless required by applicable law or agreed to in
20  *  writing, the program is distributed on an "AS IS" BASIS, WITHOUT
21  *  ANY WARRANTY OR CONDITIONS OF ANY KIND, either express or implied.
22  *  See the GEEHY SOFTWARE PACKAGE LICENSE for the governing permissions
23  *  and limitations under the License.
24  */
25 
26 /* Define to prevent recursive inclusion */
27 #ifndef __APM32F0XX_IWDT_H
28 #define __APM32F0XX_IWDT_H
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 /* Includes */
35 #include "apm32f0xx.h"
36 
37 /** @addtogroup APM32F0xx_StdPeriphDriver
38   @{
39 */
40 
41 /** @addtogroup IWDT_Driver
42   @{
43 */
44 
45 /** @defgroup IWDT_Macros Macros
46   @{
47 */
48 
49 /**@} end of group IWDT_Macros*/
50 
51 /** @defgroup IWDT_Enumerations Enumerations
52   @{
53 */
54 
55 /**@} end of group IWDT_Enumerations*/
56 
57 /** @defgroup IWDT_Structures Structures
58   @{
59 */
60 
61 /**@} end of group IWDT_Structures*/
62 
63 /** @defgroup IWDT_Variables Variables
64   @{
65 */
66 
67 /**@} end of group IWDT_Variables*/
68 
69 /** @defgroup IWDT_Functions Functions
70   @{
71 */
72 
73 /**
74  * @brief   IWDT key definition
75  */
76 typedef enum
77 {
78     IWDT_KEY_REFRESH = ((uint16_t)0xAAAA), /*!< Value of  Reload Register reoload to the counter to prevent the IWDT from resetting */
79     IWDT_KEY_ENABLE  = ((uint16_t)0xCCCC), /*!< Enable the IWDT then the counter starts to count down from the reset value */
80     IWDT_KEY_ACCESS  = ((uint16_t)0x5555), /*!< Rewrite the value of the Prescaler Register, Reload Register and Window Value Register */
81 } IWDT_KEY_T;
82 
83 /**
84  * @brief   IWDT divider
85  */
86 typedef enum
87 {
88     IWDT_DIV_4   = ((uint8_t)0x00), /*!< Prescaler divider 4 */
89     IWDT_DIV_8   = ((uint8_t)0x01), /*!< Prescaler divider 8 */
90     IWDT_DIV_16  = ((uint8_t)0x02), /*!< Prescaler divider 16 */
91     IWDT_DIV_32  = ((uint8_t)0x03), /*!< Prescaler divider 32 */
92     IWDT_DIV_64  = ((uint8_t)0x04), /*!< Prescaler divider 64 */
93     IWDT_DIV_128 = ((uint8_t)0x05), /*!< Prescaler divider 128 */
94     IWDT_DIV_256 = ((uint8_t)0x06), /*!< Prescaler divider 256 */
95 } IWDT_DIV_T;
96 
97 /**
98  * @brief   IWDT flag definition
99  */
100 typedef enum
101 {
102     IWDT_FLAG_DIVU = ((uint8_t)0X01), /*!< Watchdog prescaler value update */
103     IWDT_FLAG_CNTU = ((uint8_t)0X02), /*!< Watchdog counter reload value update */
104     IWDT_FLAG_WINU = ((uint8_t)0X04), /*!< Watchdog counter window value update */
105 } IWDT_FLAG_T;
106 
107 /**@} end of group IWDT_Enumerations*/
108 
109 /** @defgroup IWDT_Functions
110   @{
111 */
112 
113 /* Enable IWDT */
114 void IWDT_Enable(void);
115 
116 /* Refresh IWDT */
117 void IWDT_Refresh(void);
118 
119 /* Window Value */
120 void IWDT_ConfigWindowValue(uint16_t windowValue);
121 
122 /* Set Counter reload */
123 void IWDT_ConfigReload(uint16_t reload);
124 
125 /* Write Access */
126 void IWDT_EnableWriteAccess(void);
127 void IWDT_DisableWriteAccess(void);
128 
129 /* divider */
130 void IWDT_ConfigDivider(IWDT_DIV_T div);
131 
132 /* flag */
133 uint8_t IWDT_ReadStatusFlag(uint8_t flag);
134 
135 #ifdef __cplusplus
136 }
137 #endif
138 
139 #endif /* __APM32F0XX_IWDT_H */
140 
141 /**@} end of group IWDT_Functions*/
142 /**@} end of group IWDT_Driver */
143 /**@} end of group APM32F0xx_StdPeriphDriver*/
144