Merge branch 'bugfix/esp_timer_isr_dispatch_test_fail' into 'master'

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

Closes IDFCI-1514

See merge request espressif/esp-idf!21006
This commit is contained in:
Marius Vikhammer
2022-11-09 16:45:19 +08:00
2 changed files with 17 additions and 3 deletions

View File

@@ -959,7 +959,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 {
@@ -971,7 +971,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,

View File

@@ -10,7 +10,6 @@ CONFIGS = [
pytest.param('single_core', marks=[pytest.mark.esp32]), pytest.param('single_core', marks=[pytest.mark.esp32]),
pytest.param('freertos_compliance', marks=[pytest.mark.esp32]), pytest.param('freertos_compliance', marks=[pytest.mark.esp32]),
pytest.param('isr_dispatch_esp32', marks=[pytest.mark.esp32]), pytest.param('isr_dispatch_esp32', marks=[pytest.mark.esp32]),
pytest.param('26mhz_esp32c2', marks=[pytest.mark.esp32c2]),
] ]
@@ -31,3 +30,18 @@ def test_esp_timer_psram(dut: Dut) -> None:
dut.expect_exact('Press ENTER to see the list of tests') dut.expect_exact('Press ENTER to see the list of tests')
dut.write('*') dut.write('*')
dut.expect_unity_test_output(timeout=240) dut.expect_unity_test_output(timeout=240)
@pytest.mark.esp32c2
@pytest.mark.xtal_26mhz
@pytest.mark.parametrize(
'config, baud',
[
('26mhz_esp32c2', '74880'),
],
indirect=True,
)
def test_esp_timer_esp32c2_xtal_26mhz(dut: Dut) -> None:
dut.expect_exact('Press ENTER to see the list of tests')
dut.write('*')
dut.expect_unity_test_output(timeout=240)