PDL for FM4  Version1.2
Peripheral Driverl Library for FM4
hwwdg.h
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright (C) 2013 Spansion LLC. All Rights Reserved.
3 *
4 * This software is owned and published by:
5 * Spansion LLC, 915 DeGuigne Dr. Sunnyvale, CA 94088-3453 ("Spansion").
6 *
7 * BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND
8 * BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT.
9 *
10 * This software contains source code for use with Spansion
11 * components. This software is licensed by Spansion to be adapted only
12 * for use in systems utilizing Spansion components. Spansion shall not be
13 * responsible for misuse or illegal use of this software for devices not
14 * supported herein. Spansion is providing this software "AS IS" and will
15 * not be responsible for issues arising from incorrect user implementation
16 * of the software.
17 *
18 * SPANSION MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE,
19 * REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS),
20 * ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING,
21 * WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED
22 * WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED
23 * WARRANTY OF NONINFRINGEMENT.
24 * SPANSION SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT,
25 * NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT
26 * LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION,
27 * LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR
28 * INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT,
29 * INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA,
30 * SAVINGS OR PROFITS,
31 * EVEN IF SPANSION HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
32 * YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR
33 * INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED
34 * FROM, THE SOFTWARE.
35 *
36 * This software may be replicated in part or whole for the licensed use,
37 * with the restriction that this Disclaimer and Copyright notice must be
38 * included with each copy of this software, whether used in part or whole,
39 * at all times.
40 */
41 /******************************************************************************/
51 #ifndef __HWWDG_H__
52 #define __HWWDG_H__
53 
54 /******************************************************************************/
55 /* Include files */
56 /******************************************************************************/
57 #include "pdl.h"
58 
59 #if (defined(PDL_PERIPHERAL_WDG_ACTIVE))
60 
61 /* C binding of definitions if building with C++ compiler */
62 #ifdef __cplusplus
63 extern "C"
64 {
65 #endif
66 
112 
113 /*****************************************************************************/
114 /* Global pre-processor symbols/macros ('#define') */
115 /*****************************************************************************/
116 /* for WDG_LCK */
117 #define HWWDG_REG_UNLOCK_1 (0x1ACCE551u)
118 #define HWWDG_REG_UNLOCK_2 (0xE5331AAEu)
119 
120 /******************************************************************************
121  * Global type definitions
122  ******************************************************************************/
123 
128 typedef struct stc_hwwdg_config
129 {
130  uint32_t u32LoadValue;
133 
134 /******************************************************************************/
135 /* Local type definitions ('typedef') */
136 /******************************************************************************/
137 
138 /******************************************************************************/
139 /* Global variable definitions ('extern') */
140 /******************************************************************************/
141 
142 /******************************************************************************/
143 /* Global function prototypes (definition in C source) */
144 /******************************************************************************/
145 /* Interrupt */
146 extern void HwwdgIrqHandler(void);
147 
148 /* Setup(Initialize)/Disable(Un-initialize) */
149 extern en_result_t Hwwdg_Init(stc_hwwdg_config_t* pstcConfig);
150 extern en_result_t Hwwdg_DeInit(uint32_t u32MagicWord1,
151  uint32_t u32MagicWord2
152  );
153 
154 /* Start/Stop */
155 extern en_result_t Hwwdg_Start(func_ptr_t pfnHwwdgCb);
156 extern void Hwwdg_Stop(void);
157 
158 /* Write/Read for counter */
159 extern void Hwwdg_WriteWdgLoad(uint32_t u32LoadValue);
160 extern uint32_t Hwwdg_ReadWdgValue(void);
161 
162 /* Feed watchdog */
163 extern void Hwwdg_Feed(uint8_t u8ClearPattern1,
164  uint8_t u8ClearPattern2
165  );
166 
167 extern void Hwwdg_EnableDbgBrkWdgCtl(void);
168 extern void Hwwdg_DisableDbgBrkWdgCtl(void);
169 
170 static void Hwwdg_QuickFeed(uint8_t u8ClearPattern1, uint8_t u8ClearPattern2);
171 
172 /******************************************************************************/
173 /* Static inline functions */
174 /******************************************************************************/
175 
188 static __INLINE void Hwwdg_QuickFeed(uint8_t u8ClearPattern1, uint8_t u8ClearPattern2)
189 {
190  FM4_HWWDT->WDG_LCK = HWWDG_REG_UNLOCK_1;/* Release Lock */
191  FM4_HWWDT->WDG_ICL = u8ClearPattern1; /* Clear possible interrupt and reload value, step 1 */
192  FM4_HWWDT->WDG_ICL = u8ClearPattern2; /* Clear possible interrupt and reload value, step 2 */
193 } /* Hwwdg_QuickFeed */
194 
196 
197 #ifdef __cplusplus
198 }
199 #endif
200 
201 #endif /* #if (defined(PDL_PERIPHERAL_WDG_ACTIVE)) */
202 
203 #endif /* __HWWDG_H__ */
204 /******************************************************************************/
205 /* EOF (not truncated) */
206 /******************************************************************************/