Kinetis Bootloader  2.0.0
Common bootloader for Kinetis devices
fsl_wdog32.h
1 /*
2  * Copyright (c) 2015, Freescale Semiconductor, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * o Redistributions of source code must retain the above copyright notice, this list
9  * of conditions and the following disclaimer.
10  *
11  * o Redistributions in binary form must reproduce the above copyright notice, this
12  * list of conditions and the following disclaimer in the documentation and/or
13  * other materials provided with the distribution.
14  *
15  * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
16  * contributors may be used to endorse or promote products derived from this
17  * software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 #ifndef _FSL_WDOG32_H_
31 #define _FSL_WDOG32_H_
32 
33 #include "fsl_common.h"
39 /*******************************************************************************
40  * Definitions
41  *******************************************************************************/
42 
44 #define FSL_WDOG32_DRIVER_VERSION (MAKE_VERSION(2, 0, 0))
47 typedef enum _wdog32_clock_source
48 {
54 
56 typedef enum _wdog32_clock_prescaler
57 {
61 
63 typedef struct _wdog32_work_mode
64 {
65  bool enableWait;
66  bool enableStop;
67  bool enableDebug;
69 
71 typedef enum _wdog32_test_mode
72 {
78 
80 typedef struct _wdog32_config
81 {
82  bool enableWdog32;
87  bool enableUpdate;
90  uint16_t windowValue;
91  uint16_t timeoutValue;
93 
100 {
101  kWDOG32_InterruptEnable = WDOG_CS_INT_MASK,
102 };
103 
110 {
111  kWDOG32_RunningFlag = WDOG_CS_EN_MASK,
112  kWDOG32_InterruptFlag = WDOG_CS_FLG_MASK,
113 };
114 
115 /*******************************************************************************
116  * API
117  *******************************************************************************/
118 
119 #if defined(__cplusplus)
120 extern "C" {
121 #endif /* __cplusplus */
122 
152 
172 void WDOG32_Init(WDOG_Type *base, const wdog32_config_t *config);
173 
182 void WDOG32_Deinit(WDOG_Type *base);
183 
184 /* @} */
185 
200 static inline void WDOG32_Enable(WDOG_Type *base)
201 {
202  base->CS |= WDOG_CS_EN_MASK;
203 }
204 
214 static inline void WDOG32_Disable(WDOG_Type *base)
215 {
216  base->CS &= ~WDOG_CS_EN_MASK;
217 }
218 
231 static inline void WDOG32_EnableInterrupts(WDOG_Type *base, uint32_t mask)
232 {
233  base->CS |= mask;
234 }
235 
248 static inline void WDOG32_DisableInterrupts(WDOG_Type *base, uint32_t mask)
249 {
250  base->CS &= ~mask;
251 }
252 
268 uint32_t inline WDOG32_GetStatusFlags(WDOG_Type *base)
269 {
270  return (base->CS & (WDOG_CS_EN_MASK | WDOG_CS_FLG_MASK));
271 }
272 
287 void WDOG32_ClearStatusFlags(WDOG_Type *base, uint32_t mask);
288 
299 static inline void WDOG32_SetTimeoutValue(WDOG_Type *base, uint16_t timeoutCount)
300 {
301  base->TOVAL = timeoutCount;
302 }
303 
314 static inline void WDOG32_SetWindowValue(WDOG_Type *base, uint16_t windowValue)
315 {
316  base->WIN = windowValue;
317 }
318 
330 static inline void WDOG32_Unlock(WDOG_Type *base)
331 {
332  base->CNT = WDOG_UPDATE_KEY;
333 }
334 
343 static inline void WDOG32_Refresh(WDOG_Type *base)
344 {
345  base->CNT = WDOG_REFRESH_KEY;
346 }
347 
356 static inline uint16_t WDOG32_GetCounterValue(WDOG_Type *base)
357 {
358  return base->CNT;
359 }
360 
363 #if defined(__cplusplus)
364 }
365 #endif /* __cplusplus */
366 
369 #endif /* _FSL_WDOG32_H_ */
Definition: fsl_wdog32.h:49
Describes WDOG32 configuration structure.
Definition: fsl_wdog32.h:80
void WDOG32_GetDefaultConfig(wdog32_config_t *config)
Initializes WDOG32 configure sturcture.
Definition: fsl_wdog32.c:45
Definition: fsl_wdog32.h:101
bool enableWdog32
Definition: fsl_wdog32.h:82
Definition: fsl_wdog32.h:76
wdog32_test_mode_t testMode
Definition: fsl_wdog32.h:86
Definition: fsl_wdog32.h:112
uint16_t windowValue
Definition: fsl_wdog32.h:90
static void WDOG32_SetWindowValue(WDOG_Type *base, uint16_t windowValue)
Sets the WDOG32 window value.
Definition: fsl_wdog32.h:314
bool enableWindowMode
Definition: fsl_wdog32.h:89
static uint16_t WDOG32_GetCounterValue(WDOG_Type *base)
Gets WDOG32 counter value.
Definition: fsl_wdog32.h:356
bool enableInterrupt
Definition: fsl_wdog32.h:88
bool enableUpdate
Definition: fsl_wdog32.h:87
wdog32_clock_source_t
Describes WDOG32 clock source.
Definition: fsl_wdog32.h:47
wdog32_work_mode_t workMode
Definition: fsl_wdog32.h:85
static void WDOG32_Unlock(WDOG_Type *base)
Unlocks the WDOG32 register written.
Definition: fsl_wdog32.h:330
static void WDOG32_SetTimeoutValue(WDOG_Type *base, uint16_t timeoutCount)
Set the WDOG32 timeout value.
Definition: fsl_wdog32.h:299
_wdog32_status_flags_t
WDOG32 status flags.
Definition: fsl_wdog32.h:109
Definition: fsl_wdog32.h:74
Definition: fsl_wdog32.h:52
Definition: fsl_wdog32.h:73
uint32_t WDOG32_GetStatusFlags(WDOG_Type *base)
Gets WDOG32 all status flags.
Definition: fsl_wdog32.h:268
_wdog32_interrupt_enable_t
WDOG32 interrupt configuration structure.
Definition: fsl_wdog32.h:99
Definition: fsl_wdog32.h:111
bool enableDebug
Definition: fsl_wdog32.h:67
Definition: fsl_wdog32.h:58
Definition: fsl_wdog32.h:50
wdog32_clock_prescaler_t
Describes the selection of the clock prescaler.
Definition: fsl_wdog32.h:56
wdog32_clock_source_t clockSource
Definition: fsl_wdog32.h:83
wdog32_test_mode_t
Describes WDOG32 test mode.
Definition: fsl_wdog32.h:71
Definition: fsl_wdog32.h:51
static void WDOG32_Disable(WDOG_Type *base)
Disables WDOG32 module.
Definition: fsl_wdog32.h:214
bool enableStop
Definition: fsl_wdog32.h:66
Definition: fsl_wdog32.h:59
wdog32_clock_prescaler_t prescaler
Definition: fsl_wdog32.h:84
static void WDOG32_Refresh(WDOG_Type *base)
Refreshes the WDOG32 timer.
Definition: fsl_wdog32.h:343
Defines WDOG32 work mode.
Definition: fsl_wdog32.h:63
bool enableWait
Definition: fsl_wdog32.h:65
void WDOG32_Deinit(WDOG_Type *base)
De-initializes WDOG32 module.
Definition: fsl_wdog32.c:85
Definition: fsl_wdog32.h:75
static void WDOG32_Enable(WDOG_Type *base)
Enables WDOG32 module.
Definition: fsl_wdog32.h:200
void WDOG32_Init(WDOG_Type *base, const wdog32_config_t *config)
Initializes WDOG32 module.
Definition: fsl_wdog32.c:63
uint16_t timeoutValue
Definition: fsl_wdog32.h:91
void WDOG32_ClearStatusFlags(WDOG_Type *base, uint32_t mask)
Clear WDOG32 flag.
Definition: fsl_wdog32.c:37
static void WDOG32_EnableInterrupts(WDOG_Type *base, uint32_t mask)
Enable WDOG32 interrupt.
Definition: fsl_wdog32.h:231
static void WDOG32_DisableInterrupts(WDOG_Type *base, uint32_t mask)
Disable WDOG32 interrupt.
Definition: fsl_wdog32.h:248