PDL for FM4  Version1.2
Peripheral Driverl Library for FM4
swwdg.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 __SWWDG_H__
52 #define __SWWDG_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 
116 
117 /*****************************************************************************/
118 /* Global pre-processor symbols/macros ('#define') */
119 /*****************************************************************************/
120 /* for WDOGLOCK */
121 #define SWWDG_REG_UNLOCK (0x1ACCE551u)
122 
123 /******************************************************************************
124  * Global type definitions
125  ******************************************************************************/
126 
132 {
138 
143 typedef struct stc_swwdg_config
144 {
145  uint32_t u32LoadValue;
149  uint8_t u8TimingWindow;
151 
152 /******************************************************************************/
153 /* Local type definitions ('typedef') */
154 /******************************************************************************/
155 
156 /******************************************************************************/
157 /* Global variable definitions ('extern') */
158 /******************************************************************************/
159 
160 /******************************************************************************/
161 /* Global function prototypes (definition in C source) */
162 /******************************************************************************/
163 /* Interrupt */
164 extern void SwwdgIrqHandler(void);
165 
166 /* Setup(Initialize)/Disable(Un-initialize) */
167 extern en_result_t Swwdg_Init(stc_swwdg_config_t* pstcConfig);
168 extern void Swwdg_DeInit(void);
169 
170 /* Start/Stop */
171 extern en_result_t Swwdg_Start(func_ptr_t pfnSwwdgCb);
172 extern void Swwdg_Stop(void);
173 
174 /* Write/Read for counter */
175 extern void Swwdg_WriteWdgLoad(uint32_t u32LoadValue);
176 extern uint32_t Swwdg_ReadWdgValue(void);
177 
178 /* Feed watchdog */
179 extern void Swwdg_Feed(void) ;
180 static void Swwdg_QuickFeed(void);
181 
182 /* Setting Debug Break Watchdog Timer Control */
183 extern void Swwdg_EnableDbgBrkWdgCtl(void);
184 extern void Swwdg_DisableDbgBrkWdgCtl(void);
185 
186 /******************************************************************************/
187 /* Static inline functions */
188 /******************************************************************************/
189 
197 static __INLINE void Swwdg_QuickFeed(void)
198 {
199  FM4_SWWDT->WDOGLOCK = SWWDG_REG_UNLOCK; /* Release Lock */
200  FM4_SWWDT->WDOGINTCLR = 1; /* Clear possible interrupt and reload value */
201  FM4_SWWDT->WDOGLOCK = 0; /* Lock again it! */
202 } /* Swwdg_QuickFeed */
203 
205 
206 #ifdef __cplusplus
207 }
208 #endif
209 
210 #endif /* #if (defined(PDL_PERIPHERAL_WDG_ACTIVE)) */
211 
212 #endif /* __SWWDG_H__ */
213 /******************************************************************************/
214 /* EOF (not truncated) */
215 /******************************************************************************/