Callisto4Bootloader: drivers/fsl_wdog.h Source File

Callisto4Bootloader

fsl_wdog.h
Go to the documentation of this file.
1 /*
2 * Copyright (c) 2016, Freescale Semiconductor, Inc.
3 * Copyright 2016-2019 NXP
4 * All rights reserved.
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8 #ifndef _FSL_WDOG_H_
9 #define _FSL_WDOG_H_
10
11 #include "fsl_common.h"
12
18 /*******************************************************************************
19 * Definitions
20 *******************************************************************************/
24 #define FSL_WDOG_DRIVER_VERSION (MAKE_VERSION(2, 1, 1))
25
28 #define WDOG_REFRESH_KEY (0xAAAA5555U)
29
32 typedef struct _wdog_work_mode
33 {
34 bool enableWait;
35 bool enableStop;
36 bool enableDebug;
37 } wdog_work_mode_t;
38
40 typedef struct _wdog_config
41 {
42 bool enableWdog;
43 wdog_work_mode_t workMode;
44 bool enableInterrupt;
45 uint16_t timeoutValue;
46 uint16_t interruptTimeValue;
47 bool softwareResetExtension;
48 bool enablePowerDown;
49 bool enableTimeOutAssert;
50 } wdog_config_t;
51
57 enum _wdog_interrupt_enable
58 {
59 kWDOG_InterruptEnable = WDOG_WICR_WIE_MASK
60 };
61
67 enum _wdog_status_flags
68 {
69 kWDOG_RunningFlag = WDOG_WCR_WDE_MASK,
70 kWDOG_PowerOnResetFlag = WDOG_WRSR_POR_MASK,
71 kWDOG_TimeoutResetFlag = WDOG_WRSR_TOUT_MASK,
72 kWDOG_SoftwareResetFlag = WDOG_WRSR_SFTW_MASK,
73 kWDOG_InterruptFlag = WDOG_WICR_WTIS_MASK
74 };
75
76 /*******************************************************************************
77 * API
78 *******************************************************************************/
79
80 #if defined(__cplusplus)
81 extern "C" {
82 #endif /* __cplusplus */
83
109 void WDOG_GetDefaultConfig(wdog_config_t *config);
110
128 void WDOG_Init(WDOG_Type *base, const wdog_config_t *config);
129
138 void WDOG_Deinit(WDOG_Type *base);
139
148 static inline void WDOG_Enable(WDOG_Type *base)
149 {
150 base->WCR |= WDOG_WCR_WDE_MASK;
151 }
152
161 static inline void WDOG_Disable(WDOG_Type *base)
162 {
163 base->WCR &= ~(uint16_t)WDOG_WCR_WDE_MASK;
164 }
165
175 static inline void WDOG_TriggerSystemSoftwareReset(WDOG_Type *base)
176 {
177 base->WCR &= ~(uint16_t)WDOG_WCR_SRS_MASK;
178 }
179
191 static inline void WDOG_TriggerSoftwareSignal(WDOG_Type *base)
192 {
193 base->WCR &= ~(uint16_t)WDOG_WCR_WDA_MASK;
194 }
195
207 static inline void WDOG_EnableInterrupts(WDOG_Type *base, uint16_t mask)
208 {
209 base->WICR |= mask;
210 }
211
226 uint16_t WDOG_GetStatusFlags(WDOG_Type *base);
227
242 void WDOG_ClearInterruptStatus(WDOG_Type *base, uint16_t mask);
243
255 static inline void WDOG_SetTimeoutValue(WDOG_Type *base, uint16_t timeoutCount)
256 {
257 base->WCR = (base->WCR & (uint16_t)~WDOG_WCR_WT_MASK) | WDOG_WCR_WT(timeoutCount);
258 }
259
270 static inline void WDOG_SetInterrputTimeoutValue(WDOG_Type *base, uint16_t timeoutCount)
271 {
272 base->WICR = (base->WICR & ~(uint16_t)WDOG_WICR_WICT_MASK) | WDOG_WICR_WICT(timeoutCount);
273 }
274
283 static inline void WDOG_DisablePowerDownEnable(WDOG_Type *base)
284 {
285 base->WMCR &= ~(uint16_t)WDOG_WMCR_PDE_MASK;
286 }
287
296 void WDOG_Refresh(WDOG_Type *base);
299 #if defined(__cplusplus)
300 }
301 #endif /* __cplusplus */
302
305 #endif /* _FSL_WDOG_H_ */
WDOG_Type::WCR
__IO uint16_t WCR
Definition: MIMXRT1062.h:46322
kWDOG_SoftwareResetFlag
Definition: fsl_wdog.h:71
WDOG_TriggerSystemSoftwareReset
static void WDOG_TriggerSystemSoftwareReset(WDOG_Type *base)
Trigger the system software reset.
Definition: fsl_wdog.h:173
_wdog_config::enableTimeOutAssert
bool enableTimeOutAssert
Definition: fsl_wdog.h:48
WDOG_WCR_SRS_MASK
#define WDOG_WCR_SRS_MASK
Definition: MIMXRT1062.h:46368
WDOG_GetStatusFlags
uint16_t WDOG_GetStatusFlags(WDOG_Type *base)
Gets the WDOG all reset status flags.
Definition: bl_api.c:298
WDOG_WICR_WICT
#define WDOG_WICR_WICT(x)
Definition: MIMXRT1062.h:46454
_wdog_config::workMode
wdog_work_mode_t workMode
Definition: fsl_wdog.h:42
wdog_work_mode_t
struct _wdog_work_mode wdog_work_mode_t
Defines WDOG work mode.
WDOG_Type::WMCR
__IO uint16_t WMCR
Definition: MIMXRT1062.h:46326
_wdog_work_mode
Defines WDOG work mode.
Definition: fsl_wdog.h:31
WDOG_EnableInterrupts
static void WDOG_EnableInterrupts(WDOG_Type *base, uint16_t mask)
Enables the WDOG interrupt.
Definition: fsl_wdog.h:205
WDOG_WCR_WDA_MASK
#define WDOG_WCR_WDA_MASK
Definition: MIMXRT1062.h:46375
_wdog_work_mode::enableStop
bool enableStop
Definition: fsl_wdog.h:34
WDOG_WCR_WDE_MASK
#define WDOG_WCR_WDE_MASK
Definition: MIMXRT1062.h:46354
WDOG_Disable
static void WDOG_Disable(WDOG_Type *base)
Disables the WDOG module.
Definition: fsl_wdog.h:159
WDOG_SetInterrputTimeoutValue
static void WDOG_SetInterrputTimeoutValue(WDOG_Type *base, uint16_t timeoutCount)
Sets the WDOG interrupt count timeout value.
Definition: fsl_wdog.h:268
WDOG_WCR_WT
#define WDOG_WCR_WT(x)
Definition: MIMXRT1062.h:46405
WDOG_WRSR_SFTW_MASK
#define WDOG_WRSR_SFTW_MASK
Definition: MIMXRT1062.h:46421
WDOG_WICR_WIE_MASK
#define WDOG_WICR_WIE_MASK
Definition: MIMXRT1062.h:46462
WDOG_WCR_WT_MASK
#define WDOG_WCR_WT_MASK
Definition: MIMXRT1062.h:46396
_wdog_config::enableInterrupt
bool enableInterrupt
Definition: fsl_wdog.h:43
kWDOG_InterruptFlag
Definition: fsl_wdog.h:72
_wdog_interrupt_enable
_wdog_interrupt_enable
WDOG interrupt configuration structure, default settings all disabled.
Definition: fsl_wdog.h:56
_wdog_config::enableWdog
bool enableWdog
Definition: fsl_wdog.h:41
WDOG_Type
Definition: MIMXRT1062.h:46321
WDOG_WICR_WICT_MASK
#define WDOG_WICR_WICT_MASK
Definition: MIMXRT1062.h:46446
wdog_config_t
struct _wdog_config wdog_config_t
Describes WDOG configuration structure.
WDOG_Enable
static void WDOG_Enable(WDOG_Type *base)
Enables the WDOG module.
Definition: fsl_wdog.h:146
WDOG_GetDefaultConfig
void WDOG_GetDefaultConfig(wdog_config_t *config)
Initializes the WDOG configuration structure.
Definition: bl_api.c:283
_wdog_config::interruptTimeValue
uint16_t interruptTimeValue
Definition: fsl_wdog.h:45
_wdog_work_mode::enableDebug
bool enableDebug
Definition: fsl_wdog.h:35
kWDOG_InterruptEnable
Definition: fsl_wdog.h:58
kWDOG_PowerOnResetFlag
Definition: fsl_wdog.h:69
_wdog_config::softwareResetExtension
bool softwareResetExtension
Definition: fsl_wdog.h:46
WDOG_DisablePowerDownEnable
static void WDOG_DisablePowerDownEnable(WDOG_Type *base)
Disable the WDOG power down enable bit.
Definition: fsl_wdog.h:281
_wdog_config::timeoutValue
uint16_t timeoutValue
Definition: fsl_wdog.h:44
WDOG_ClearInterruptStatus
void WDOG_ClearInterruptStatus(WDOG_Type *base, uint16_t mask)
Clears the WDOG flag.
Definition: bl_api.c:303
kWDOG_RunningFlag
Definition: fsl_wdog.h:68
_wdog_work_mode::enableWait
bool enableWait
Definition: fsl_wdog.h:33
_wdog_config
Describes WDOG configuration structure.
Definition: fsl_wdog.h:39
WDOG_Deinit
void WDOG_Deinit(WDOG_Type *base)
Shuts down the WDOG.
Definition: bl_api.c:293
_wdog_status_flags
_wdog_status_flags
WDOG status flags.
Definition: fsl_wdog.h:66
WDOG_Init
void WDOG_Init(WDOG_Type *base, const wdog_config_t *config)
Initializes the WDOG.
Definition: bl_api.c:288
kWDOG_TimeoutResetFlag
Definition: fsl_wdog.h:70
_wdog_config::enablePowerDown
bool enablePowerDown
Definition: fsl_wdog.h:47
WDOG_TriggerSoftwareSignal
static void WDOG_TriggerSoftwareSignal(WDOG_Type *base)
Trigger an output assertion.
Definition: fsl_wdog.h:189
WDOG_WRSR_TOUT_MASK
#define WDOG_WRSR_TOUT_MASK
Definition: MIMXRT1062.h:46428
WDOG_SetTimeoutValue
static void WDOG_SetTimeoutValue(WDOG_Type *base, uint16_t timeoutCount)
Sets the WDOG timeout value.
Definition: fsl_wdog.h:253
WDOG_Type::WICR
__IO uint16_t WICR
Definition: MIMXRT1062.h:46325
WDOG_WICR_WTIS_MASK
#define WDOG_WICR_WTIS_MASK
Definition: MIMXRT1062.h:46455
WDOG_WRSR_POR_MASK
#define WDOG_WRSR_POR_MASK
Definition: MIMXRT1062.h:46435
WDOG_WMCR_PDE_MASK
#define WDOG_WMCR_PDE_MASK
Definition: MIMXRT1062.h:46473
WDOG_Refresh
void WDOG_Refresh(WDOG_Type *base)
Refreshes the WDOG timer.
Definition: bl_api.c:308