@@ -65,7 +65,7 @@ static hw_timer_t hw_timer[4] = {
6565};
6666
6767typedef void (* voidFuncPtr )(void );
68- static voidFuncPtr __timerInterruptHandlers [4 ] = {0 ,};
68+ static voidFuncPtr __timerInterruptHandlers [4 ] = {0 ,0 , 0 , 0 };
6969
7070void IRAM_ATTR __timerISR (void * arg ){
7171 uint32_t s0 = TIMERG0 .int_st_timers .val ;
@@ -84,10 +84,8 @@ void IRAM_ATTR __timerISR(void * arg){
8484 i = 4 ;
8585 //call callbacks
8686 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 ]();
9189 }
9290 }
9391}
@@ -186,8 +184,6 @@ bool timerAlarmEnabled(hw_timer_t *timer){
186184 return timer -> dev -> config .alarm_en ;
187185}
188186
189-
190-
191187hw_timer_t * timerBegin (uint8_t num , uint16_t divider , bool countUp ){
192188 if (num > 3 ){
193189 return NULL ;
@@ -217,12 +213,14 @@ void timerEnd(hw_timer_t *timer){
217213 timerAttachInterrupt (timer , NULL , false);
218214}
219215
216+ #define HWTIMER_INUM 10
220217void timerAttachInterrupt (hw_timer_t * timer , void (* fn )(void ), bool edge ){
221218 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 );
226224 if (fn == NULL ){
227225 timer -> dev -> config .level_int_en = 0 ;
228226 timer -> dev -> config .edge_int_en = 0 ;
@@ -253,19 +251,22 @@ void timerAttachInterrupt(hw_timer_t *timer, void (*fn)(void), bool edge){
253251 }
254252 if (!initialized ){
255253 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 );
260260 if (timer -> group ){
261261 TIMERG1 .int_ena .val |= BIT (timer -> timer );
262262 } else {
263263 TIMERG0 .int_ena .val |= BIT (timer -> timer );
264264 }
265265 }
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 );
269270}
270271
271272void timerDetachInterrupt (hw_timer_t * timer ){
0 commit comments