This module contains APIs to program and use the ECAP module.
Files | |
file | ecap/v0/ecap.h |
This file contains the function prototypes for the device abstraction layer for ECAP. It also contains some related macro definitions and some files to be included. | |
Functions | |
void | ECAP_captureLoadingEnable (uint32_t baseAddr) |
This function enables capture loading. More... | |
void | ECAP_captureLoadingDisable (uint32_t baseAddr) |
This function disables capture loading. More... | |
void | ECAP_prescaleConfig (uint32_t baseAddr, uint32_t prescale) |
This function configures prescale value. More... | |
void | ECAP_operatingModeSelect (uint32_t baseAddr, uint32_t modeSelect) |
This function configures ecapture module to operate in capture mode or in APWM mode. More... | |
uint32_t | ECAP_timeStampRead (uint32_t baseAddr, uint32_t capEvtFlag) |
This function returns time-stamp for a given capture event. More... | |
void | ECAP_counterConfig (uint32_t baseAddr, uint32_t countVal) |
This function configures the counter register which is used as Capture Time base. More... | |
void | ECAP_captureEvtPolarityConfig (uint32_t baseAddr, uint32_t capEvt1pol, uint32_t capEvt2pol, uint32_t capEvt3pol, uint32_t capEvt4pol) |
This function configures Capture Event polarity. More... | |
void | ECAP_captureEvtCntrRstConfig (uint32_t baseAddr, uint32_t counterRst1, uint32_t counterRst2, uint32_t counterRst3, uint32_t counterRst4) |
This function enables reset of the counters upon Capture Events. More... | |
void | ECAP_continuousModeConfig (uint32_t baseAddr) |
This function configures ECAP to Continuous mode. More... | |
void | ECAP_oneShotModeConfig (uint32_t baseAddr, uint32_t stopVal) |
This function configures ECAP to One-shot mode and also stop value for this mode. More... | |
void | ECAP_oneShotReArm (uint32_t baseAddr) |
This function configures ECAP to One-Short Re-arming. More... | |
void | ECAP_APWM_polarityConfig (uint32_t baseAddr, uint32_t flag) |
This function configures output polarity for APWM output. More... | |
void | ECAP_counterControl (uint32_t baseAddr, uint32_t flag) |
This function configures counter to stop or free running based on its input argument flag. More... | |
void | ECAP_syncInOutSelect (uint32_t baseAddr, uint32_t syncIn, uint32_t syncOut) |
This function configures Sync-In and Sync-Out. More... | |
void | ECAP_APWM_captureConfig (uint32_t baseAddr, uint32_t compareVal, uint32_t periodVal) |
When ECAP module is configured in APWM mode capture 1 and capture 2 registers are used as period and compare register.This function configures compare and period values to this register. More... | |
void | ECAP_APWM_shadowCaptureConfig (uint32_t baseAddr, uint32_t compareVal, uint32_t periodVal) |
This function configures the Shadow register. More... | |
void | ECAP_counterPhaseValConfig (uint32_t baseAddr, uint32_t cntPhaseVal) |
This function configures the counter phase value. More... | |
void | ECAP_globalIntrClear (uint32_t baseAddr) |
This function clears global interrupt and enables the generation of interrupts if any of the event interrupt are enabled and corresponding event interrupt flag is set. More... | |
void | ECAP_intrEnable (uint32_t baseAddr, uint32_t flag) |
This function enables the specified interrupts. More... | |
void | ECAP_intrDisable (uint32_t baseAddr, uint32_t flag) |
This function disables the specified interrupts. More... | |
uint32_t | ECAP_getIntrStatus (uint32_t baseAddr, uint32_t flag) |
This function returns the status specified interrupts. More... | |
void | ECAP_intrStatusClear (uint32_t baseAddr, uint32_t flag) |
This function clears of the status specified interrupts. More... | |
uint32_t | ECAP_peripheralIdGet (uint32_t baseAddr) |
This function returns the peripheral ID. More... | |
ECAP Operating Mode | |
#define | ECAP_CAPTURE_MODE (0U) |
Capture Mode. More... | |
#define | ECAP_APWM_MODE (1U) |
Auxiliary PWM Mode. More... | |
ECAP time stamp capture on event | |
#define | ECAP_CAPTURE_EVENT_1 ((uint32_t)0x08U) |
Time stamp capture on event 1. More... | |
#define | ECAP_CAPTURE_EVENT_2 ((uint32_t)0x0cU) |
Time stamp capture on event 2. More... | |
#define | ECAP_CAPTURE_EVENT_3 ((uint32_t)0x10U) |
Time stamp capture on event 3. More... | |
#define | ECAP_CAPTURE_EVENT_4 ((uint32_t)0x14U) |
Time stamp capture on event 4. More... | |
ECAP stop capture on event | |
#define | ECAP_CAPTURE_EVENT1_STOP ((uint32_t)0x00U) |
Stop capture after event 1. More... | |
#define | ECAP_CAPTURE_EVENT2_STOP ((uint32_t)0x01U) |
Stop capture after event 2. More... | |
#define | ECAP_CAPTURE_EVENT3_STOP ((uint32_t)0x02U) |
Stop capture after event 3. More... | |
#define | ECAP_CAPTURE_EVENT4_STOP ((uint32_t)0x03U) |
Stop capture after event 4. More... | |
ECAP APWM Output Polarity | |
#define | ECAP_APWM_ACTIVE_HIGH (0U) |
Output Polarity HIGH. More... | |
#define | ECAP_APWM_ACTIVE_LOW (1U) |
Output Polarity LOW. More... | |
ECAP Counter Mode | |
#define | ECAP_COUNTER_STOP (0U) |
Counter Mode Stop. More... | |
#define | ECAP_COUNTER_FREE_RUNNING (1U) |
Counter Mode Free Running. More... | |
ECAP Counter SyncIn Mode | |
#define | ECAP_SYNC_IN_DISABLE ((uint32_t)0U) |
Disable SyncIn option. More... | |
#define | ECAP_ENABLE_COUNTER ((uint32_t)1U) |
Enable Counter to be loaded from the ECAP_CNTPHS register upon SYNCI signal. More... | |
ECAP Counter SyncOut Mode | |
#define | ECAP_SYNC_IN ((uint32_t)0x0U) |
Select SyncIn event to be the SyncOut signal. More... | |
#define | ECAP_PRD_EQ ((uint32_t)0x1U) |
Select PRD event to be the SyncOut signal. More... | |
#define | ECAP_SYNC_OUT_DISABLE ((uint32_t)0x2U) |
Disable SyncOut Signal. More... | |
ECAP Interrupt Sources | |
#define | ECAP_CEVT1_INT (ECAP_ECEINT_CEVT1) |
Capture Event 1 Interrupt Enable. More... | |
#define | ECAP_CEVT2_INT (ECAP_ECEINT_CEVT2) |
Capture Event 2 Interrupt Enable. More... | |
#define | ECAP_CEVT3_INT (ECAP_ECEINT_CEVT3) |
Capture Event 3 Interrupt Enable. More... | |
#define | ECAP_CEVT4_INT (ECAP_ECEINT_CEVT4) |
Capture Event 4 Interrupt Enable. More... | |
#define | ECAP_CNTOVF_INT (ECAP_ECEINT_CTROVF) |
Counter Overflow Interrupt Enable. More... | |
#define | ECAP_PRDEQ_INT (ECAP_ECEINT_CTR_PRD) |
Period Equal Interrupt Enable. More... | |
#define | ECAP_CMPEQ_INT (ECAP_ECEINT_CTR_CMP) |
Compare Equal Interrupt Enable. More... | |
ECAP Global Interrupt Source | |
#define | ECAP_GLOBAL_INT (ECAP_ECFLG_INT) |
Global Interrupt Source Clear Flag. More... | |
ECAP Capture Event Polarity | |
#define | ECAP_CAPTURE_EVENT_RISING (0U) |
Capture Event Rising Edge. More... | |
#define | ECAP_CAPTURE_EVENT_FALLING (1U) |
Capture Event Falling Edge. More... | |
ECAP Counter Reset On Capture Event | |
#define | ECAP_CAPTURE_EVENT_RESET_COUNTER_NO_RESET (0U) |
No counter reset upon Capture Event. More... | |
#define | ECAP_CAPTURE_EVENT_RESET_COUNTER_RESET (1U) |
Counter reset upon Capture Event. More... | |
#define ECAP_CAPTURE_MODE (0U) |
Capture Mode.
#define ECAP_APWM_MODE (1U) |
Auxiliary PWM Mode.
#define ECAP_CAPTURE_EVENT_1 ((uint32_t)0x08U) |
Time stamp capture on event 1.
#define ECAP_CAPTURE_EVENT_2 ((uint32_t)0x0cU) |
Time stamp capture on event 2.
#define ECAP_CAPTURE_EVENT_3 ((uint32_t)0x10U) |
Time stamp capture on event 3.
#define ECAP_CAPTURE_EVENT_4 ((uint32_t)0x14U) |
Time stamp capture on event 4.
#define ECAP_CAPTURE_EVENT1_STOP ((uint32_t)0x00U) |
Stop capture after event 1.
#define ECAP_CAPTURE_EVENT2_STOP ((uint32_t)0x01U) |
Stop capture after event 2.
#define ECAP_CAPTURE_EVENT3_STOP ((uint32_t)0x02U) |
Stop capture after event 3.
#define ECAP_CAPTURE_EVENT4_STOP ((uint32_t)0x03U) |
Stop capture after event 4.
#define ECAP_APWM_ACTIVE_HIGH (0U) |
Output Polarity HIGH.
#define ECAP_APWM_ACTIVE_LOW (1U) |
Output Polarity LOW.
#define ECAP_COUNTER_STOP (0U) |
Counter Mode Stop.
#define ECAP_COUNTER_FREE_RUNNING (1U) |
Counter Mode Free Running.
#define ECAP_SYNC_IN_DISABLE ((uint32_t)0U) |
Disable SyncIn option.
#define ECAP_ENABLE_COUNTER ((uint32_t)1U) |
Enable Counter to be loaded from the ECAP_CNTPHS register upon SYNCI signal.
#define ECAP_SYNC_IN ((uint32_t)0x0U) |
Select SyncIn event to be the SyncOut signal.
#define ECAP_PRD_EQ ((uint32_t)0x1U) |
Select PRD event to be the SyncOut signal.
#define ECAP_SYNC_OUT_DISABLE ((uint32_t)0x2U) |
Disable SyncOut Signal.
#define ECAP_CEVT1_INT (ECAP_ECEINT_CEVT1) |
Capture Event 1 Interrupt Enable.
#define ECAP_CEVT2_INT (ECAP_ECEINT_CEVT2) |
Capture Event 2 Interrupt Enable.
#define ECAP_CEVT3_INT (ECAP_ECEINT_CEVT3) |
Capture Event 3 Interrupt Enable.
#define ECAP_CEVT4_INT (ECAP_ECEINT_CEVT4) |
Capture Event 4 Interrupt Enable.
#define ECAP_CNTOVF_INT (ECAP_ECEINT_CTROVF) |
Counter Overflow Interrupt Enable.
#define ECAP_PRDEQ_INT (ECAP_ECEINT_CTR_PRD) |
Period Equal Interrupt Enable.
#define ECAP_CMPEQ_INT (ECAP_ECEINT_CTR_CMP) |
Compare Equal Interrupt Enable.
#define ECAP_GLOBAL_INT (ECAP_ECFLG_INT) |
Global Interrupt Source Clear Flag.
#define ECAP_CAPTURE_EVENT_RISING (0U) |
Capture Event Rising Edge.
#define ECAP_CAPTURE_EVENT_FALLING (1U) |
Capture Event Falling Edge.
#define ECAP_CAPTURE_EVENT_RESET_COUNTER_NO_RESET (0U) |
No counter reset upon Capture Event.
#define ECAP_CAPTURE_EVENT_RESET_COUNTER_RESET (1U) |
Counter reset upon Capture Event.
void ECAP_captureLoadingEnable | ( | uint32_t | baseAddr | ) |
This function enables capture loading.
baseAddr | It is the Memory address of the ECAP instance used. |
void ECAP_captureLoadingDisable | ( | uint32_t | baseAddr | ) |
This function disables capture loading.
baseAddr | It is the Memory address of the ECAP instance used. |
void ECAP_prescaleConfig | ( | uint32_t | baseAddr, |
uint32_t | prescale | ||
) |
This function configures prescale value.
baseAddr | It is the Memory address of the ECAP instance used. |
prescale | It is the value which is used to prescale the incoming input. |
Prescale can take any integer value between 0 to 31
void ECAP_operatingModeSelect | ( | uint32_t | baseAddr, |
uint32_t | modeSelect | ||
) |
This function configures ecapture module to operate in capture mode or in APWM mode.
baseAddr | It is the Memory address of the ECAP instance used. |
modeSelect | It is the value which determines whether ecapture module to operate in capture mode or in APWM mode. modeSelect can take one of the following macros. |
uint32_t ECAP_timeStampRead | ( | uint32_t | baseAddr, |
uint32_t | capEvtFlag | ||
) |
This function returns time-stamp for a given capture event.
baseAddr | It is the Memory address of the ECAP instance used. |
capEvtFlag | It is the value which determines for which capture event time-stam has to returned. |
capEvtFlag can take one of the following macros.
void ECAP_counterConfig | ( | uint32_t | baseAddr, |
uint32_t | countVal | ||
) |
This function configures the counter register which is used as Capture Time base.
baseAddr | It is the Memory address of the ECAP instance used. |
countVal | It is counter value to be configured. |
void ECAP_captureEvtPolarityConfig | ( | uint32_t | baseAddr, |
uint32_t | capEvt1pol, | ||
uint32_t | capEvt2pol, | ||
uint32_t | capEvt3pol, | ||
uint32_t | capEvt4pol | ||
) |
This function configures Capture Event polarity.
baseAddr | It is the Memory address of the ECAP instance used. |
capEvt1pol | It determines whether Capture Event1 has to be generated on rising edge or falling edge of pulse. |
capEvt2pol | It determines whether Capture Event2 has to be generated on rising edge or falling edge of pulse. |
capEvt3pol | It determines whether Capture Event3 has to be generated on rising edge or falling edge of pulse. |
capEvt4pol | It determines whether Capture Event4 has to be generated on rising edge or falling edge of pulse. |
capEvtpol variables can take one of the following macros.
void ECAP_captureEvtCntrRstConfig | ( | uint32_t | baseAddr, |
uint32_t | counterRst1, | ||
uint32_t | counterRst2, | ||
uint32_t | counterRst3, | ||
uint32_t | counterRst4 | ||
) |
This function enables reset of the counters upon Capture Events.
baseAddr | It is the Memory address of the ECAP instance used. |
counterRst1 | It determines whether counter has to be reset upon Capture Event1. |
counterRst2 | It determines whether counter has to be reset upon Capture Event2. |
counterRst3 | It determines whether counter has to be reset upon Capture Event3. |
counterRst4 | It determines whether counter has to be reset upon Capture Event4. |
counterRst variables can take one of the following macros.
void ECAP_continuousModeConfig | ( | uint32_t | baseAddr | ) |
This function configures ECAP to Continuous mode.
This API is valid only if ECAP is configured to Capture Mode.It has no significance when ECAP is configured in APWM mode.
baseAddr | It is the Memory address of the ECAP instance used. |
void ECAP_oneShotModeConfig | ( | uint32_t | baseAddr, |
uint32_t | stopVal | ||
) |
This function configures ECAP to One-shot mode and also stop value for this mode.
This API is valid only if ECAP is configured to Capture Mode.It has no significance when ECAP is configured in APWM mode.
baseAddr | It is the Memory address of the ECAP instance used. |
stopVal | It is the number of captures allowed to occur before Capture register(1-4) are frozen. stopVal can take one of the following macros. |
void ECAP_oneShotReArm | ( | uint32_t | baseAddr | ) |
This function configures ECAP to One-Short Re-arming.
When this API is invoked following things happen.
baseAddr | It is the Memory address of the ECAP instance used. |
void ECAP_APWM_polarityConfig | ( | uint32_t | baseAddr, |
uint32_t | flag | ||
) |
This function configures output polarity for APWM output.
baseAddr | It is the Memory address of the ECAP instance used. |
flag | It is the value which determines the output polarity for APWM output. flag can take one of the following macros. |
void ECAP_counterControl | ( | uint32_t | baseAddr, |
uint32_t | flag | ||
) |
This function configures counter to stop or free running based on its input argument flag.
baseAddr | It is the Memory address of the ECAP instance used. |
flag | It is the value which determine counter to be configured to stop or free running. flag can take one of the following macros. |
void ECAP_syncInOutSelect | ( | uint32_t | baseAddr, |
uint32_t | syncIn, | ||
uint32_t | syncOut | ||
) |
This function configures Sync-In and Sync-Out.
baseAddr | It is the Memory address of the ECAP instance used. |
syncIn | It is the value which determines whether to disable syncIn or to enable counter to be loaded from CNTPHS register upon a SYNCI signal. syncIn can take one of the following macros. |
syncOut | It is the value which select type of syncOut signal (i.e select syncIn event to be the Sync-Out signal, select PRD_eq event to be Sync-Out signal). syncOut can take one of the following macros. |
void ECAP_APWM_captureConfig | ( | uint32_t | baseAddr, |
uint32_t | compareVal, | ||
uint32_t | periodVal | ||
) |
When ECAP module is configured in APWM mode capture 1 and capture 2 registers are used as period and compare register.This function configures compare and period values to this register.
baseAddr | It is the Memory address of the ECAP instance used. |
compareVal | It is the Compare value to be configured. |
periodVal | It is the Period value to be configured. |
void ECAP_APWM_shadowCaptureConfig | ( | uint32_t | baseAddr, |
uint32_t | compareVal, | ||
uint32_t | periodVal | ||
) |
This function configures the Shadow register.
baseAddr | It is the Memory address of the ECAP instance used. |
compareVal | It is the Compare value to be configured. |
periodVal | It is the Period value to be configured. |
void ECAP_counterPhaseValConfig | ( | uint32_t | baseAddr, |
uint32_t | cntPhaseVal | ||
) |
This function configures the counter phase value.
baseAddr | It is the Memory address of the ECAP instance used. |
cntPhaseVal | It is the counter phase value to be programmed for phase lag/lead. |
void ECAP_globalIntrClear | ( | uint32_t | baseAddr | ) |
This function clears global interrupt and enables the generation of interrupts if any of the event interrupt are enabled and corresponding event interrupt flag is set.
baseAddr | It is the Memory address of the ECAP instance used. |
void ECAP_intrEnable | ( | uint32_t | baseAddr, |
uint32_t | flag | ||
) |
This function enables the specified interrupts.
baseAddr | It is the Memory address of the ECAP instance used. |
flag | It is the value which specifies the interrupts to be enabled. flag can take one of the following macros. |
void ECAP_intrDisable | ( | uint32_t | baseAddr, |
uint32_t | flag | ||
) |
This function disables the specified interrupts.
baseAddr | It is the Memory address of the ECAP instance used. |
flag | It is the value which specifies the interrupts to be disabled. flag can take one of the following macros. |
uint32_t ECAP_getIntrStatus | ( | uint32_t | baseAddr, |
uint32_t | flag | ||
) |
This function returns the status specified interrupts.
baseAddr | It is the Memory address of the ECAP instance used. |
flag | It is the value which specifies the status of interrupts to be returned. flag can take one of the following macros. |
void ECAP_intrStatusClear | ( | uint32_t | baseAddr, |
uint32_t | flag | ||
) |
This function clears of the status specified interrupts.
baseAddr | It is the Memory address of the ECAP instance used. |
flag | It is the value which specifies the status of interrupts to be cleared. flag can take one of the following macros. |
uint32_t ECAP_peripheralIdGet | ( | uint32_t | baseAddr | ) |
This function returns the peripheral ID.
baseAddr | It is the Memory address of the ECAP instance used. |