@@ -32,13 +32,6 @@ typedef union {
32
32
33
33
#define NUM_OF_TIMERS SOC_TIMER_GROUP_TOTAL_TIMERS
34
34
35
- typedef struct {
36
- int timer_group ;
37
- int timer_idx ;
38
- int alarm_interval ;
39
- bool auto_reload ;
40
- } timer_info_t ;
41
-
42
35
typedef struct hw_timer_s
43
36
{
44
37
uint8_t group ;
@@ -194,7 +187,7 @@ static void _on_apb_change(void * arg, apb_change_ev_t ev_type, uint32_t old_apb
194
187
hw_timer_t * timerBegin (uint8_t num , uint16_t divider , bool countUp ){
195
188
if (num >= NUM_OF_TIMERS )
196
189
{
197
- log_e ("Timer dont have that timer number." );
190
+ log_e ("Timer number %u exceeds available number of Timers." , num );
198
191
return NULL ;
199
192
}
200
193
@@ -220,24 +213,23 @@ void timerEnd(hw_timer_t *timer){
220
213
timer_deinit (timer -> group , timer -> num );
221
214
}
222
215
216
+ bool IRAM_ATTR timerFnWrapper (void * arg ){
217
+ void (* fn )(void ) = arg ;
218
+ fn ();
219
+
220
+ // some additional logic or handling may be required here to approriately yield or not
221
+ return false;
222
+ }
223
+
223
224
void timerAttachInterrupt (hw_timer_t * timer , void (* fn )(void ), bool edge ){
224
225
if (edge ){
225
226
log_w ("EDGE timer interrupt is not supported! Setting to LEVEL..." );
226
- edge = false;
227
227
}
228
- timer_enable_intr (timer -> group , timer -> num );
229
-
230
- timer_info_t * timer_info = calloc (1 , sizeof (timer_info_t ));
231
- timer_info -> timer_group = timer -> group ;
232
- timer_info -> timer_idx = timer -> num ;
233
- timer_info -> auto_reload = timerGetAutoReload (timer );
234
- timer_info -> alarm_interval = timerAlarmRead (timer );
235
-
236
- timer_isr_callback_add (timer -> group , timer -> num , (timer_isr_t )fn , timer_info , 0 );
228
+ timer_isr_callback_add (timer -> group , timer -> num , timerFnWrapper , fn , 0 );
237
229
}
238
230
239
231
void timerDetachInterrupt (hw_timer_t * timer ){
240
- timerAttachInterrupt (timer , NULL , false );
232
+ timer_isr_callback_remove (timer -> group , timer -> num );
241
233
}
242
234
243
235
uint64_t timerReadMicros (hw_timer_t * timer ){
0 commit comments