esp_timer: fix ESP_TIMER_ISR dispatch method due to off by one error

This commit is contained in:
Marius Vikhammer
2022-11-09 10:34:13 +08:00
parent 3f2f35bd5e
commit 61990fc8d4

View File

@ -875,7 +875,7 @@ static void timer_isr_callback(void* arg)
int64_t now = esp_timer_get_time(); int64_t now = esp_timer_get_time();
int64_t dt = now - old_time[num_timer]; int64_t dt = now - old_time[num_timer];
old_time[num_timer] = now; old_time[num_timer] = now;
if (num_timer == 1) { if (num_timer == 0) {
esp_rom_printf("(%lld): \t\t\t\t timer ISR, dt: %lld us\n", now, dt); esp_rom_printf("(%lld): \t\t\t\t timer ISR, dt: %lld us\n", now, dt);
assert(xPortInIsrContext()); assert(xPortInIsrContext());
} else { } else {
@ -887,7 +887,7 @@ static void timer_isr_callback(void* arg)
TEST_CASE("Test ESP_TIMER_ISR dispatch method", "[esp_timer]") TEST_CASE("Test ESP_TIMER_ISR dispatch method", "[esp_timer]")
{ {
TEST_ESP_OK(esp_timer_dump(stdout)); TEST_ESP_OK(esp_timer_dump(stdout));
int timer[2]= {1, 2}; int timer[2]= {0, 1};
const esp_timer_create_args_t periodic_timer1_args = { const esp_timer_create_args_t periodic_timer1_args = {
.callback = &timer_isr_callback, .callback = &timer_isr_callback,
.dispatch_method = ESP_TIMER_ISR, .dispatch_method = ESP_TIMER_ISR,