ADuCM302x Device Drivers API Reference Manual
Release 3.1.2.0
|
General Purpose and RGB Timer Driver. More...
Modules | |
Static Configuration | |
Data Structures | |
struct | ADI_TMR_CONFIG |
struct | ADI_TMR_EVENT_CONFIG |
struct | ADI_TMR_PWM_CONFIG |
Macros | |
#define | ADI_TMR_NUM_EVENTS (16u) |
Enumerations | |
enum | ADI_TMR_RESULT { ADI_TMR_SUCCESS, ADI_TMR_BAD_DEVICE_NUM, ADI_TMR_BAD_PWM_NUM, ADI_TMR_BAD_EVENT_ID, ADI_TMR_BAD_RELOAD_CONFIGURATION, ADI_TMR_OPERATION_NOT_ALLOWED, ADI_TMR_DEVICE_BUSY, ADI_TMR_RELOAD_DISABLED, ADI_TMR_NULL_POINTER } |
enum | ADI_TMR_DEVICE { ADI_TMR_DEVICE_GP0 = 0u, ADI_TMR_DEVICE_GP1 = 1u, ADI_TMR_DEVICE_GP2 = 2u, ADI_TMR_DEVICE_NUM = 3u } |
enum | ADI_TMR_EVENT { ADI_TMR_EVENT_TIMEOUT = 0x01, ADI_TMR_EVENT_CAPTURE = 0x02 } |
enum | ADI_TMR_PRESCALER { ADI_TMR_PRESCALER_1 = 0u, ADI_TMR_PRESCALER_16 = 1u, ADI_TMR_PRESCALER_64 = 2u, ADI_TMR_PRESCALER_256 = 3u } |
enum | ADI_TMR_CLOCK_SOURCE { ADI_TMR_CLOCK_PCLK = 0u, ADI_TMR_CLOCK_HFOSC = 1u, ADI_TMR_CLOCK_LFOSC = 2u, ADI_TMR_CLOCK_LFXTAL = 3u } |
enum | ADI_TMR_PWM_OUTPUT { ADI_TMR_PWM_OUTPUT_0 = 0u, ADI_TMR_PWM_OUTPUT_1 = 1u, ADI_TMR_PWM_OUTPUT_2 = 2u, ADI_TMR_PWM_OUTPUT_NUM = 3u } |
Functions | |
ADI_TMR_RESULT | adi_tmr_Init (ADI_TMR_DEVICE const eDevice, ADI_CALLBACK const pfCallback, void *const pCBParam, bool bEnableInt) |
Initialize GP or RGB Timer. More... | |
ADI_TMR_RESULT | adi_tmr_ConfigTimer (ADI_TMR_DEVICE const eDevice, ADI_TMR_CONFIG *timerConfig) |
Configure GP or RGB Timer. More... | |
ADI_TMR_RESULT | adi_tmr_ConfigEvent (ADI_TMR_DEVICE const eDevice, ADI_TMR_EVENT_CONFIG *eventConfig) |
Setup GP or RGB Timer Event Capture. More... | |
ADI_TMR_RESULT | adi_tmr_ConfigPwm (ADI_TMR_DEVICE const eDevice, ADI_TMR_PWM_CONFIG *pwmConfig) |
Setup GP or RGB Timer Pulse Width Modulation. More... | |
ADI_TMR_RESULT | adi_tmr_Enable (ADI_TMR_DEVICE const eDevice, bool bEnable) |
Enable or Disable the GP or RGB Timer. More... | |
ADI_TMR_RESULT | adi_tmr_GetCurrentCount (ADI_TMR_DEVICE const eDevice, uint16_t *pCount) |
Get GP or RGB Timer Current Count. More... | |
ADI_TMR_RESULT | adi_tmr_GetCaptureCount (ADI_TMR_DEVICE const eDevice, uint16_t *pCount) |
Get GP or RGB Timer Captured Count. More... | |
ADI_TMR_RESULT | adi_tmr_Reload (ADI_TMR_DEVICE const eDevice) |
Reload GP or RGB Timer. More... | |
General Purpose and RGB Timer Driver.
The timer driver controls the timer period, event capture, and pulse width modulation (PWM) features of the General Purpose (GP) Timers and the RGB Timer.
#define ADI_TMR_NUM_EVENTS (16u) |
Number of events that can be captured
Definition at line 105 of file adi_tmr.c.
Referenced by adi_tmr_ConfigEvent().
enum ADI_TMR_RESULT |
Enumeration for result code returned from the timer device driver functions. The return value of all timer APIs returning ADI_TMR_RESULT should always be tested at the application level for success or failure.
Enumerator | |
---|---|
ADI_TMR_SUCCESS | Successful operation |
ADI_TMR_BAD_DEVICE_NUM | Bad device number supplied by user |
ADI_TMR_BAD_PWM_NUM | Bad PWM output number supplied by user to adi_tmr_ConfigPwm |
ADI_TMR_BAD_EVENT_ID | Bad event number supplied by user to adi_tmr_ConfigEvent |
ADI_TMR_BAD_RELOAD_CONFIGURATION | Bad timer configuration, reloading and free running are mutually exclusive options |
ADI_TMR_OPERATION_NOT_ALLOWED | Setup or enable function called while the timer is running |
ADI_TMR_DEVICE_BUSY | Timeout while waiting for busy bit to clear before writing control register |
ADI_TMR_RELOAD_DISABLED | User attempts to reload the timer when reloading has not been enabled |
ADI_TMR_NULL_POINTER | User attempts to read the current or captured count with a NULL pointer |
enum ADI_TMR_DEVICE |
enum ADI_TMR_EVENT |
enum ADI_TMR_PRESCALER |
enum ADI_TMR_CLOCK_SOURCE |
enum ADI_TMR_PWM_OUTPUT |
RGB PWM outputs, used to specify which PWM output to configure. For the GP timers only ADI_TMR_PWM_OUTPUT_0 is allowed. The RGB timer has all three outputs.
Enumerator | |
---|---|
ADI_TMR_PWM_OUTPUT_0 | PWM output 0 |
ADI_TMR_PWM_OUTPUT_1 | PWM output 1 |
ADI_TMR_PWM_OUTPUT_2 | PWM output 2 |
ADI_TMR_PWM_OUTPUT_NUM | Total number of outputs (private) |
ADI_TMR_RESULT adi_tmr_Init | ( | ADI_TMR_DEVICE const | eDevice, |
ADI_CALLBACK const | pfCallback, | ||
void *const | pCBParam, | ||
bool | bEnableInt | ||
) |
Initialize GP or RGB Timer.
Setup callback function, device interrupt, and perform static configuration (if applicable).
[in] | eDevice | : Device number |
[in] | pfCallback | : Callback function |
[in] | pCBParam | : Callback function parameter |
[in] | bEnableInt | : True to enable the device interrupt, false to disable it |
ADI_TMR_RESULT adi_tmr_ConfigTimer | ( | ADI_TMR_DEVICE const | eDevice, |
ADI_TMR_CONFIG * | timerConfig | ||
) |
Configure GP or RGB Timer.
Configure the basic hardware timer parameters.
[in] | eDevice | : Device number |
[in] | timerConfig | : Timer configuration structure, filled by user prior to function call |
ADI_TMR_RESULT adi_tmr_ConfigEvent | ( | ADI_TMR_DEVICE const | eDevice, |
ADI_TMR_EVENT_CONFIG * | eventConfig | ||
) |
Setup GP or RGB Timer Event Capture.
The timer can be configured to capture the timer value when a specific event occurs. The list of events can be found in the hardware reference manual. The callback function specified in adi_tmr_Init will be supplied ADI_TMR_EVENT_CAPTURE to indicate the event occured. The user can then read the captured value by calling adi_tmr_GetCaptureCount.
[in] | eDevice | : Device number |
[in] | eventConfig | : Event configuration structure, filled by user prior to function call |
ADI_TMR_RESULT adi_tmr_ConfigPwm | ( | ADI_TMR_DEVICE const | eDevice, |
ADI_TMR_PWM_CONFIG * | pwmConfig | ||
) |
Setup GP or RGB Timer Pulse Width Modulation.
The timer can be configured to generate a pulse width modulation output signal. The period of this signal is simply determined by the period of timer. The duty cycle will be 50% in toggle mode, or can be configured by the user for a different value using the match value. The pulse will toggle when the timer count matches the match value. The user can also specify the polarity of the signal by choosing if the signal idles low or high. GPIO muxing will be required to use the PWM output.
[in] | eDevice | : Device number |
[in] | pwmConfig | : PWM configuration structure, filled by user prior to function call |
ADI_TMR_RESULT adi_tmr_Enable | ( | ADI_TMR_DEVICE const | eDevice, |
bool | bEnable | ||
) |
Enable or Disable the GP or RGB Timer.
Start or stop the timer.
[in] | eDevice | : Device number |
[in] | bEnable | : True to enable, false to disable |
ADI_TMR_RESULT adi_tmr_GetCurrentCount | ( | ADI_TMR_DEVICE const | eDevice, |
uint16_t * | pCount | ||
) |
Get GP or RGB Timer Current Count.
Read the timer.
[in] | eDevice | : Device number |
[out] | pCount | : Pointer to the result. |
ADI_TMR_RESULT adi_tmr_GetCaptureCount | ( | ADI_TMR_DEVICE const | eDevice, |
uint16_t * | pCount | ||
) |
Get GP or RGB Timer Captured Count.
Read the captured timer value. This should be called after the callback function is called with ADI_TMR_EVENT_CAPTURE in the Event field.
[in] | eDevice | : Device number |
[out] | pCount | : Pointer to the result. |
ADI_TMR_RESULT adi_tmr_Reload | ( | ADI_TMR_DEVICE const | eDevice | ) |
Reload GP or RGB Timer.
Only relevent in peridic mode and when bReloading was set to true when configuring the timer. Calling this function will reload (i.e. reset) the timer to the LOAD value.
[in] | eDevice | : Device number |