fsl_wdog32.h
/*
* Copyright (c) 2015, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _FSL_WDOG32_H_
#define _FSL_WDOG32_H_
#include "fsl_common.h"
/*******************************************************************************
* Definitions
*******************************************************************************/
#define FSL_WDOG32_DRIVER_VERSION (MAKE_VERSION(2, 0, 0))
typedef enum _wdog32_clock_source
{
kWDOG32_ClockSource0 = 0U,
kWDOG32_ClockSource1 = 1U,
kWDOG32_ClockSource2 = 2U,
kWDOG32_ClockSource3 = 3U,
} wdog32_clock_source_t;
typedef enum _wdog32_clock_prescaler
{
kWDOG32_ClockPrescalerDivide1 = 0x0U,
kWDOG32_ClockPrescalerDivide256 = 0x1U,
} wdog32_clock_prescaler_t;
typedef struct _wdog32_work_mode
{
bool enableWait;
bool enableStop;
bool enableDebug;
} wdog32_work_mode_t;
typedef enum _wdog32_test_mode
{
kWDOG32_TestModeDisabled = 0U,
kWDOG32_UserModeEnabled = 1U,
kWDOG32_LowByteTest = 2U,
kWDOG32_HighByteTest = 3U,
} wdog32_test_mode_t;
typedef struct _wdog32_config
{
bool enableWdog32;
wdog32_clock_source_t clockSource;
wdog32_clock_prescaler_t prescaler;
wdog32_work_mode_t workMode;
wdog32_test_mode_t testMode;
bool enableUpdate;
bool enableInterrupt;
bool enableWindowMode;
uint16_t windowValue;
uint16_t timeoutValue;
} wdog32_config_t;
enum _wdog32_interrupt_enable_t
{
kWDOG32_InterruptEnable = WDOG_CS_INT_MASK,
};
enum _wdog32_status_flags_t
{
kWDOG32_RunningFlag = WDOG_CS_EN_MASK,
kWDOG32_InterruptFlag = WDOG_CS_FLG_MASK,
};
/*******************************************************************************
* API
*******************************************************************************/
#if defined(__cplusplus)
extern "C" {
#endif /* __cplusplus */
void WDOG32_GetDefaultConfig(wdog32_config_t *config);
void WDOG32_Init(WDOG_Type *base, const wdog32_config_t *config);
void WDOG32_Deinit(WDOG_Type *base);
/* @} */
static inline void WDOG32_Enable(WDOG_Type *base)
{
base->CS |= WDOG_CS_EN_MASK;
}
static inline void WDOG32_Disable(WDOG_Type *base)
{
base->CS &= ~WDOG_CS_EN_MASK;
}
static inline void WDOG32_EnableInterrupts(WDOG_Type *base, uint32_t mask)
{
base->CS |= mask;
}
static inline void WDOG32_DisableInterrupts(WDOG_Type *base, uint32_t mask)
{
base->CS &= ~mask;
}
uint32_t inline WDOG32_GetStatusFlags(WDOG_Type *base)
{
return (base->CS & (WDOG_CS_EN_MASK | WDOG_CS_FLG_MASK));
}
void WDOG32_ClearStatusFlags(WDOG_Type *base, uint32_t mask);
static inline void WDOG32_SetTimeoutValue(WDOG_Type *base, uint16_t timeoutCount)
{
base->TOVAL = timeoutCount;
}
static inline void WDOG32_SetWindowValue(WDOG_Type *base, uint16_t windowValue)
{
base->WIN = windowValue;
}
static inline void WDOG32_Unlock(WDOG_Type *base)
{
base->CNT = WDOG_UPDATE_KEY;
}
static inline void WDOG32_Refresh(WDOG_Type *base)
{
base->CNT = WDOG_REFRESH_KEY;
}
static inline uint16_t WDOG32_GetCounterValue(WDOG_Type *base)
{
return base->CNT;
}
#if defined(__cplusplus)
}
#endif /* __cplusplus */
#endif /* _FSL_WDOG32_H_ */
kWDOG32_ClockSource0
Definition: fsl_wdog32.h:49
wdog32_config_t
Describes WDOG32 configuration structure.
Definition: fsl_wdog32.h:80
WDOG32_GetDefaultConfig
void WDOG32_GetDefaultConfig(wdog32_config_t *config)
Initializes WDOG32 configure sturcture.
Definition: fsl_wdog32.c:45
kWDOG32_InterruptEnable
Definition: fsl_wdog32.h:101
wdog32_config_t::enableWdog32
bool enableWdog32
Definition: fsl_wdog32.h:82
kWDOG32_HighByteTest
Definition: fsl_wdog32.h:76
wdog32_config_t::testMode
wdog32_test_mode_t testMode
Definition: fsl_wdog32.h:86
kWDOG32_InterruptFlag
Definition: fsl_wdog32.h:112
wdog32_config_t::windowValue
uint16_t windowValue
Definition: fsl_wdog32.h:90
WDOG32_SetWindowValue
static void WDOG32_SetWindowValue(WDOG_Type *base, uint16_t windowValue)
Sets the WDOG32 window value.
Definition: fsl_wdog32.h:314
wdog32_config_t::enableWindowMode
bool enableWindowMode
Definition: fsl_wdog32.h:89
WDOG32_GetCounterValue
static uint16_t WDOG32_GetCounterValue(WDOG_Type *base)
Gets WDOG32 counter value.
Definition: fsl_wdog32.h:356
wdog32_config_t::enableInterrupt
bool enableInterrupt
Definition: fsl_wdog32.h:88
wdog32_config_t::enableUpdate
bool enableUpdate
Definition: fsl_wdog32.h:87
wdog32_clock_source_t
wdog32_clock_source_t
Describes WDOG32 clock source.
Definition: fsl_wdog32.h:47
wdog32_config_t::workMode
wdog32_work_mode_t workMode
Definition: fsl_wdog32.h:85
WDOG32_Unlock
static void WDOG32_Unlock(WDOG_Type *base)
Unlocks the WDOG32 register written.
Definition: fsl_wdog32.h:330
WDOG32_SetTimeoutValue
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_t
WDOG32 status flags.
Definition: fsl_wdog32.h:109
kWDOG32_UserModeEnabled
Definition: fsl_wdog32.h:74
kWDOG32_ClockSource3
Definition: fsl_wdog32.h:52
kWDOG32_TestModeDisabled
Definition: fsl_wdog32.h:73
WDOG32_GetStatusFlags
uint32_t WDOG32_GetStatusFlags(WDOG_Type *base)
Gets WDOG32 all status flags.
Definition: fsl_wdog32.h:268
_wdog32_interrupt_enable_t
_wdog32_interrupt_enable_t
WDOG32 interrupt configuration structure.
Definition: fsl_wdog32.h:99
kWDOG32_RunningFlag
Definition: fsl_wdog32.h:111
wdog32_work_mode_t::enableDebug
bool enableDebug
Definition: fsl_wdog32.h:67
kWDOG32_ClockPrescalerDivide1
Definition: fsl_wdog32.h:58
kWDOG32_ClockSource1
Definition: fsl_wdog32.h:50
wdog32_clock_prescaler_t
wdog32_clock_prescaler_t
Describes the selection of the clock prescaler.
Definition: fsl_wdog32.h:56
wdog32_config_t::clockSource
wdog32_clock_source_t clockSource
Definition: fsl_wdog32.h:83
wdog32_test_mode_t
wdog32_test_mode_t
Describes WDOG32 test mode.
Definition: fsl_wdog32.h:71
kWDOG32_ClockSource2
Definition: fsl_wdog32.h:51
WDOG32_Disable
static void WDOG32_Disable(WDOG_Type *base)
Disables WDOG32 module.
Definition: fsl_wdog32.h:214
wdog32_work_mode_t::enableStop
bool enableStop
Definition: fsl_wdog32.h:66
kWDOG32_ClockPrescalerDivide256
Definition: fsl_wdog32.h:59
wdog32_config_t::prescaler
wdog32_clock_prescaler_t prescaler
Definition: fsl_wdog32.h:84
WDOG32_Refresh
static void WDOG32_Refresh(WDOG_Type *base)
Refreshes the WDOG32 timer.
Definition: fsl_wdog32.h:343
wdog32_work_mode_t
Defines WDOG32 work mode.
Definition: fsl_wdog32.h:63
wdog32_work_mode_t::enableWait
bool enableWait
Definition: fsl_wdog32.h:65
WDOG32_Deinit
void WDOG32_Deinit(WDOG_Type *base)
De-initializes WDOG32 module.
Definition: fsl_wdog32.c:85
kWDOG32_LowByteTest
Definition: fsl_wdog32.h:75
WDOG32_Enable
static void WDOG32_Enable(WDOG_Type *base)
Enables WDOG32 module.
Definition: fsl_wdog32.h:200
WDOG32_Init
void WDOG32_Init(WDOG_Type *base, const wdog32_config_t *config)
Initializes WDOG32 module.
Definition: fsl_wdog32.c:63
wdog32_config_t::timeoutValue
uint16_t timeoutValue
Definition: fsl_wdog32.h:91
WDOG32_ClearStatusFlags
void WDOG32_ClearStatusFlags(WDOG_Type *base, uint32_t mask)
Clear WDOG32 flag.
Definition: fsl_wdog32.c:37
WDOG32_EnableInterrupts
static void WDOG32_EnableInterrupts(WDOG_Type *base, uint32_t mask)
Enable WDOG32 interrupt.
Definition: fsl_wdog32.h:231
WDOG32_DisableInterrupts
static void WDOG32_DisableInterrupts(WDOG_Type *base, uint32_t mask)
Disable WDOG32 interrupt.
Definition: fsl_wdog32.h:248