gr55xx_ll_dual_tim.h
Go to the documentation of this file.
1
51 /* Define to prevent recursive inclusion -------------------------------------*/
52 #ifndef __GR55XX_LL_DUAL_TIMER_H__
53 #define __GR55XX_LL_DUAL_TIMER_H__
54
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58
59 /* Includes ------------------------------------------------------------------*/
60 #include "gr55xx.h"
61
62 #if defined (DUAL_TIMER0) || defined (DUAL_TIMER1)
63
68 /* Exported types ------------------------------------------------------------*/
76 typedef struct _ll_dual_timer_init
77 {
78 uint32_t prescaler;
83 uint32_t counter_size;
88 uint32_t counter_mode;
93 uint32_t auto_reload;
99 } ll_dual_timer_init_t;
100
110 /* Exported constants --------------------------------------------------------*/
118 #define LL_DUAL_TIMER_FREERUNNING_MODE 0x00000000U
119 #define LL_DUAL_TIMER_PERIODIC_MODE DUAL_TIMER_CTRL_MODE
125 #define LL_DUAL_TIMER_PRESCALER_DIV0 0x00000000U
126 #define LL_DUAL_TIMER_PRESCALER_DIV16 (1UL << DUAL_TIMER_CTRL_PRE_Pos)
127 #define LL_DUAL_TIMER_PRESCALER_DIV256 (2UL << DUAL_TIMER_CTRL_PRE_Pos)
133 #define LL_DUAL_TIMER_COUNTERSIZE_16 0x00000000U
134 #define LL_DUAL_TIMER_COUNTERSIZE_32 DUAL_TIMER_CTRL_SIZE
144 #define DUAL_TIMER_DEFAULT_CONFIG \
145 { \
146 .prescaler = LL_DUAL_TIMER_PRESCALER_DIV0, \
147 .counter_size = LL_DUAL_TIMER_COUNTERSIZE_32, \
148 .counter_mode = LL_DUAL_TIMER_PERIODIC_MODE, \
149 .auto_reload = SystemCoreClock - 1, \
150 }
151
155 /* Exported macro ------------------------------------------------------------*/
171 #define LL_DUAL_TIMER_WriteReg(__instance__, __REG__, __VALUE__) WRITE_REG(__instance__->__REG__, (__VALUE__))
172
179 #define LL_DUAL_TIMER_ReadReg(__instance__, __REG__) READ_REG(__instance__->__REG__)
180
187 /* Exported functions --------------------------------------------------------*/
207 __STATIC_INLINE void ll_dual_timer_enable_counter(dual_timer_regs_t *DUAL_TIMERx)
208 {
209 SET_BITS(DUAL_TIMERx->CTRL, DUAL_TIMER_CTRL_EN);
210 }
211
222 __STATIC_INLINE void ll_dual_timer_disable_counter(dual_timer_regs_t *DUAL_TIMERx)
223 {
224 CLEAR_BITS(DUAL_TIMERx->CTRL, DUAL_TIMER_CTRL_EN);
225 }
226
237 __STATIC_INLINE uint32_t ll_dual_timer_is_enabled_counter(dual_timer_regs_t *DUAL_TIMERx)
238 {
239 return (READ_BITS(DUAL_TIMERx->CTRL, DUAL_TIMER_CTRL_EN) == (DUAL_TIMER_CTRL_EN));
240 }
241
255 __STATIC_INLINE void ll_dual_timer_set_counter_mode(dual_timer_regs_t *DUAL_TIMERx, uint32_t counter_mode)
256 {
257 MODIFY_REG(DUAL_TIMERx->CTRL, DUAL_TIMER_CTRL_MODE, counter_mode);
258 }
259
272 __STATIC_INLINE uint32_t ll_dual_timer_get_counter_mode(dual_timer_regs_t *DUAL_TIMERx)
273 {
274 return (READ_BITS(DUAL_TIMERx->CTRL, DUAL_TIMER_CTRL_MODE));
275 }
276
291 __STATIC_INLINE void ll_dual_timer_set_prescaler(dual_timer_regs_t *DUAL_TIMERx, uint32_t prescaler)
292 {
293 MODIFY_REG(DUAL_TIMERx->CTRL, DUAL_TIMER_CTRL_PRE, prescaler);
294 }
295
309 __STATIC_INLINE uint32_t ll_dual_timer_get_prescaler(dual_timer_regs_t *DUAL_TIMERx)
310 {
311 return (READ_BITS(DUAL_TIMERx->CTRL, DUAL_TIMER_CTRL_PRE));
312 }
313
327 __STATIC_INLINE void ll_dual_timer_set_counter_size(dual_timer_regs_t *DUAL_TIMERx, uint32_t counter_size)
328 {
329 MODIFY_REG(DUAL_TIMERx->CTRL, DUAL_TIMER_CTRL_SIZE, counter_size);
330 }
331
344 __STATIC_INLINE uint32_t ll_dual_timer_get_counter_size(dual_timer_regs_t *DUAL_TIMERx)
345 {
346 return (READ_BITS(DUAL_TIMERx->CTRL, DUAL_TIMER_CTRL_SIZE));
347 }
348
359 __STATIC_INLINE void ll_dual_timer_enable_oneshot(dual_timer_regs_t *DUAL_TIMERx)
360 {
361 SET_BITS(DUAL_TIMERx->CTRL, DUAL_TIMER_CTRL_ONESHOT);
362 }
363
374 __STATIC_INLINE void ll_dual_timer_disable_oneshot(dual_timer_regs_t *DUAL_TIMERx)
375 {
376 CLEAR_BITS(DUAL_TIMERx->CTRL, DUAL_TIMER_CTRL_ONESHOT);
377 }
378
389 __STATIC_INLINE uint32_t ll_dual_timer_is_enabled_oneshot(dual_timer_regs_t *DUAL_TIMERx)
390 {
391 return (READ_BITS(DUAL_TIMERx->CTRL, DUAL_TIMER_CTRL_ONESHOT) == (DUAL_TIMER_CTRL_ONESHOT));
392 }
393
404 __STATIC_INLINE uint32_t ll_dual_timer_get_counter(dual_timer_regs_t *DUAL_TIMERx)
405 {
406 return (uint32_t)(READ_REG(DUAL_TIMERx->VALUE));
407 }
408
421 __STATIC_INLINE void ll_dual_timer_set_auto_reload(dual_timer_regs_t *DUAL_TIMERx, uint32_t auto_reload)
422 {
423 WRITE_REG(DUAL_TIMERx->RELOAD, auto_reload);
424 }
425
436 __STATIC_INLINE uint32_t ll_dual_timer_get_auto_reload(dual_timer_regs_t *DUAL_TIMERx)
437 {
438 return (uint32_t)(READ_REG(DUAL_TIMERx->RELOAD));
439 }
440
452 __STATIC_INLINE void ll_dual_timer_set_background_reload(dual_timer_regs_t *DUAL_TIMERx, uint32_t background_reload)
453 {
454 WRITE_REG(DUAL_TIMERx->BG_LOAD, background_reload);
455 }
456
467 __STATIC_INLINE uint32_t ll_dual_timer_get_background_reload(dual_timer_regs_t *DUAL_TIMERx)
468 {
469 return (uint32_t)(READ_REG(DUAL_TIMERx->BG_LOAD));
470 }
471
488 __STATIC_INLINE void ll_dual_timer_enable_it(dual_timer_regs_t *DUAL_TIMERx)
489 {
490 SET_BITS(DUAL_TIMERx->CTRL, DUAL_TIMER_CTRL_INTEN);
491 }
492
503 __STATIC_INLINE void ll_dual_timer_disable_it(dual_timer_regs_t *DUAL_TIMERx)
504 {
505 CLEAR_BITS(DUAL_TIMERx->CTRL, DUAL_TIMER_CTRL_INTEN);
506 }
507
518 __STATIC_INLINE uint32_t ll_dual_timer_is_enabled_it(dual_timer_regs_t *DUAL_TIMERx)
519 {
520 return (READ_BITS(DUAL_TIMERx->CTRL, DUAL_TIMER_CTRL_INTEN) == (DUAL_TIMER_CTRL_INTEN));
521 }
522
540 __STATIC_INLINE void ll_dual_timer_clear_flag_it(dual_timer_regs_t *DUAL_TIMERx)
541 {
542 WRITE_REG(DUAL_TIMERx->INTCLR, DUAL_TIMER_INT_CLR);
543 }
544
555 __STATIC_INLINE uint32_t ll_dual_timer_is_active_flag_it(dual_timer_regs_t *DUAL_TIMERx)
556 {
557 return (READ_BITS(DUAL_TIMERx->INTSTAT, DUAL_TIMER_ISR_TI) == (DUAL_TIMER_ISR_TI));
558 }
559
570 __STATIC_INLINE uint32_t ll_dual_timer_get_raw_it_flag(dual_timer_regs_t *DUAL_TIMERx)
571 {
572 return (READ_REG(DUAL_TIMERx->RAW_INTSTAT));
573 }
574
588 error_status_t ll_dual_timer_deinit(dual_timer_regs_t *DUAL_TIMERx);
589
600 error_status_t ll_dual_timer_init(dual_timer_regs_t *DUAL_TIMERx, ll_dual_timer_init_t *p_dual_timer_init);
601
608 void ll_dual_timer_struct_init(ll_dual_timer_init_t *p_dual_timer_init);
609
615 #endif /* DUAL_TIMER0 || DUAL_TIMER1 */
616
617 #ifdef __cplusplus
618 }
619 #endif
620
621 #endif /* __GR55XX_LL_DUAL_TIMER_H__ */
622
ll_dual_timer_enable_it
__STATIC_INLINE void ll_dual_timer_enable_it(dual_timer_regs_t *DUAL_TIMERx)
Enable dual_timer interrupt.
Definition: gr55xx_ll_dual_tim.h:488
ll_dual_timer_init_t
struct _ll_dual_timer_init ll_dual_timer_init_t
LL DUAL TIMER init Structure definition.
ll_dual_timer_get_raw_it_flag
__STATIC_INLINE uint32_t ll_dual_timer_get_raw_it_flag(dual_timer_regs_t *DUAL_TIMERx)
Get Dual_timer raw interrupt flags.
Definition: gr55xx_ll_dual_tim.h:570
ll_dual_timer_get_counter_mode
__STATIC_INLINE uint32_t ll_dual_timer_get_counter_mode(dual_timer_regs_t *DUAL_TIMERx)
Get the counter mode.
Definition: gr55xx_ll_dual_tim.h:272
ll_dual_timer_is_active_flag_it
__STATIC_INLINE uint32_t ll_dual_timer_is_active_flag_it(dual_timer_regs_t *DUAL_TIMERx)
Indicate whether interrupt flag (INTSTAT) is set (interrupt is pending).
Definition: gr55xx_ll_dual_tim.h:555
ll_dual_timer_disable_it
__STATIC_INLINE void ll_dual_timer_disable_it(dual_timer_regs_t *DUAL_TIMERx)
Disable dual_timer interrput.
Definition: gr55xx_ll_dual_tim.h:503
ll_dual_timer_set_prescaler
__STATIC_INLINE void ll_dual_timer_set_prescaler(dual_timer_regs_t *DUAL_TIMERx, uint32_t prescaler)
Set the prescaler.
Definition: gr55xx_ll_dual_tim.h:291
_ll_dual_timer_init::prescaler
uint32_t prescaler
Definition: gr55xx_ll_dual_tim.h:78
ll_dual_timer_set_auto_reload
__STATIC_INLINE void ll_dual_timer_set_auto_reload(dual_timer_regs_t *DUAL_TIMERx, uint32_t auto_reload)
Set the auto-reload value.
Definition: gr55xx_ll_dual_tim.h:421
ll_dual_timer_enable_counter
__STATIC_INLINE void ll_dual_timer_enable_counter(dual_timer_regs_t *DUAL_TIMERx)
Enable dual_timer counter.
Definition: gr55xx_ll_dual_tim.h:207
ll_dual_timer_get_prescaler
__STATIC_INLINE uint32_t ll_dual_timer_get_prescaler(dual_timer_regs_t *DUAL_TIMERx)
Get the prescaler.
Definition: gr55xx_ll_dual_tim.h:309
ll_dual_timer_init
error_status_t ll_dual_timer_init(dual_timer_regs_t *DUAL_TIMERx, ll_dual_timer_init_t *p_dual_timer_init)
Initialize DUAL_TIMER registers according to the specified parameters in p_dual_timer_init.
ll_dual_timer_clear_flag_it
__STATIC_INLINE void ll_dual_timer_clear_flag_it(dual_timer_regs_t *DUAL_TIMERx)
Clear the interrupt flag (INTSTAT).
Definition: gr55xx_ll_dual_tim.h:540
ll_dual_timer_disable_oneshot
__STATIC_INLINE void ll_dual_timer_disable_oneshot(dual_timer_regs_t *DUAL_TIMERx)
Disable one-shot mode.
Definition: gr55xx_ll_dual_tim.h:374
ll_dual_timer_set_counter_mode
__STATIC_INLINE void ll_dual_timer_set_counter_mode(dual_timer_regs_t *DUAL_TIMERx, uint32_t counter_mode)
Set the counter mode.
Definition: gr55xx_ll_dual_tim.h:255
ll_dual_timer_set_background_reload
__STATIC_INLINE void ll_dual_timer_set_background_reload(dual_timer_regs_t *DUAL_TIMERx, uint32_t background_reload)
Set the backgroud-reload value.
Definition: gr55xx_ll_dual_tim.h:452
ll_dual_timer_enable_oneshot
__STATIC_INLINE void ll_dual_timer_enable_oneshot(dual_timer_regs_t *DUAL_TIMERx)
Enable one-shot mode.
Definition: gr55xx_ll_dual_tim.h:359
ll_dual_timer_is_enabled_it
__STATIC_INLINE uint32_t ll_dual_timer_is_enabled_it(dual_timer_regs_t *DUAL_TIMERx)
Indicate whether the dual_timer interrput is enabled.
Definition: gr55xx_ll_dual_tim.h:518
_ll_dual_timer_init::auto_reload
uint32_t auto_reload
Definition: gr55xx_ll_dual_tim.h:93
ll_dual_timer_get_background_reload
__STATIC_INLINE uint32_t ll_dual_timer_get_background_reload(dual_timer_regs_t *DUAL_TIMERx)
Get the backgroud-reload value.
Definition: gr55xx_ll_dual_tim.h:467
ll_dual_timer_get_counter
__STATIC_INLINE uint32_t ll_dual_timer_get_counter(dual_timer_regs_t *DUAL_TIMERx)
Get the counter value.
Definition: gr55xx_ll_dual_tim.h:404
ll_dual_timer_is_enabled_oneshot
__STATIC_INLINE uint32_t ll_dual_timer_is_enabled_oneshot(dual_timer_regs_t *DUAL_TIMERx)
Indicate whether the one-shot mode is enabled.
Definition: gr55xx_ll_dual_tim.h:389
_ll_dual_timer_init
LL DUAL TIMER init Structure definition.
Definition: gr55xx_ll_dual_tim.h:77
ll_dual_timer_struct_init
void ll_dual_timer_struct_init(ll_dual_timer_init_t *p_dual_timer_init)
Set each field of a ll_dual_timer_init_t type structure to default value.
_ll_dual_timer_init::counter_size
uint32_t counter_size
Definition: gr55xx_ll_dual_tim.h:83
_ll_dual_timer_init::counter_mode
uint32_t counter_mode
Definition: gr55xx_ll_dual_tim.h:88
ll_dual_timer_is_enabled_counter
__STATIC_INLINE uint32_t ll_dual_timer_is_enabled_counter(dual_timer_regs_t *DUAL_TIMERx)
Indicate whether the dual_timer counter is enabled.
Definition: gr55xx_ll_dual_tim.h:237
ll_dual_timer_disable_counter
__STATIC_INLINE void ll_dual_timer_disable_counter(dual_timer_regs_t *DUAL_TIMERx)
Disable dual_timer counter.
Definition: gr55xx_ll_dual_tim.h:222
ll_dual_timer_get_auto_reload
__STATIC_INLINE uint32_t ll_dual_timer_get_auto_reload(dual_timer_regs_t *DUAL_TIMERx)
Get the auto-reload value.
Definition: gr55xx_ll_dual_tim.h:436
ll_dual_timer_set_counter_size
__STATIC_INLINE void ll_dual_timer_set_counter_size(dual_timer_regs_t *DUAL_TIMERx, uint32_t counter_size)
Set the counter size.
Definition: gr55xx_ll_dual_tim.h:327
ll_dual_timer_get_counter_size
__STATIC_INLINE uint32_t ll_dual_timer_get_counter_size(dual_timer_regs_t *DUAL_TIMERx)
Get the counter size.
Definition: gr55xx_ll_dual_tim.h:344
ll_dual_timer_deinit
error_status_t ll_dual_timer_deinit(dual_timer_regs_t *DUAL_TIMERx)
De-initialize DUAL_TIMER registers (Registers restored to their default values).