Callisto4Bootloader: Rtwdog

Callisto4Bootloader

Data Structures | Typedefs | Enumerations
Rtwdog

## Data Structures

struct | _rtwdog_work_mode
| Defines RTWDOG work mode. More...
struct | _rtwdog_config
| Describes RTWDOG configuration structure. More...

## Typedefs

typedef enum _rtwdog_clock_source | rtwdog_clock_source_t
| Describes RTWDOG clock source. More...
typedef enum _rtwdog_clock_prescaler | rtwdog_clock_prescaler_t
| Describes the selection of the clock prescaler. More...
typedef struct _rtwdog_work_mode | rtwdog_work_mode_t
| Defines RTWDOG work mode. More...
typedef enum _rtwdog_test_mode | rtwdog_test_mode_t
| Describes RTWDOG test mode. More...
typedef struct _rtwdog_config | rtwdog_config_t
| Describes RTWDOG configuration structure. More...

## Enumerations

enum | _rtwdog_clock_source { kRTWDOG_ClockSource0 = 0U, kRTWDOG_ClockSource1 = 1U, kRTWDOG_ClockSource2 = 2U, kRTWDOG_ClockSource3 = 3U }
| Describes RTWDOG clock source. More...
enum | _rtwdog_clock_prescaler { kRTWDOG_ClockPrescalerDivide1 = 0x0U, kRTWDOG_ClockPrescalerDivide256 = 0x1U }
| Describes the selection of the clock prescaler. More...
enum | _rtwdog_test_mode { kRTWDOG_TestModeDisabled = 0U, kRTWDOG_UserModeEnabled = 1U, kRTWDOG_LowByteTest = 2U, kRTWDOG_HighByteTest = 3U }
| Describes RTWDOG test mode. More...
enum | _rtwdog_interrupt_enable_t { kRTWDOG_InterruptEnable = RTWDOG_CS_INT_MASK }
| RTWDOG interrupt configuration structure. More...
enum | _rtwdog_status_flags_t { kRTWDOG_RunningFlag = RTWDOG_CS_EN_MASK, kRTWDOG_InterruptFlag = RTWDOG_CS_FLG_MASK }
| RTWDOG status flags. More...

## Unlock sequence

#define | WDOG_FIRST_WORD_OF_UNLOCK (RTWDOG_UPDATE_KEY & 0xFFFFU)
#define | WDOG_SECOND_WORD_OF_UNLOCK ((RTWDOG_UPDATE_KEY >> 16U) & 0xFFFFU)

## Refresh sequence

#define | WDOG_FIRST_WORD_OF_REFRESH (RTWDOG_REFRESH_KEY & 0xFFFFU)
#define | WDOG_SECOND_WORD_OF_REFRESH ((RTWDOG_REFRESH_KEY >> 16U) & 0xFFFFU)

## Driver version

#define | FSL_RTWDOG_DRIVER_VERSION (MAKE_VERSION(2, 0, 0))
| RTWDOG driver version 2.0.0. More...

## RTWDOG Initialization and De-initialization

void | RTWDOG_GetDefaultConfig (rtwdog_config_t *config)
| Initializes the RTWDOG configuration structure. More...
void | RTWDOG_Init (RTWDOG_Type *base, const rtwdog_config_t *config)
| Initializes the RTWDOG module. More...
void | RTWDOG_Deinit (RTWDOG_Type *base)
| De-initializes the RTWDOG module. More...

## RTWDOG functional Operation

static void | RTWDOG_Enable (RTWDOG_Type *base)
| Enables the RTWDOG module. More...
static void | RTWDOG_Disable (RTWDOG_Type *base)
| Disables the RTWDOG module. More...
static void | RTWDOG_EnableInterrupts (RTWDOG_Type *base, uint32_t mask)
| Enables the RTWDOG interrupt. More...
static void | RTWDOG_DisableInterrupts (RTWDOG_Type *base, uint32_t mask)
| Disables the RTWDOG interrupt. More...
static uint32_t | RTWDOG_GetStatusFlags (RTWDOG_Type *base)
| Gets the RTWDOG all status flags. More...
void | RTWDOG_ClearStatusFlags (RTWDOG_Type *base, uint32_t mask)
| Clears the RTWDOG flag. More...
static void | RTWDOG_SetTimeoutValue (RTWDOG_Type *base, uint16_t timeoutCount)
| Sets the RTWDOG timeout value. More...
static void | RTWDOG_SetWindowValue (RTWDOG_Type *base, uint16_t windowValue)
| Sets the RTWDOG window value. More...
static void | RTWDOG_Unlock (RTWDOG_Type *base)
| Unlocks the RTWDOG register written. More...
static void | RTWDOG_Refresh (RTWDOG_Type *base)
| Refreshes the RTWDOG timer. More...
static uint16_t | RTWDOG_GetCounterValue (RTWDOG_Type *base)
| Gets the RTWDOG counter value. More...

## Detailed Description

## Macro Definition Documentation

## ◆ FSL_RTWDOG_DRIVER_VERSION

#define FSL_RTWDOG_DRIVER_VERSION (MAKE_VERSION(2, 0, 0))

RTWDOG driver version 2.0.0.

Definition at line 33 of file fsl_rtwdog.h.

## ◆ WDOG_FIRST_WORD_OF_REFRESH

#define WDOG_FIRST_WORD_OF_REFRESH (RTWDOG_REFRESH_KEY & 0xFFFFU)

First word of refresh sequence

Definition at line 27 of file fsl_rtwdog.h.

## ◆ WDOG_FIRST_WORD_OF_UNLOCK

#define WDOG_FIRST_WORD_OF_UNLOCK (RTWDOG_UPDATE_KEY & 0xFFFFU)

First word of unlock sequence

Definition at line 21 of file fsl_rtwdog.h.

## ◆ WDOG_SECOND_WORD_OF_REFRESH

#define WDOG_SECOND_WORD_OF_REFRESH ((RTWDOG_REFRESH_KEY >> 16U) & 0xFFFFU)

Second word of refresh sequence

Definition at line 28 of file fsl_rtwdog.h.

## ◆ WDOG_SECOND_WORD_OF_UNLOCK

#define WDOG_SECOND_WORD_OF_UNLOCK ((RTWDOG_UPDATE_KEY >> 16U) & 0xFFFFU)

Second word of unlock sequence

Definition at line 22 of file fsl_rtwdog.h.

## Typedef Documentation

## ◆ rtwdog_clock_prescaler_t

typedef enum _rtwdog_clock_prescaler rtwdog_clock_prescaler_t

Describes the selection of the clock prescaler.

## ◆ rtwdog_clock_source_t

typedef enum _rtwdog_clock_source rtwdog_clock_source_t

Describes RTWDOG clock source.

## ◆ rtwdog_config_t

typedef struct _rtwdog_config rtwdog_config_t

Describes RTWDOG configuration structure.

## ◆ rtwdog_test_mode_t

typedef enum _rtwdog_test_mode rtwdog_test_mode_t

Describes RTWDOG test mode.

## ◆ rtwdog_work_mode_t

typedef struct _rtwdog_work_mode rtwdog_work_mode_t

Defines RTWDOG work mode.

## Enumeration Type Documentation

## ◆ _rtwdog_clock_prescaler

enum _rtwdog_clock_prescaler

Describes the selection of the clock prescaler.

Enumerator
kRTWDOG_ClockPrescalerDivide1 | Divided by 1
kRTWDOG_ClockPrescalerDivide256 | Divided by 256

Definition at line 46 of file fsl_rtwdog.h.

## ◆ _rtwdog_clock_source

enum _rtwdog_clock_source

Describes RTWDOG clock source.

Enumerator
kRTWDOG_ClockSource0 | Clock source 0
kRTWDOG_ClockSource1 | Clock source 1
kRTWDOG_ClockSource2 | Clock source 2
kRTWDOG_ClockSource3 | Clock source 3

Definition at line 37 of file fsl_rtwdog.h.

## ◆ _rtwdog_interrupt_enable_t

enum _rtwdog_interrupt_enable_t

RTWDOG interrupt configuration structure.

This structure contains the settings for all of the RTWDOG interrupt configurations.

Enumerator
kRTWDOG_InterruptEnable | Interrupt is generated before forcing a reset

Definition at line 89 of file fsl_rtwdog.h.

## ◆ _rtwdog_status_flags_t

enum _rtwdog_status_flags_t

RTWDOG status flags.

This structure contains the RTWDOG status flags for use in the RTWDOG functions.

Enumerator
kRTWDOG_RunningFlag | Running flag, set when RTWDOG is enabled
kRTWDOG_InterruptFlag | Interrupt flag, set when interrupt occurs

Definition at line 99 of file fsl_rtwdog.h.

## ◆ _rtwdog_test_mode

enum _rtwdog_test_mode

Describes RTWDOG test mode.

Enumerator
kRTWDOG_TestModeDisabled | Test Mode disabled
kRTWDOG_UserModeEnabled | User Mode enabled
kRTWDOG_LowByteTest | Test Mode enabled, only low byte is used
kRTWDOG_HighByteTest | Test Mode enabled, only high byte is used

Definition at line 61 of file fsl_rtwdog.h.

## Function Documentation

## ◆ RTWDOG_ClearStatusFlags()

void RTWDOG_ClearStatusFlags | ( | RTWDOG_Type * | base,
|  | uint32_t | mask
| ) |  |

Clears the RTWDOG flag.

This function clears the RTWDOG status flag.

Example to clear an interrupt flag:

RTWDOG_ClearStatusFlags(wdog_base,kRTWDOG_InterruptFlag);

Parameters

  base | RTWDOG peripheral base address.

  mask

  The status flags to clear. The parameter can be any combination of the following values:
  - kRTWDOG_InterruptFlag

Definition at line 260 of file bl_api.c.

## ◆ RTWDOG_Deinit()

void RTWDOG_Deinit | ( | RTWDOG_Type * | base | ) |

De-initializes the RTWDOG module.

This function shuts down the RTWDOG. Ensure that the WDOG_CS.UPDATE is 1, which means that the register update is enabled.

Parameters

  base | RTWDOG peripheral base address.

Definition at line 275 of file bl_api.c.

References g_bootloaderTree, rtwdog_driver_interface_t::RTWDOG_Init, and bootloader_api_entry_t::rtwdogDriver.

## ◆ RTWDOG_Disable()

static void RTWDOG_Disable | ( | RTWDOG_Type * | base | ) |

inlinestatic

Disables the RTWDOG module.

This function writes a value into the WDOG_CS register to disable the RTWDOG. The WDOG_CS register is a write-once register. Ensure that the WCT window is still open and this register has not been written in this WCT while the function is called.

Parameters

  base | RTWDOG peripheral base address

Definition at line 203 of file fsl_rtwdog.h.

## ◆ RTWDOG_DisableInterrupts()

static void RTWDOG_DisableInterrupts | ( | RTWDOG_Type * | base,
|  | uint32_t | mask
| ) |  |

inlinestatic

Disables the RTWDOG interrupt.

This function writes a value into the WDOG_CS register to disable the RTWDOG interrupt. The WDOG_CS register is a write-once register. Ensure that the WCT window is still open and this register has not been written in this WCT while the function is called.

Parameters

  base | RTWDOG peripheral base address.

  mask

  The interrupts to disabled. The parameter can be a combination of the following source if defined:
  - kRTWDOG_InterruptEnable

Definition at line 237 of file fsl_rtwdog.h.

## ◆ RTWDOG_Enable()

static void RTWDOG_Enable | ( | RTWDOG_Type * | base | ) |

inlinestatic

Enables the RTWDOG module.

This function writes a value into the WDOG_CS register to enable the RTWDOG. The WDOG_CS register is a write-once register. Ensure that the WCT window is still open and this register has not been written in this WCT while the function is called.

Parameters

  base | RTWDOG peripheral base address.

Definition at line 189 of file fsl_rtwdog.h.

## ◆ RTWDOG_EnableInterrupts()

static void RTWDOG_EnableInterrupts | ( | RTWDOG_Type * | base,
|  | uint32_t | mask
| ) |  |

inlinestatic

Enables the RTWDOG interrupt.

This function writes a value into the WDOG_CS register to enable the RTWDOG interrupt. The WDOG_CS register is a write-once register. Ensure that the WCT window is still open and this register has not been written in this WCT while the function is called.

Parameters

  base | RTWDOG peripheral base address.

  mask

  The interrupts to enable. The parameter can be a combination of the following source if defined:
  - kRTWDOG_InterruptEnable

Definition at line 220 of file fsl_rtwdog.h.

## ◆ RTWDOG_GetCounterValue()

static uint16_t RTWDOG_GetCounterValue | ( | RTWDOG_Type * | base | ) |

inlinestatic

Gets the RTWDOG counter value.

This function gets the RTWDOG counter value.

Parameters

  base | RTWDOG peripheral base address.

Returns
  Current RTWDOG counter value.

Definition at line 361 of file fsl_rtwdog.h.

## ◆ RTWDOG_GetDefaultConfig()

void RTWDOG_GetDefaultConfig | ( | rtwdog_config_t * | config | ) |

Initializes the RTWDOG configuration structure.

This function initializes the RTWDOG configuration structure to default values. The default values are:

rtwdogConfig->enableRtwdog = true;
rtwdogConfig->clockSource = kRTWDOG_ClockSource1;
rtwdogConfig->prescaler = kRTWDOG_ClockPrescalerDivide1;
rtwdogConfig->workMode.enableWait = true;
rtwdogConfig->workMode.enableStop = false;
rtwdogConfig->workMode.enableDebug = false;
rtwdogConfig->testMode = kRTWDOG_TestModeDisabled;
rtwdogConfig->enableUpdate = true;
rtwdogConfig->enableInterrupt = false;
rtwdogConfig->enableWindowMode = false;
rtwdogConfig->windowValue = 0U;
rtwdogConfig->timeoutValue = 0xFFFFU;

Parameters

  config | Pointer to the RTWDOG configuration structure.

See also
  rtwdog_config_t

Definition at line 265 of file bl_api.c.

References g_bootloaderTree, rtwdog_driver_interface_t::RTWDOG_ClearStatusFlags, and bootloader_api_entry_t::rtwdogDriver.

## ◆ RTWDOG_GetStatusFlags()

static uint32_t RTWDOG_GetStatusFlags | ( | RTWDOG_Type * | base | ) |

inlinestatic

Gets the RTWDOG all status flags.

This function gets all status flags.

Example to get the running flag:

uint32_t status;
status = RTWDOG_GetStatusFlags(wdog_base) & kRTWDOG_RunningFlag;

Parameters

  base | RTWDOG peripheral base address

Returns
  State of the status flag: asserted (true) or not-asserted (false).

See also
  _rtwdog_status_flags_t
  - true: related status flag has been set.
  - false: related status flag is not set.

Definition at line 257 of file fsl_rtwdog.h.

## ◆ RTWDOG_Init()

void RTWDOG_Init | ( | RTWDOG_Type * | base,
|  | const rtwdog_config_t * | config
| ) |  |

Initializes the RTWDOG module.

This function initializes the RTWDOG. To reconfigure the RTWDOG without forcing a reset first, enableUpdate must be set to true in the configuration.

Example:

rtwdog_config_t config;
RTWDOG_GetDefaultConfig(&config);
config.timeoutValue = 0x7ffU;
config.enableUpdate = true;
RTWDOG_Init(wdog_base,&config);

Parameters

  base | RTWDOG peripheral base address.
  config | The configuration of the RTWDOG.

Definition at line 270 of file bl_api.c.

References g_bootloaderTree, rtwdog_driver_interface_t::RTWDOG_GetDefaultConfig, and bootloader_api_entry_t::rtwdogDriver.

## ◆ RTWDOG_Refresh()

static void RTWDOG_Refresh | ( | RTWDOG_Type * | base | ) |

inlinestatic

Refreshes the RTWDOG timer.

This function feeds the RTWDOG. This function should be called before the Watchdog timer is in timeout. Otherwise, a reset is asserted.

Parameters

  base | RTWDOG peripheral base address

Definition at line 340 of file fsl_rtwdog.h.

## ◆ RTWDOG_SetTimeoutValue()

static void RTWDOG_SetTimeoutValue | ( | RTWDOG_Type * | base,
|  | uint16_t | timeoutCount
| ) |  |

inlinestatic

Sets the RTWDOG timeout value.

This function writes a timeout value into the WDOG_TOVAL register. The WDOG_TOVAL register is a write-once register. Ensure that the WCT window is still open and this register has not been written in this WCT while the function is called.

Parameters

  base | RTWDOG peripheral base address
  timeoutCount | RTWDOG timeout value, count of RTWDOG clock ticks.

Definition at line 288 of file fsl_rtwdog.h.

## ◆ RTWDOG_SetWindowValue()

static void RTWDOG_SetWindowValue | ( | RTWDOG_Type * | base,
|  | uint16_t | windowValue
| ) |  |

inlinestatic

Sets the RTWDOG window value.

This function writes a window value into the WDOG_WIN register. The WDOG_WIN register is a write-once register. Ensure that the WCT window is still open and this register has not been written in this WCT while the function is called.

Parameters

  base | RTWDOG peripheral base address.
  windowValue | RTWDOG window value.

Definition at line 303 of file fsl_rtwdog.h.

## ◆ RTWDOG_Unlock()

static void RTWDOG_Unlock | ( | RTWDOG_Type * | base | ) |

inlinestatic

Unlocks the RTWDOG register written.

This function unlocks the RTWDOG register written.

Before starting the unlock sequence and following the configuration, disable the global interrupts. Otherwise, an interrupt could effectively invalidate the unlock sequence and the WCT may expire. After the configuration finishes, re-enable the global interrupts.

Parameters

  base | RTWDOG peripheral base address

Definition at line 319 of file fsl_rtwdog.h.

kRTWDOG_RunningFlag
Definition: fsl_rtwdog.h:101
kRTWDOG_InterruptFlag
Definition: fsl_rtwdog.h:102
kRTWDOG_TestModeDisabled
Definition: fsl_rtwdog.h:63
_rtwdog_config::timeoutValue
uint16_t timeoutValue
Definition: fsl_rtwdog.h:81
RTWDOG_ClearStatusFlags
void RTWDOG_ClearStatusFlags(RTWDOG_Type *base, uint32_t mask)
Clears the RTWDOG flag.
Definition: bl_api.c:260
kRTWDOG_ClockSource1
Definition: fsl_rtwdog.h:40
RTWDOG_Init
void RTWDOG_Init(RTWDOG_Type *base, const rtwdog_config_t *config)
Initializes the RTWDOG module.
Definition: bl_api.c:270
RTWDOG_GetStatusFlags
static uint32_t RTWDOG_GetStatusFlags(RTWDOG_Type *base)
Gets the RTWDOG all status flags.
Definition: fsl_rtwdog.h:257
_rtwdog_config::enableUpdate
bool enableUpdate
Definition: fsl_rtwdog.h:77
RTWDOG_GetDefaultConfig
void RTWDOG_GetDefaultConfig(rtwdog_config_t *config)
Initializes the RTWDOG configuration structure.
Definition: bl_api.c:265
_rtwdog_config
Describes RTWDOG configuration structure.
Definition: fsl_rtwdog.h:70
kRTWDOG_ClockPrescalerDivide1
Definition: fsl_rtwdog.h:48