ADuCM302x Device Drivers API Reference Manual  Release 3.1.2.0
adi_tmr.h
1 
46 #ifndef ADI_TMR_H
47 #define ADI_TMR_H
48 
49 
50 #include <stdint.h>
51 #include <stdbool.h>
52 #include <adi_processor.h>
53 #include <adi_callback.h>
54 
55 
60 /* C++ linkage */
61 #ifdef __cplusplus
62 extern "C" {
63 #endif /* __cplusplus */
64 
72 typedef enum {
92 
98 typedef enum {
105 #if defined(__ADUCM302x__)
106 
108 #elif defined(__ADUCM4x50__)
109 
110  ADI_TMR_DEVICE_RGB = 3u,
112  ADI_TMR_DEVICE_NUM = 4u,
113 #else
114 #error TMR is not ported for this processor
115 #endif
117 
123 typedef enum {
128 } ADI_TMR_EVENT;
129 
135 typedef enum {
145 
151 typedef enum {
161 
169 typedef enum {
179 
186 typedef struct {
190  bool bPeriodic;
192  ADI_TMR_PRESCALER ePrescaler;
194  ADI_TMR_CLOCK_SOURCE eClockSource;
196  uint16_t nLoad;
198  uint16_t nAsyncLoad;
204 
211 typedef struct {
213  bool bEnable;
217  uint8_t nEventID;
219 
226 typedef struct {
228  ADI_TMR_PWM_OUTPUT eOutput;
230  bool bMatch;
232  bool bIdleHigh;
234  uint16_t nMatchValue;
236 
237 /******************************************************************************
238  * PUBLIC API
239  * 1.) Eliminate functions that may be optimized out by the linker
240  * 2.) Ordered by designed function call sequence
241  *****************************************************************************/
242 
243 /* Initialize timer driver */
244 ADI_TMR_RESULT adi_tmr_Init (ADI_TMR_DEVICE const eDevice, ADI_CALLBACK const pfCallback, void * const pCBParam, bool bEnableInt);
245 
246 /* Configuration interface functions */
247 ADI_TMR_RESULT adi_tmr_ConfigTimer (ADI_TMR_DEVICE const eDevice, ADI_TMR_CONFIG* timerConfig);
248 ADI_TMR_RESULT adi_tmr_ConfigEvent (ADI_TMR_DEVICE const eDevice, ADI_TMR_EVENT_CONFIG* eventConfig);
249 ADI_TMR_RESULT adi_tmr_ConfigPwm (ADI_TMR_DEVICE const eDevice, ADI_TMR_PWM_CONFIG* pwmConfig );
250 
251 /* Timer start and stop */
252 ADI_TMR_RESULT adi_tmr_Enable (ADI_TMR_DEVICE const eDevice, bool bEnable);
253 
254 /* Read functions */
255 ADI_TMR_RESULT adi_tmr_GetCurrentCount (ADI_TMR_DEVICE const eDevice, uint16_t *pCount);
256 ADI_TMR_RESULT adi_tmr_GetCaptureCount (ADI_TMR_DEVICE const eDevice, uint16_t *pCount);
257 
258 /* Reload function */
259 ADI_TMR_RESULT adi_tmr_Reload (ADI_TMR_DEVICE const eDevice);
260 
261 
262 #ifdef __cplusplus
263 }
264 #endif
265 
266 
270 #endif /* ADI_TMR_H */
271 
ADI_TMR_PRESCALER ePrescaler
Definition: adi_tmr.h:192
ADI_TMR_PWM_OUTPUT eOutput
Definition: adi_tmr.h:228
ADI_TMR_CLOCK_SOURCE
Definition: adi_tmr.h:151
ADI_TMR_RESULT adi_tmr_Enable(ADI_TMR_DEVICE const eDevice, bool bEnable)
Enable or Disable the GP or RGB Timer.
Definition: adi_tmr.c:457
ADI_TMR_RESULT adi_tmr_GetCaptureCount(ADI_TMR_DEVICE const eDevice, uint16_t *pCount)
Get GP or RGB Timer Captured Count.
Definition: adi_tmr.c:528
bool bCountingUp
Definition: adi_tmr.h:188
ADI_TMR_RESULT
Definition: adi_tmr.h:72
bool bPeriodic
Definition: adi_tmr.h:190
uint16_t nMatchValue
Definition: adi_tmr.h:234
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.
Definition: adi_tmr.c:175
uint16_t nAsyncLoad
Definition: adi_tmr.h:198
ADI_TMR_DEVICE
Definition: adi_tmr.h:98
uint16_t nLoad
Definition: adi_tmr.h:196
ADI_TMR_CLOCK_SOURCE eClockSource
Definition: adi_tmr.h:194
ADI_TMR_RESULT adi_tmr_ConfigPwm(ADI_TMR_DEVICE const eDevice, ADI_TMR_PWM_CONFIG *pwmConfig)
Setup GP or RGB Timer Pulse Width Modulation.
Definition: adi_tmr.c:394
bool bReloading
Definition: adi_tmr.h:200
bool bSyncBypass
Definition: adi_tmr.h:202
ADI_TMR_RESULT adi_tmr_ConfigTimer(ADI_TMR_DEVICE const eDevice, ADI_TMR_CONFIG *timerConfig)
Configure GP or RGB Timer.
Definition: adi_tmr.c:241
ADI_TMR_EVENT
Definition: adi_tmr.h:123
ADI_TMR_RESULT adi_tmr_Reload(ADI_TMR_DEVICE const eDevice)
Reload GP or RGB Timer.
Definition: adi_tmr.c:560
ADI_TMR_PRESCALER
Definition: adi_tmr.h:135
ADI_TMR_PWM_OUTPUT
Definition: adi_tmr.h:169
ADI_TMR_RESULT adi_tmr_ConfigEvent(ADI_TMR_DEVICE const eDevice, ADI_TMR_EVENT_CONFIG *eventConfig)
Setup GP or RGB Timer Event Capture.
Definition: adi_tmr.c:323
ADI_TMR_RESULT adi_tmr_GetCurrentCount(ADI_TMR_DEVICE const eDevice, uint16_t *pCount)
Get GP or RGB Timer Current Count.
Definition: adi_tmr.c:496