Revert Timer Interrupt setup
This commit is contained in:
parent
6d98555658
commit
17ece1bccd
@ -65,7 +65,7 @@ static hw_timer_t hw_timer[4] = {
|
||||
};
|
||||
|
||||
typedef void (*voidFuncPtr)(void);
|
||||
static voidFuncPtr __timerInterruptHandlers[4] = {0,};
|
||||
static voidFuncPtr __timerInterruptHandlers[4] = {0,0,0,0};
|
||||
|
||||
void IRAM_ATTR __timerISR(void * arg){
|
||||
uint32_t s0 = TIMERG0.int_st_timers.val;
|
||||
@ -84,12 +84,10 @@ void IRAM_ATTR __timerISR(void * arg){
|
||||
i = 4;
|
||||
//call callbacks
|
||||
while(i--){
|
||||
if(status & (1 << i)){
|
||||
if(__timerInterruptHandlers[i]){
|
||||
if(__timerInterruptHandlers[i] && status & (1 << i)){
|
||||
__timerInterruptHandlers[i]();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t timerRead(hw_timer_t *timer){
|
||||
@ -186,8 +184,6 @@ bool timerAlarmEnabled(hw_timer_t *timer){
|
||||
return timer->dev->config.alarm_en;
|
||||
}
|
||||
|
||||
|
||||
|
||||
hw_timer_t * timerBegin(uint8_t num, uint16_t divider, bool countUp){
|
||||
if(num > 3){
|
||||
return NULL;
|
||||
@ -217,12 +213,14 @@ void timerEnd(hw_timer_t *timer){
|
||||
timerAttachInterrupt(timer, NULL, false);
|
||||
}
|
||||
|
||||
#define HWTIMER_INUM 10
|
||||
void timerAttachInterrupt(hw_timer_t *timer, void (*fn)(void), bool edge){
|
||||
static bool initialized = false;
|
||||
static intr_handle_t intr_handle = NULL;
|
||||
if(intr_handle){
|
||||
esp_intr_disable(intr_handle);
|
||||
}
|
||||
//static intr_handle_t intr_handle = NULL;
|
||||
//if(intr_handle){
|
||||
// esp_intr_disable(intr_handle);
|
||||
//}
|
||||
ESP_INTR_DISABLE(HWTIMER_INUM);
|
||||
if(fn == NULL){
|
||||
timer->dev->config.level_int_en = 0;
|
||||
timer->dev->config.edge_int_en = 0;
|
||||
@ -253,19 +251,22 @@ void timerAttachInterrupt(hw_timer_t *timer, void (*fn)(void), bool edge){
|
||||
}
|
||||
if(!initialized){
|
||||
initialized = true;
|
||||
esp_intr_alloc(intr_source, (int)ESP_INTR_FLAG_IRAM, __timerISR, NULL, &intr_handle);
|
||||
} else {
|
||||
intr_matrix_set(esp_intr_get_cpu(intr_handle), intr_source, esp_intr_get_intno(intr_handle));
|
||||
}
|
||||
xt_set_interrupt_handler(HWTIMER_INUM, &__timerISR, NULL);
|
||||
//esp_intr_alloc(intr_source, (int)ESP_INTR_FLAG_IRAM, __timerISR, NULL, &intr_handle);
|
||||
}// else {
|
||||
// intr_matrix_set(esp_intr_get_cpu(intr_handle), intr_source, esp_intr_get_intno(intr_handle));
|
||||
//}
|
||||
intr_matrix_set(xPortGetCoreID(), intr_source, HWTIMER_INUM);
|
||||
if(timer->group){
|
||||
TIMERG1.int_ena.val |= BIT(timer->timer);
|
||||
} else {
|
||||
TIMERG0.int_ena.val |= BIT(timer->timer);
|
||||
}
|
||||
}
|
||||
if(intr_handle){
|
||||
esp_intr_enable(intr_handle);
|
||||
}
|
||||
//if(intr_handle){
|
||||
// esp_intr_enable(intr_handle);
|
||||
//}
|
||||
ESP_INTR_ENABLE(HWTIMER_INUM);
|
||||
}
|
||||
|
||||
void timerDetachInterrupt(hw_timer_t *timer){
|
||||
|
Loading…
Reference in New Issue
Block a user