gr55xx_ll_tim.h
Go to the documentation of this file.
1 
51 /* Define to prevent recursive inclusion -------------------------------------*/
52 #ifndef __GR55XX_LL_TIMER_H__
53 #define __GR55XX_LL_TIMER_H__
54 
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 
59 /* Includes ------------------------------------------------------------------*/
60 #include "gr55xx.h"
61 
62 #if defined (TIMER0) || defined (TIMER1)
63 
68 /* Exported types ------------------------------------------------------------*/
76 typedef struct _ll_timer_init_t
77 {
78  uint32_t auto_reload;
94 /* Exported constants --------------------------------------------------------*/
105 #define TIMER_DEFAULT_CONFIG \
106 { \
107  .auto_reload = SystemCoreClock - 1, \
108 }
109 
113 /* Exported macro ------------------------------------------------------------*/
129 #define LL_TIMER_WriteReg(__instance__, __REG__, __VALUE__) WRITE_REG(__instance__->__REG__, (__VALUE__))
130 
137 #define LL_TIMER_ReadReg(__instance__, __REG__) READ_REG(__instance__->__REG__)
138 
145 /* Exported functions --------------------------------------------------------*/
164 __STATIC_INLINE void ll_timer_enable_counter(timer_regs_t *TIMERx)
165 {
166  SET_BITS(TIMERx->CTRL, TIMER_CTRL_EN);
167 }
168 
179 __STATIC_INLINE void ll_timer_disable_counter(timer_regs_t *TIMERx)
180 {
181  CLEAR_BITS(TIMERx->CTRL, TIMER_CTRL_EN);
182 }
183 
194 __STATIC_INLINE uint32_t ll_timer_is_enabled_counter(timer_regs_t *TIMERx)
195 {
196  return (READ_BITS(TIMERx->CTRL, TIMER_CTRL_EN) == (TIMER_CTRL_EN));
197 }
198 
210 __STATIC_INLINE void ll_timer_set_counter(timer_regs_t *TIMERx, uint32_t counter)
211 {
212  WRITE_REG(TIMERx->VALUE, counter);
213 }
214 
225 __STATIC_INLINE uint32_t ll_timer_get_counter(timer_regs_t *TIMERx)
226 {
227  return (uint32_t)(READ_REG(TIMERx->VALUE));
228 }
229 
242 __STATIC_INLINE void ll_timer_set_auto_reload(timer_regs_t *TIMERx, uint32_t auto_reload)
243 {
244  WRITE_REG(TIMERx->RELOAD, auto_reload);
245 }
246 
257 __STATIC_INLINE uint32_t ll_timer_get_auto_reload(timer_regs_t *TIMERx)
258 {
259  return (uint32_t)(READ_REG(TIMERx->RELOAD));
260 }
261 
278 __STATIC_INLINE void ll_timer_enable_it(timer_regs_t *TIMERx)
279 {
280  SET_BITS(TIMERx->CTRL, TIMER_CTRL_INTEN);
281 }
282 
293 __STATIC_INLINE void ll_timer_disable_it(timer_regs_t *TIMERx)
294 {
295  CLEAR_BITS(TIMERx->CTRL, TIMER_CTRL_INTEN);
296 }
297 
308 __STATIC_INLINE uint32_t ll_timer_is_enabled_it(timer_regs_t *TIMERx)
309 {
310  return (READ_BITS(TIMERx->CTRL, TIMER_CTRL_INTEN) == (TIMER_CTRL_INTEN));
311 }
312 
329 __STATIC_INLINE void ll_timer_clear_flag_it(timer_regs_t *TIMERx)
330 {
331  WRITE_REG(TIMERx->INTSTAT, TIMER_INT_STAT);
332 }
333 
344 __STATIC_INLINE uint32_t ll_timer_is_active_flag_it(timer_regs_t *TIMERx)
345 {
346  return (READ_BITS(TIMERx->INTSTAT, TIMER_INT_STAT) == (TIMER_INT_STAT));
347 }
348 
362 error_status_t ll_timer_deinit(timer_regs_t *TIMERx);
363 
374 error_status_t ll_timer_init(timer_regs_t *TIMERx, ll_timer_init_t *p_timer_init);
375 
383 
388 #endif /* TIMER0 || TIMER1 */
389 
390 #ifdef __cplusplus
391 }
392 #endif
393 
394 #endif /* __GR55XX_LL_TIMER_H__ */
395 
ll_timer_enable_counter
__STATIC_INLINE void ll_timer_enable_counter(timer_regs_t *TIMERx)
Enable timer counter.
Definition: gr55xx_ll_tim.h:164
ll_timer_init
error_status_t ll_timer_init(timer_regs_t *TIMERx, ll_timer_init_t *p_timer_init)
Initialize TIMER registers according to the specified parameters in TIMER_InitStruct.
ll_timer_disable_counter
__STATIC_INLINE void ll_timer_disable_counter(timer_regs_t *TIMERx)
Disable timer counter.
Definition: gr55xx_ll_tim.h:179
ll_timer_set_counter
__STATIC_INLINE void ll_timer_set_counter(timer_regs_t *TIMERx, uint32_t counter)
Set the counter value.
Definition: gr55xx_ll_tim.h:210
ll_timer_enable_it
__STATIC_INLINE void ll_timer_enable_it(timer_regs_t *TIMERx)
Enable timer interrupt.
Definition: gr55xx_ll_tim.h:278
ll_timer_clear_flag_it
__STATIC_INLINE void ll_timer_clear_flag_it(timer_regs_t *TIMERx)
Clear the interrupt flag (INTSTAT).
Definition: gr55xx_ll_tim.h:329
ll_timer_is_enabled_counter
__STATIC_INLINE uint32_t ll_timer_is_enabled_counter(timer_regs_t *TIMERx)
Indicate whether the timer counter is enabled.
Definition: gr55xx_ll_tim.h:194
ll_timer_deinit
error_status_t ll_timer_deinit(timer_regs_t *TIMERx)
De-initialize TIMER registers (Registers restored to their default values).
_ll_timer_init_t
LL TIMER init Structure definition.
Definition: gr55xx_ll_tim.h:77
ll_timer_get_counter
__STATIC_INLINE uint32_t ll_timer_get_counter(timer_regs_t *TIMERx)
Get the counter value.
Definition: gr55xx_ll_tim.h:225
ll_timer_struct_init
void ll_timer_struct_init(ll_timer_init_t *p_timer_init)
Set each field of a ll_timer_init_t type structure to default value.
_ll_timer_init_t::auto_reload
uint32_t auto_reload
Definition: gr55xx_ll_tim.h:78
ll_timer_set_auto_reload
__STATIC_INLINE void ll_timer_set_auto_reload(timer_regs_t *TIMERx, uint32_t auto_reload)
Set the auto-reload value.
Definition: gr55xx_ll_tim.h:242
ll_timer_get_auto_reload
__STATIC_INLINE uint32_t ll_timer_get_auto_reload(timer_regs_t *TIMERx)
Get the auto-reload value.
Definition: gr55xx_ll_tim.h:257
ll_timer_is_active_flag_it
__STATIC_INLINE uint32_t ll_timer_is_active_flag_it(timer_regs_t *TIMERx)
Indicate whether interrupt flag (INTSTAT) is set (interrupt is pending).
Definition: gr55xx_ll_tim.h:344
ll_timer_init_t
struct _ll_timer_init_t ll_timer_init_t
LL TIMER init Structure definition.
ll_timer_is_enabled_it
__STATIC_INLINE uint32_t ll_timer_is_enabled_it(timer_regs_t *TIMERx)
Indicate whether the timer interrput is enabled.
Definition: gr55xx_ll_tim.h:308
ll_timer_disable_it
__STATIC_INLINE void ll_timer_disable_it(timer_regs_t *TIMERx)
Disable timer interrput.
Definition: gr55xx_ll_tim.h:293