@@ -65,7 +65,7 @@ static hw_timer_t hw_timer[4] = {
65
65
};
66
66
67
67
typedef void (* voidFuncPtr )(void );
68
- static voidFuncPtr __timerInterruptHandlers [4 ] = {0 ,};
68
+ static voidFuncPtr __timerInterruptHandlers [4 ] = {0 ,0 , 0 , 0 };
69
69
70
70
void IRAM_ATTR __timerISR (void * arg ){
71
71
uint32_t s0 = TIMERG0 .int_st_timers .val ;
@@ -84,10 +84,8 @@ void IRAM_ATTR __timerISR(void * arg){
84
84
i = 4 ;
85
85
//call callbacks
86
86
while (i -- ){
87
- if (status & (1 << i )){
88
- if (__timerInterruptHandlers [i ]){
89
- __timerInterruptHandlers [i ]();
90
- }
87
+ if (__timerInterruptHandlers [i ] && status & (1 << i )){
88
+ __timerInterruptHandlers [i ]();
91
89
}
92
90
}
93
91
}
@@ -186,8 +184,6 @@ bool timerAlarmEnabled(hw_timer_t *timer){
186
184
return timer -> dev -> config .alarm_en ;
187
185
}
188
186
189
-
190
-
191
187
hw_timer_t * timerBegin (uint8_t num , uint16_t divider , bool countUp ){
192
188
if (num > 3 ){
193
189
return NULL ;
@@ -217,12 +213,14 @@ void timerEnd(hw_timer_t *timer){
217
213
timerAttachInterrupt (timer , NULL , false);
218
214
}
219
215
216
+ #define HWTIMER_INUM 10
220
217
void timerAttachInterrupt (hw_timer_t * timer , void (* fn )(void ), bool edge ){
221
218
static bool initialized = false;
222
- static intr_handle_t intr_handle = NULL ;
223
- if (intr_handle ){
224
- esp_intr_disable (intr_handle );
225
- }
219
+ //static intr_handle_t intr_handle = NULL;
220
+ //if(intr_handle){
221
+ // esp_intr_disable(intr_handle);
222
+ //}
223
+ ESP_INTR_DISABLE (HWTIMER_INUM );
226
224
if (fn == NULL ){
227
225
timer -> dev -> config .level_int_en = 0 ;
228
226
timer -> dev -> config .edge_int_en = 0 ;
@@ -253,19 +251,22 @@ void timerAttachInterrupt(hw_timer_t *timer, void (*fn)(void), bool edge){
253
251
}
254
252
if (!initialized ){
255
253
initialized = true;
256
- esp_intr_alloc (intr_source , (int )ESP_INTR_FLAG_IRAM , __timerISR , NULL , & intr_handle );
257
- } else {
258
- intr_matrix_set (esp_intr_get_cpu (intr_handle ), intr_source , esp_intr_get_intno (intr_handle ));
259
- }
254
+ xt_set_interrupt_handler (HWTIMER_INUM , & __timerISR , NULL );
255
+ //esp_intr_alloc(intr_source, (int)ESP_INTR_FLAG_IRAM, __timerISR, NULL, &intr_handle);
256
+ }// else {
257
+ // intr_matrix_set(esp_intr_get_cpu(intr_handle), intr_source, esp_intr_get_intno(intr_handle));
258
+ //}
259
+ intr_matrix_set (xPortGetCoreID (), intr_source , HWTIMER_INUM );
260
260
if (timer -> group ){
261
261
TIMERG1 .int_ena .val |= BIT (timer -> timer );
262
262
} else {
263
263
TIMERG0 .int_ena .val |= BIT (timer -> timer );
264
264
}
265
265
}
266
- if (intr_handle ){
267
- esp_intr_enable (intr_handle );
268
- }
266
+ //if(intr_handle){
267
+ // esp_intr_enable(intr_handle);
268
+ //}
269
+ ESP_INTR_ENABLE (HWTIMER_INUM );
269
270
}
270
271
271
272
void timerDetachInterrupt (hw_timer_t * timer ){
0 commit comments