Skip to content

Commit

Permalink
ESP32 3.0 support DRAFT
Browse files Browse the repository at this point in the history
  • Loading branch information
pschatzmann committed Oct 8, 2023
1 parent 7bd34d4 commit cd1f7bf
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions src/AudioTimer/AudioTimerESP32.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,17 @@ class TimerAlarmRepeatingDriverESP32 : public TimerAlarmRepeatingDriverBase {
int priority = configMAX_PRIORITIES -1;
uint32_t timeUs;

/// call timerAttachInterrupt
void attach(hw_timer_t* timer, void (*cb)()){
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1 , 0)
timerAttachInterrupt(timer, cb);
#else
timerAttachInterrupt(timer, cb, false);
#endif
}



/// direct timer callback
void setupDirectTimerCallback(repeating_timer_callback_t callback_f){
TRACED();
Expand All @@ -228,10 +239,10 @@ class TimerAlarmRepeatingDriverESP32 : public TimerAlarmRepeatingDriverBase {
simpleUserCallback = new UserCallback[4];
}
simpleUserCallback[timer_id].setup(callback_f, object, true);
if (timer_id==0) timerAttachInterrupt(adc_timer, userCallback0);
else if (timer_id==1) timerAttachInterrupt(adc_timer, userCallback1);
else if (timer_id==2) timerAttachInterrupt(adc_timer, userCallback2);
else if (timer_id==3) timerAttachInterrupt(adc_timer, userCallback3);
if (timer_id==0) attach(adc_timer, userCallback0);
else if (timer_id==1) attach(adc_timer, userCallback1);
else if (timer_id==2) attach(adc_timer, userCallback2);
else if (timer_id==3) attach(adc_timer, userCallback3);

#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1 , 0)
timerStart(adc_timer);
Expand All @@ -250,10 +261,10 @@ class TimerAlarmRepeatingDriverESP32 : public TimerAlarmRepeatingDriverBase {
timerCallbackArray = new TimerCallback[4];
}

if (timer_id==0) timerAttachInterrupt(adc_timer, timerCallback0);
else if (timer_id==1) timerAttachInterrupt(adc_timer, timerCallback1);
else if (timer_id==2) timerAttachInterrupt(adc_timer, timerCallback2);
else if (timer_id==3) timerAttachInterrupt(adc_timer, timerCallback3);
if (timer_id==0) attach(adc_timer, timerCallback0);
else if (timer_id==1) attach(adc_timer, timerCallback1);
else if (timer_id==2) attach(adc_timer, timerCallback2);
else if (timer_id==3) attach(adc_timer, timerCallback3);

// we record the callback method and user data
user_callback.setup(callback_f, object, false);
Expand All @@ -272,7 +283,6 @@ class TimerAlarmRepeatingDriverESP32 : public TimerAlarmRepeatingDriverBase {
#endif
}


/// No timer - just a simple task loop
void setupSimpleThreadLoop(repeating_timer_callback_t callback_f){
TRACED();
Expand Down

0 comments on commit cd1f7bf

Please sign in to comment.