@@ -67,6 +67,25 @@ static const clock_ip_name_t ctimers_clocks[FSL_FEATURE_SOC_CTIMER_COUNT] =
6767#error "ERROR in board timer configuration: too many timers defined"
6868#endif
6969
70+ uword_t timer_query_freqs_numof (tim_t dev )
71+ {
72+ assert (dev < TIMER_NUMOF );
73+ (void )dev ;
74+ return 256 ;
75+ }
76+
77+ uint32_t timer_query_freqs (tim_t dev , uword_t index )
78+ {
79+ assert (dev < TIMER_NUMOF );
80+ (void )dev ;
81+
82+ if (index >= UINT8_MAX ) {
83+ return 0 ;
84+ }
85+
86+ return CLOCK_GetFreq (kCLOCK_ApbClk ) / (index + 1 );
87+ }
88+
7089int timer_init (tim_t tim , uint32_t freq , timer_cb_t cb , void * arg )
7190{
7291 DEBUG ("timer_init(%u, %" PRIu32 ")\n" , tim , freq );
@@ -103,7 +122,7 @@ int timer_init(tim_t tim, uint32_t freq, timer_cb_t cb, void *arg)
103122int timer_set_absolute (tim_t tim , int channel , unsigned int value )
104123{
105124 DEBUG ("timer_set_absolute(%u, %u, %u)\n" , tim , channel , value );
106- if ((tim >= TIMER_NUMOF ) || (channel >= TIMER_CHANNELS )) {
125+ if ((tim >= TIMER_NUMOF ) || (channel >= TIMER_CHANNEL_NUMOF )) {
107126 return -1 ;
108127 }
109128 CTIMER_Type * const dev = ctimers [tim ];
@@ -115,7 +134,7 @@ int timer_set_absolute(tim_t tim, int channel, unsigned int value)
115134int timer_set (tim_t tim , int channel , unsigned int value )
116135{
117136 DEBUG ("timer_set(%u, %u, %u)\n" , tim , channel , value );
118- if ((tim >= TIMER_NUMOF ) || (channel >= TIMER_CHANNELS )) {
137+ if ((tim >= TIMER_NUMOF ) || (channel >= TIMER_CHANNEL_NUMOF )) {
119138 return -1 ;
120139 }
121140 CTIMER_Type * const dev = ctimers [tim ];
@@ -140,7 +159,7 @@ int timer_set(tim_t tim, int channel, unsigned int value)
140159int timer_clear (tim_t tim , int channel )
141160{
142161 DEBUG ("timer_clear(%u, %d)\n" , tim , channel );
143- if ((tim >= TIMER_NUMOF ) || (channel >= TIMER_CHANNELS )) {
162+ if ((tim >= TIMER_NUMOF ) || (channel >= TIMER_CHANNEL_NUMOF )) {
144163 return -1 ;
145164 }
146165 CTIMER_Type * const dev = ctimers [tim ];
@@ -170,7 +189,7 @@ static inline void isr_ctimer_n(CTIMER_Type *dev, uint32_t ctimer_num)
170189{
171190 DEBUG ("isr_ctimer_%" PRIu32 " flags=0x%" PRIx32 "\n" ,
172191 ctimer_num , dev -> IR );
173- unsigned state = dev -> IR & ((1 << TIMER_CHANNELS ) - 1 );
192+ unsigned state = dev -> IR & ((1 << TIMER_CHANNEL_NUMOF ) - 1 );
174193 while (state ) {
175194 uint8_t channel ;
176195 state = bitarithm_test_and_clear (state , & channel );
0 commit comments