2
2
* @file adi_tmr.h
3
3
* @brief GP and RGB timer device driver public header file
4
4
-----------------------------------------------------------------------------
5
- Copyright (c) 2016 Analog Devices, Inc.
5
+ Copyright (c) 2016-2018 Analog Devices, Inc.
6
6
7
7
All rights reserved.
8
8
@@ -56,12 +56,16 @@ POSSIBILITY OF SUCH DAMAGE.
56
56
* @{
57
57
*/
58
58
59
+ /* C++ linkage */
60
+ #ifdef __cplusplus
61
+ extern "C" {
62
+ #endif /* __cplusplus */
59
63
60
64
/*!
61
65
*****************************************************************************
62
66
* \enum ADI_TMR_RESULT
63
67
* Enumeration for result code returned from the timer device driver functions.
64
- * The return value of all timer APIs returning #ADI_TMR_RESULT should always
68
+ * The return value of all timer APIs returning #ADI_TMR_RESULT should always
65
69
* be tested at the application level for success or failure.
66
70
*****************************************************************************/
67
71
typedef enum {
@@ -97,10 +101,17 @@ typedef enum {
97
101
ADI_TMR_DEVICE_GP1 = 1u ,
98
102
/*! General purpose timer 2 */
99
103
ADI_TMR_DEVICE_GP2 = 2u ,
104
+ #if defined(__ADUCM3029__ )
105
+ /*! Total number of devices (private) */
106
+ ADI_TMR_DEVICE_NUM = 3u ,
107
+ #elif defined(__ADUCM4050__ )
100
108
/*! RGB timer */
101
109
ADI_TMR_DEVICE_RGB = 3u ,
102
110
/*! Total number of devices (private) */
103
111
ADI_TMR_DEVICE_NUM = 4u ,
112
+ #else
113
+ #error TMR is not ported for this processor
114
+ #endif
104
115
} ADI_TMR_DEVICE ;
105
116
106
117
/*!
@@ -110,7 +121,7 @@ typedef enum {
110
121
*****************************************************************************/
111
122
typedef enum {
112
123
/*! Timeout event occurred */
113
- ADI_TMR_EVENT_TIMEOUT = 0x01 ,
124
+ ADI_TMR_EVENT_TIMEOUT = 0x01 ,
114
125
/*! Event capture event occurred */
115
126
ADI_TMR_EVENT_CAPTURE = 0x02 ,
116
127
} ADI_TMR_EVENT ;
@@ -124,7 +135,7 @@ typedef enum {
124
135
/*! Count every 1 source clock periods */
125
136
ADI_TMR_PRESCALER_1 = 0u ,
126
137
/*! Count every 16 source clock periods */
127
- ADI_TMR_PRESCALER_16 = 1u ,
138
+ ADI_TMR_PRESCALER_16 = 1u ,
128
139
/*! Count every 64 source clock periods */
129
140
ADI_TMR_PRESCALER_64 = 2u ,
130
141
/*! Count every 256 source clock periods */
@@ -138,11 +149,11 @@ typedef enum {
138
149
*****************************************************************************/
139
150
typedef enum {
140
151
/*! Use periphreal clock (PCLK) */
141
- ADI_TMR_CLOCK_PCLK = 0u ,
152
+ ADI_TMR_CLOCK_PCLK = 0u ,
142
153
/*! Use internal high frequency clock (HFOSC) */
143
- ADI_TMR_CLOCK_HFOSC = 1u ,
154
+ ADI_TMR_CLOCK_HFOSC = 1u ,
144
155
/*! Use internal low frequency clock (LFOSC) */
145
- ADI_TMR_CLOCK_LFOSC = 2u ,
156
+ ADI_TMR_CLOCK_LFOSC = 2u ,
146
157
/*! Use external low frequency clock (LFXTAL) */
147
158
ADI_TMR_CLOCK_LFXTAL = 3u ,
148
159
} ADI_TMR_CLOCK_SOURCE ;
@@ -151,7 +162,7 @@ typedef enum {
151
162
*****************************************************************************
152
163
* \enum ADI_TMR_PWM_OUTPUT
153
164
* RGB PWM outputs, used to specify which PWM output to configure. For the GP
154
- * timers only #ADI_TMR_PWM_OUTPUT_0 is allowed. The RGB timer has all three
165
+ * timers only #ADI_TMR_PWM_OUTPUT_0 is allowed. The RGB timer has all three
155
166
* outputs.
156
167
*****************************************************************************/
157
168
typedef enum {
@@ -168,7 +179,7 @@ typedef enum {
168
179
/*!
169
180
*****************************************************************************
170
181
* \struct ADI_TMR_CONFIG
171
- * Configuration structure to fill and pass to #adi_tmr_ConfigTimer when
182
+ * Configuration structure to fill and pass to #adi_tmr_ConfigTimer when
172
183
* configuring the GP or RGB timer
173
184
*****************************************************************************/
174
185
typedef struct {
@@ -180,7 +191,7 @@ typedef struct {
180
191
ADI_TMR_PRESCALER ePrescaler ;
181
192
/*! Clock source */
182
193
ADI_TMR_CLOCK_SOURCE eClockSource ;
183
- /*! Load value (only relent in periodic mode) */
194
+ /*! Load value (only relevant in periodic mode) */
184
195
uint16_t nLoad ;
185
196
/*! Asynchronous load value (only relevant in periodic mode, and when PCLK is used) */
186
197
uint16_t nAsyncLoad ;
@@ -193,7 +204,7 @@ typedef struct {
193
204
/*!
194
205
*****************************************************************************
195
206
* \struct ADI_TMR_EVENT_CONFIG
196
- * Configuration structure to fill and pass to #adi_tmr_ConfigEvent when
207
+ * Configuration structure to fill and pass to #adi_tmr_ConfigEvent when
197
208
* configuring event capture
198
209
*****************************************************************************/
199
210
typedef struct {
@@ -208,7 +219,7 @@ typedef struct {
208
219
/*!
209
220
*****************************************************************************
210
221
* \struct ADI_TMR_PWM_CONFIG
211
- * Configuration structure to fill and pass to #adi_tmr_ConfigPwm when
222
+ * Configuration structure to fill and pass to #adi_tmr_ConfigPwm when
212
223
* configuring pulse width modulation output
213
224
*****************************************************************************/
214
225
typedef struct {
@@ -232,9 +243,9 @@ typedef struct {
232
243
ADI_TMR_RESULT adi_tmr_Init (ADI_TMR_DEVICE const eDevice , ADI_CALLBACK const pfCallback , void * const pCBParam , bool bEnableInt );
233
244
234
245
/* Configuration interface functions */
235
- ADI_TMR_RESULT adi_tmr_ConfigTimer (ADI_TMR_DEVICE const eDevice , ADI_TMR_CONFIG timerConfig );
236
- ADI_TMR_RESULT adi_tmr_ConfigEvent (ADI_TMR_DEVICE const eDevice , ADI_TMR_EVENT_CONFIG eventConfig );
237
- ADI_TMR_RESULT adi_tmr_ConfigPwm (ADI_TMR_DEVICE const eDevice , ADI_TMR_PWM_CONFIG pwmConfig );
246
+ ADI_TMR_RESULT adi_tmr_ConfigTimer (ADI_TMR_DEVICE const eDevice , ADI_TMR_CONFIG * timerConfig );
247
+ ADI_TMR_RESULT adi_tmr_ConfigEvent (ADI_TMR_DEVICE const eDevice , ADI_TMR_EVENT_CONFIG * eventConfig );
248
+ ADI_TMR_RESULT adi_tmr_ConfigPwm (ADI_TMR_DEVICE const eDevice , ADI_TMR_PWM_CONFIG * pwmConfig );
238
249
239
250
/* Timer start and stop */
240
251
ADI_TMR_RESULT adi_tmr_Enable (ADI_TMR_DEVICE const eDevice , bool bEnable );
@@ -246,7 +257,9 @@ ADI_TMR_RESULT adi_tmr_GetCaptureCount (ADI_TMR_DEVICE const eDevice, uint16_t *
246
257
/* Reload function */
247
258
ADI_TMR_RESULT adi_tmr_Reload (ADI_TMR_DEVICE const eDevice );
248
259
249
-
260
+ #ifdef __cplusplus
261
+ }
262
+ #endif
250
263
/*! @} */
251
264
252
265
0 commit comments