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:
const ewm_user_config_t init =
{
.ewmEnable = true,
.ewmInAssertionState = kEWMLogicOneAssert,
EWM_out will be assert when servicing EWM counter
.ewmInputEnable = true,
.ewmIntEnable = true,
.ewmCmpLowValue = 0x00,
.ewmCmpHighValue = 0xfe,
};
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.
|
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...
|
|
This function initializes the EWM. When called, the EWM runs according to the configuration.
- Parameters
-
instance | EWM instance ID |
ConfigPtr | EWM 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
-
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
-
bool EWM_DRV_IsRunning |
( |
uint32_t |
instance | ) |
|
This function gets the EWM running status.
- Parameters
-
- Returns
- EWM running status. False means not running. True means running
void EWM_DRV_SetIntCmd |
( |
uint32_t |
instance, |
|
|
bool |
enable |
|
) |
| |
- Parameters
-
instance | EWM instance ID. |
enable | EWM interrupt enable/disable. |
EWM_Type* const g_ewmBase[] |
const IRQn_Type g_ewmIrqId[EWM_INSTANCE_COUNT] |