9
9
10
10
/*******************************************************************************************************************/ /**
11
11
* @defgroup TIMER_API Timer Interface
12
- * @ingroup RENESAS_INTERFACES
12
+ * @ingroup RENESAS_TIMERS_INTERFACES
13
13
* @brief Interface for timer functions.
14
14
*
15
15
* @section TIMER_API_SUMMARY Summary
19
19
* If an instance supports output compare mode, it is provided in the extension configuration
20
20
* timer_on_<instance>_cfg_t defined in r_<instance>.h.
21
21
*
22
- * Implemented by:
23
- * - @ref GPT
24
- * - @ref GTM
25
- * - @ref MTU3
26
22
*
27
23
* @{
28
24
**********************************************************************************************************************/
@@ -45,6 +41,8 @@ FSP_HEADER
45
41
* Typedef definitions
46
42
**********************************************************************************************************************/
47
43
44
+ #ifndef BSP_OVERRIDE_TIMER_EVENT_T
45
+
48
46
/** Events that can trigger a callback function */
49
47
typedef enum e_timer_event
50
48
{
@@ -53,21 +51,36 @@ typedef enum e_timer_event
53
51
TIMER_EVENT_CAPTURE_A , ///< A capture has occurred on signal A
54
52
TIMER_EVENT_CAPTURE_B , ///< A capture has occurred on signal B
55
53
TIMER_EVENT_TROUGH , ///< Timer trough event (counter is 0, triangle-wave PWM only
56
- TIMER_EVENT_OUTPUT_COMPARE_0 , ///< An output has occurred on signal 0
57
- TIMER_EVENT_OUTPUT_COMPARE_1 , ///< An output has occurred on signal 1
58
- TIMER_EVENT_DEAD_TIME , ///< Dead time event
59
- TIMER_EVENT_CAPTURE_U , ///< A capture has occurred on signal U
60
- TIMER_EVENT_CAPTURE_V , ///< A capture has occurred on signal V
61
- TIMER_EVENT_CAPTURE_W , ///< A capture has occurred on signal W
54
+ TIMER_EVENT_COMPARE_A , ///< A compare has occurred on signal A
55
+ TIMER_EVENT_COMPARE_B , ///< A compare has occurred on signal B
56
+ TIMER_EVENT_COMPARE_C , ///< A compare has occurred on signal C
57
+ TIMER_EVENT_COMPARE_D , ///< A compare has occurred on signal D
58
+ TIMER_EVENT_COMPARE_E , ///< A compare has occurred on signal E
59
+ TIMER_EVENT_COMPARE_F , ///< A compare has occurred on signal F
60
+ TIMER_EVENT_DEAD_TIME ///< Dead time event
62
61
} timer_event_t ;
62
+ #endif
63
63
64
64
/** Timer variant types. */
65
65
typedef enum e_timer_variant
66
66
{
67
- TIMER_VARIANT_32_BIT , ///< 32-bit timer
68
- TIMER_VARIANT_16_BIT ///< 16-bit timer
67
+ TIMER_VARIANT_32_BIT , ///< 32-bit timer
68
+ TIMER_VARIANT_16_BIT ///< 16-bit timer
69
69
} timer_variant_t ;
70
70
71
+ /** Options for storing compare match value */
72
+ typedef enum e_timer_compare_match
73
+ {
74
+ TIMER_COMPARE_MATCH_A = 0U , ///< Compare match A value
75
+ TIMER_COMPARE_MATCH_B = 1U , ///< Compare match B value
76
+ TIMER_COMPARE_MATCH_C = 2U , ///< Compare match C value
77
+ TIMER_COMPARE_MATCH_D = 3U , ///< Compare match D value
78
+ TIMER_COMPARE_MATCH_E = 4U , ///< Compare match E value
79
+ TIMER_COMPARE_MATCH_F = 5U , ///< Compare match F value
80
+ TIMER_COMPARE_MATCH_G = 6U , ///< Compare match G value
81
+ TIMER_COMPARE_MATCH_H = 7U , ///< Compare match H value
82
+ } timer_compare_match_t ;
83
+
71
84
/** Callback function parameter data */
72
85
typedef struct st_timer_callback_args
73
86
{
@@ -80,19 +93,16 @@ typedef struct st_timer_callback_args
80
93
} timer_callback_args_t ;
81
94
82
95
/** Timer control block. Allocate an instance specific control block to pass into the timer API calls.
83
- * @par Implemented as
84
- * - gpt_instance_ctrl_t
85
- * - gtm_instance_ctrl_t
86
- * - mtu3_instance_ctrl_t
87
96
*/
88
97
typedef void timer_ctrl_t ;
89
98
90
99
/** Possible status values returned by @ref timer_api_t::statusGet. */
91
100
typedef enum e_timer_state
92
101
{
93
102
TIMER_STATE_STOPPED = 0 , ///< Timer is stopped
94
- TIMER_STATE_COUNTING = 1 , ///< Timer is running
103
+ TIMER_STATE_COUNTING = 1 ///< Timer is running
95
104
} timer_state_t ;
105
+ #ifndef BSP_OVERRIDE_TIMER_MODE_T
96
106
97
107
/** Timer operational modes */
98
108
typedef enum e_timer_mode
@@ -109,16 +119,20 @@ typedef enum e_timer_mode
109
119
* not need to be updated at each tough/crest interrupt. Instead, the trough and crest duty cycle values can be
110
120
* set once and only need to be updated when the application needs to change the duty cycle.
111
121
*/
112
- TIMER_MODE_TRIANGLE_WAVE_ASYMMETRIC_PWM_MODE3 = 6U ,
122
+ TIMER_MODE_TRIANGLE_WAVE_ASYMMETRIC_PWM_MODE3 = 6U
113
123
} timer_mode_t ;
114
124
125
+ #endif
126
+
115
127
/** Direction of timer count */
116
128
typedef enum e_timer_direction
117
129
{
118
130
TIMER_DIRECTION_DOWN = 0 , ///< Timer count goes up
119
131
TIMER_DIRECTION_UP = 1 ///< Timer count goes down
120
132
} timer_direction_t ;
121
133
134
+ #ifndef BSP_OVERRIDE_TIMER_SOURCE_DIV_T
135
+
122
136
/** Clock source divisors */
123
137
typedef enum e_timer_source_div
124
138
{
@@ -133,7 +147,9 @@ typedef enum e_timer_source_div
133
147
TIMER_SOURCE_DIV_256 = 8 , ///< Timer clock source divided by 256
134
148
TIMER_SOURCE_DIV_512 = 9 , ///< Timer clock source divided by 512
135
149
TIMER_SOURCE_DIV_1024 = 10 , ///< Timer clock source divided by 1024
150
+ TIMER_SOURCE_DIV_8192 = 13 , ///< Timer clock source divided by 8192
136
151
} timer_source_div_t ;
152
+ #endif
137
153
138
154
/** Timer information structure to store various information for a timer resource */
139
155
typedef struct st_timer_info
@@ -183,136 +199,98 @@ typedef struct st_timer_cfg
183
199
typedef struct st_timer_api
184
200
{
185
201
/** Initial configuration.
186
- * @par Implemented as
187
- * - @ref R_GPT_Open()
188
- * - @ref R_GTM_Open()
189
- * - @ref R_MTU3_Open()
190
202
*
191
203
* @param[in] p_ctrl Pointer to control block. Must be declared by user. Elements set here.
192
204
* @param[in] p_cfg Pointer to configuration structure. All elements of this structure must be set by user.
193
205
*/
194
206
fsp_err_t (* open )(timer_ctrl_t * const p_ctrl , timer_cfg_t const * const p_cfg );
195
207
196
208
/** Start the counter.
197
- * @par Implemented as
198
- * - @ref R_GPT_Start()
199
- * - @ref R_GTM_Start()
200
- * - @ref R_MTU3_Start()
201
209
*
202
210
* @param[in] p_ctrl Control block set in @ref timer_api_t::open call for this timer.
203
211
*/
204
212
fsp_err_t (* start )(timer_ctrl_t * const p_ctrl );
205
213
206
214
/** Stop the counter.
207
- * @par Implemented as
208
- * - @ref R_GPT_Stop()
209
- * - @ref R_GTM_Stop()
210
- * - @ref R_MTU3_Stop()
211
215
*
212
216
* @param[in] p_ctrl Control block set in @ref timer_api_t::open call for this timer.
213
217
*/
214
218
fsp_err_t (* stop )(timer_ctrl_t * const p_ctrl );
215
219
216
220
/** Reset the counter to the initial value.
217
- * @par Implemented as
218
- * - @ref R_GPT_Reset()
219
- * - @ref R_GTM_Reset()
220
- * - @ref R_MTU3_Reset()
221
221
*
222
222
* @param[in] p_ctrl Control block set in @ref timer_api_t::open call for this timer.
223
223
*/
224
224
fsp_err_t (* reset )(timer_ctrl_t * const p_ctrl );
225
225
226
226
/** Enables input capture.
227
- * @par Implemented as
228
- * - @ref R_GPT_Enable()
229
- * - @ref R_GTM_Enable()
230
- * - @ref R_MTU3_Enable()
231
227
*
232
228
* @param[in] p_ctrl Control block set in @ref timer_api_t::open call for this timer.
233
229
*/
234
230
fsp_err_t (* enable )(timer_ctrl_t * const p_ctrl );
235
231
236
232
/** Disables input capture.
237
- * @par Implemented as
238
- * - @ref R_GPT_Disable()
239
- * - @ref R_GTM_Disable()
240
- * - @ref R_MTU3_Disable()
241
233
*
242
234
* @param[in] p_ctrl Control block set in @ref timer_api_t::open call for this timer.
243
235
*/
244
236
fsp_err_t (* disable )(timer_ctrl_t * const p_ctrl );
245
237
246
238
/** Set the time until the timer expires. See implementation for details of period update timing.
247
239
*
248
- * @par Implemented as
249
- * - @ref R_GPT_PeriodSet()
250
- * - @ref R_GTM_PeriodSet()
251
- * - @ref R_MTU3_PeriodSet()
252
240
*
253
241
* @note Timer expiration may or may not generate a CPU interrupt based on how the timer is configured in
254
242
* @ref timer_api_t::open.
255
243
* @param[in] p_ctrl Control block set in @ref timer_api_t::open call for this timer.
256
- * @param[in] p_period Time until timer should expire.
244
+ * @param[in] period Time until timer should expire.
257
245
*/
258
246
fsp_err_t (* periodSet )(timer_ctrl_t * const p_ctrl , uint32_t const period );
259
247
260
248
/** Sets the number of counts for the pin level to be high. If the timer is counting, the updated duty cycle is
261
249
* reflected after the next timer expiration.
262
250
*
263
- * @par Implemented as
264
- * - @ref R_GPT_DutyCycleSet()
265
- * - @ref R_GTM_DutyCycleSet()
266
- * - @ref R_MTU3_DutyCycleSet()
267
251
*
268
252
* @param[in] p_ctrl Control block set in @ref timer_api_t::open call for this timer.
269
253
* @param[in] duty_cycle_counts Time until duty cycle should expire.
270
254
* @param[in] pin Which output pin to update. See implementation for details.
271
255
*/
272
256
fsp_err_t (* dutyCycleSet )(timer_ctrl_t * const p_ctrl , uint32_t const duty_cycle_counts , uint32_t const pin );
273
257
258
+ /** Set a compare match value in raw counts.
259
+ *
260
+ *
261
+ * @param[in] p_ctrl Control block set in @ref timer_api_t::open call for this timer.
262
+ * @param[in] compare_match_value Timer value to trigger a compare match event.
263
+ * @param[in] match_channel Which channel to update.
264
+ */
265
+ fsp_err_t (* compareMatchSet )(timer_ctrl_t * const p_ctrl , uint32_t const compare_match_value ,
266
+ timer_compare_match_t const match_channel );
267
+
274
268
/** Stores timer information in p_info.
275
- * @par Implemented as
276
- * - @ref R_GPT_InfoGet()
277
- * - @ref R_GTM_InfoGet()
278
- * - @ref R_MTU3_InfoGet()
279
269
*
280
270
* @param[in] p_ctrl Control block set in @ref timer_api_t::open call for this timer.
281
271
* @param[out] p_info Collection of information for this timer.
282
272
*/
283
273
fsp_err_t (* infoGet )(timer_ctrl_t * const p_ctrl , timer_info_t * const p_info );
284
274
285
275
/** Get the current counter value and timer state and store it in p_status.
286
- * @par Implemented as
287
- * - @ref R_GPT_StatusGet()
288
- * - @ref R_GTM_StatusGet()
289
- * - @ref R_MTU3_StatusGet()
290
276
*
291
277
* @param[in] p_ctrl Control block set in @ref timer_api_t::open call for this timer.
292
278
* @param[out] p_status Current status of this timer.
293
279
*/
294
280
fsp_err_t (* statusGet )(timer_ctrl_t * const p_ctrl , timer_status_t * const p_status );
295
281
296
282
/** Specify callback function and optional context pointer and working memory pointer.
297
- * @par Implemented as
298
- * - @ref R_GPT_CallbackSet()
299
- * - @ref R_GTM_CallbackSet()
300
- * - @ref R_MTU3_CallbackSet()
301
283
*
302
284
* @param[in] p_ctrl Control block set in @ref timer_api_t::open call for this timer.
303
285
* @param[in] p_callback Callback function to register
304
286
* @param[in] p_context Pointer to send to callback function
305
287
* @param[in] p_working_memory Pointer to volatile memory where callback structure can be allocated.
306
288
* Callback arguments allocated here are only valid during the callback.
307
289
*/
308
- fsp_err_t (* callbackSet )(timer_ctrl_t * const p_api_ctrl , void (* p_callback )(timer_callback_args_t * ),
290
+ fsp_err_t (* callbackSet )(timer_ctrl_t * const p_ctrl , void (* p_callback )(timer_callback_args_t * ),
309
291
void const * const p_context , timer_callback_args_t * const p_callback_memory );
310
292
311
293
/** Allows driver to be reconfigured and may reduce power consumption.
312
- * @par Implemented as
313
- * - @ref R_GPT_Close()
314
- * - @ref R_GTM_Close()
315
- * - @ref R_MTU3_Close()
316
294
*
317
295
* @param[in] p_ctrl Control block set in @ref timer_api_t::open call for this timer.
318
296
*/
0 commit comments