@@ -213,14 +213,12 @@ void timerEnd(hw_timer_t *timer){
213213 timerAttachInterrupt (timer , NULL , false);
214214}
215215
216- #define HWTIMER_INUM 10
217216void timerAttachInterrupt (hw_timer_t * timer , void (* fn )(void ), bool edge ){
218217 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+ }
224222 if (fn == NULL ){
225223 timer -> dev -> config .level_int_en = 0 ;
226224 timer -> dev -> config .edge_int_en = 0 ;
@@ -251,22 +249,19 @@ void timerAttachInterrupt(hw_timer_t *timer, void (*fn)(void), bool edge){
251249 }
252250 if (!initialized ){
253251 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+ }
260256 if (timer -> group ){
261257 TIMERG1 .int_ena .val |= BIT (timer -> timer );
262258 } else {
263259 TIMERG0 .int_ena .val |= BIT (timer -> timer );
264260 }
265261 }
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+ }
270265}
271266
272267void timerDetachInterrupt (hw_timer_t * timer ){
0 commit comments