@@ -213,14 +213,12 @@ void timerEnd(hw_timer_t *timer){
213
213
timerAttachInterrupt (timer , NULL , false);
214
214
}
215
215
216
- #define HWTIMER_INUM 10
217
216
void timerAttachInterrupt (hw_timer_t * timer , void (* fn )(void ), bool edge ){
218
217
static bool initialized = false;
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 );
218
+ static intr_handle_t intr_handle = NULL ;
219
+ if (intr_handle ){
220
+ esp_intr_disable (intr_handle );
221
+ }
224
222
if (fn == NULL ){
225
223
timer -> dev -> config .level_int_en = 0 ;
226
224
timer -> dev -> config .edge_int_en = 0 ;
@@ -251,22 +249,19 @@ void timerAttachInterrupt(hw_timer_t *timer, void (*fn)(void), bool edge){
251
249
}
252
250
if (!initialized ){
253
251
initialized = true;
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 );
252
+ esp_intr_alloc (intr_source , (int )(ESP_INTR_FLAG_IRAM |ESP_INTR_FLAG_LOWMED |ESP_INTR_FLAG_EDGE ), __timerISR , NULL , & intr_handle );
253
+ } else {
254
+ intr_matrix_set (esp_intr_get_cpu (intr_handle ), intr_source , esp_intr_get_intno (intr_handle ));
255
+ }
260
256
if (timer -> group ){
261
257
TIMERG1 .int_ena .val |= BIT (timer -> timer );
262
258
} else {
263
259
TIMERG0 .int_ena .val |= BIT (timer -> timer );
264
260
}
265
261
}
266
- //if(intr_handle){
267
- // esp_intr_enable(intr_handle);
268
- //}
269
- ESP_INTR_ENABLE (HWTIMER_INUM );
262
+ if (intr_handle ){
263
+ esp_intr_enable (intr_handle );
264
+ }
270
265
}
271
266
272
267
void timerDetachInterrupt (hw_timer_t * timer ){
0 commit comments