| Kinetis SDK v.2.0 API Reference Manual Rev. 0 Freescale Semiconductor, Inc.

- Main Page
- Related Pages
- API Reference

All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Files | Data Structures | Enumerations
EWM: External Watchdog Monitor Driver

## Overview

The KSDK provides a peripheral driver for the EWM module of Kinetis devices.

# Typical use case

ewm_config_t config;
EWM_GetDefaultConfig(&config);
config.enableInterrupt = true;
config.compareLowValue = 0U;
config.compareHighValue = 0xAAU;
NVIC_EnableIRQ(WDOG_EWM_IRQn);
EWM_Init(base, &config);

## Files
file | fsl_ewm.h

## Data Structures
struct | ewm_config_t
| Describes ewm clock source. More...

## Enumerations
enum | _ewm_interrupt_enable_t { kEWM_InterruptEnable = EWM_CTRL_INTEN_MASK }
| EWM interrupt configuration structure, default settings all disabled. More...
enum | _ewm_status_flags_t { kEWM_RunningFlag = EWM_CTRL_EWMEN_MASK }
| EWM status flags. More...

## Driver version
#define | FSL_EWM_DRIVER_VERSION (MAKE_VERSION(2, 0, 1))
| EWM driver version 2.0.1. More...

## EWM Initialization and De-initialization
void | EWM_Init (EWM_Type *base, const ewm_config_t *config)
| Initializes the EWM peripheral. More...
void | EWM_Deinit (EWM_Type *base)
| Deinitializes the EWM peripheral. More...
void | EWM_GetDefaultConfig (ewm_config_t *config)
| Initializes the EWM configuration structure. More...

## EWM functional Operation
static void | EWM_EnableInterrupts (EWM_Type *base, uint32_t mask)
| Enables the EWM interrupt. More...
static void | EWM_DisableInterrupts (EWM_Type *base, uint32_t mask)
| Disables the EWM interrupt. More...
static uint32_t | EWM_GetStatusFlags (EWM_Type *base)
| Gets EWM all status flags. More...
void | EWM_Refresh (EWM_Type *base)
| Service EWM. More...

## Data Structure Documentation

struct ewm_config_t

Data structure for EWM configuration.

This structure is used to configure the EWM.

### Data Fields
bool | enableEwm
| Enable EWM module.
bool | enableEwmInput
| Enable EWM_in input.
bool | setInputAssertLogic
| EWM_in signal assertion state.
bool | enableInterrupt
| Enable EWM interrupt.
uint8_t | compareLowValue
| Compare low register value.
uint8_t | compareHighValue
| Compare high register value.

## Macro Definition Documentation

#define FSL_EWM_DRIVER_VERSION (MAKE_VERSION(2, 0, 1))

## Enumeration Type Documentation

enum _ewm_interrupt_enable_t

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

Enumerator
kEWM_InterruptEnable | Enable EWM to generate an interrupt.

enum _ewm_status_flags_t

This structure contains the constants for the EWM status flags for use in the EWM functions.

Enumerator
kEWM_RunningFlag | Running flag, set when ewm is enabled.

## Function Documentation

void EWM_Init | ( | EWM_Type * | base,
|  | const ewm_config_t * | config
| ) |  |

This function is used to initialize the EWM. After calling, the EWM runs immediately according to the configuration. Note that except for interrupt enable control bit, other control bits and registers are write once after a CPU reset. Modifying them more than once generates a bus transfer error.

Example:

ewm_config_t config;
EWM_GetDefaultConfig(&config);
config.compareHighValue = 0xAAU;
EWM_Init(ewm_base,&config);

Parameters

  base | EWM peripheral base address
  config | The configuration of EWM

void EWM_Deinit | ( | EWM_Type * | base | ) |

This function is used to shut down the EWM.

Parameters

  base | EWM peripheral base address

void EWM_GetDefaultConfig | ( | ewm_config_t * | config | ) |

This function initializes the EWM configure structure to default values. The default values are:

ewmConfig->enableEwm = true;
ewmConfig->enableEwmInput = false;
ewmConfig->setInputAssertLogic = false;
ewmConfig->enableInterrupt = false;
ewmConfig->ewm_lpo_clock_source_t = kEWM_LpoClockSource0;
ewmConfig->prescaler = 0;
ewmConfig->compareLowValue = 0;
ewmConfig->compareHighValue = 0xFEU;

Parameters

  config | Pointer to EWM configuration structure.

See Also
  ewm_config_t

static void EWM_EnableInterrupts | ( | EWM_Type * | base,
|  | uint32_t | mask
| ) |  |
| inline static

This function enables the EWM interrupt.

Parameters

  base | EWM peripheral base address
  mask | The interrupts to enable The parameter can be combination of the following source if defined: kEWM_InterruptEnable

static void EWM_DisableInterrupts | ( | EWM_Type * | base,
|  | uint32_t | mask
| ) |  |
| inline static

This function enables the EWM interrupt.

Parameters

  base | EWM peripheral base address
  mask | The interrupts to disable The parameter can be combination of the following source if defined: kEWM_InterruptEnable

static uint32_t EWM_GetStatusFlags | ( | EWM_Type * | base | ) |
| inline static

This function gets all status flags.

Example for getting Running Flag:

uint32_t status;
status = EWM_GetStatusFlags(ewm_base) & kEWM_RunningFlag;

Parameters

  base | EWM peripheral base address

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

See Also
  _ewm_status_flags_t
  - true: related status flag has been set.
  - false: related status flag is not set.

void EWM_Refresh | ( | EWM_Type * | base | ) |

This function reset EWM counter to zero.

Parameters

  base | EWM peripheral base address