Kinetis SDK v.1.3 API Reference Manual  Rev. 0
Freescale Semiconductor, Inc.
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
EWM Peripheral Driver

Overview

The section describes the programming interface of the EWM Peripheral driver. The EWM driver provides an easy way to initialize and configure the EWM.

EWM Initialization

To initialize the EWM module, call the EWM_DRV_Init() function and pass in the user configuration structure. This function automatically enables the EWM module and clock. After the EWM_DRV_Init() function is called, the EWM is enabled and its counter is working. Therefore, the EWM_DRV_Refresh() function should be called before the EWM times out.

This example code shows how to initialize and configure the driver:

// Define device configuration.
const ewm_user_config_t init =
{
.ewmEnable = true, // When reset EWM_out signal is assert, to de-assert the signal EWM must be enabled //
.ewmInAssertionState = kEWMLogicOneAssert, // At reset EWM_in is assert in logic zero, so EWM_in signal assertion should be set in logic one, otherwise,
EWM_out will be assert when servicing EWM counter //
.ewmInputEnable = true, // Enable the EWM_in signal, so EWM can monitor external circuit //
.ewmIntEnable = true, // Enable EWM interrupt //
.ewmCmpLowValue = 0x00, // The compare low register configures the minimum period to service the EWM counter //
.ewmCmpHighValue = 0xfe, // 0xfe is the maximum value for compare high register, because interrupt occurs when counter value is greater than compare high register value //
};

Initialize EWM. EWM_DRV_Init(instance, &init);

EWM Refresh

After the EWM is enabled, the EWM_DRV_Refresh() function should be called periodically to prevent the EWM from timing out. Otherwise, EWM_out is asserted and an EWM interrupt occurs. When EWM_in is asserted, servicing EWM causes the EWM_out signal to be asserted.

Variables

EWM_Type *const g_ewmBase []
 Table of base addresses for EWM instances. More...
 
const IRQn_Type g_ewmIrqId [EWM_INSTANCE_COUNT]
 Table to save EWM IRQ enumeration numbers defined in the CMSIS header file. More...
 

EWM Driver

ewm_status_t EWM_DRV_Init (uint32_t instance, const ewm_config_t *ConfigPtr)
 Initializes the EWM. More...
 
void EWM_DRV_Deinit (uint32_t instance)
 Closes the clock for EWM. More...
 
void EWM_DRV_Refresh (uint32_t instance)
 Refreshes the EWM. More...
 
bool EWM_DRV_IsRunning (uint32_t instance)
 Gets the EWM running status. More...
 
void EWM_DRV_SetIntCmd (uint32_t instance, bool enable)
 Enables/disables the EWM interrupt. More...
 

Function Documentation

ewm_status_t EWM_DRV_Init ( uint32_t  instance,
const ewm_config_t ConfigPtr 
)

This function initializes the EWM. When called, the EWM runs according to the configuration.

Parameters
instanceEWM instance ID
ConfigPtrEWM user configure data structure, see #EWM_user_config_t
Returns
Execution status.
void EWM_DRV_Deinit ( uint32_t  instance)

This function sets the run time array to zero and closes the clock.

Parameters
instanceEWM instance ID
void EWM_DRV_Refresh ( uint32_t  instance)

This function feeds the EWM. It sets the EWM timer count to zero and should be called before the EWM timer times out.

Parameters
instanceEWM instance ID
bool EWM_DRV_IsRunning ( uint32_t  instance)

This function gets the EWM running status.

Parameters
instanceEWM instance ID
Returns
EWM running status. False means not running. True means running
void EWM_DRV_SetIntCmd ( uint32_t  instance,
bool  enable 
)
Parameters
instanceEWM instance ID.
enableEWM interrupt enable/disable.

Variable Documentation

EWM_Type* const g_ewmBase[]
const IRQn_Type g_ewmIrqId[EWM_INSTANCE_COUNT]