mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
fix(esp_timer): Force to go light sleep ignoring ESP_ERR_SLEEP_REJECT
This commit is contained in:
parent
9da552c409
commit
b531376a62
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -84,6 +84,7 @@ TEST_CASE("esp_timer orders timers correctly", "[esp_timer]")
|
||||
|
||||
}
|
||||
fclose(stream);
|
||||
vTaskDelay(3); // wait for the esp_timer task to delete all timers
|
||||
}
|
||||
|
||||
static const int test_time_sec = 10;
|
||||
@ -160,6 +161,7 @@ TEST_CASE("esp_timer produces correct delay", "[esp_timer]")
|
||||
TEST_ESP_OK( esp_timer_dump(stdout) );
|
||||
|
||||
esp_timer_delete(timer1);
|
||||
vTaskDelay(3); // wait for the esp_timer task to delete all timers
|
||||
}
|
||||
|
||||
// no, we can't make this a const size_t (§6.7.5.2)
|
||||
@ -218,6 +220,7 @@ TEST_CASE("periodic esp_timer produces correct delays", "[esp_timer]")
|
||||
|
||||
TEST_ESP_OK( esp_timer_delete(timer1) );
|
||||
vSemaphoreDelete(args.done);
|
||||
vTaskDelay(3); // wait for the esp_timer task to delete all timers
|
||||
}
|
||||
#undef NUM_INTERVALS
|
||||
|
||||
@ -342,6 +345,7 @@ TEST_CASE("multiple timers are ordered correctly", "[esp_timer]")
|
||||
TEST_ESP_OK( esp_timer_delete(args1.timer) );
|
||||
TEST_ESP_OK( esp_timer_delete(args2.timer) );
|
||||
TEST_ESP_OK( esp_timer_delete(args3.timer) );
|
||||
vTaskDelay(3); // wait for the esp_timer task to delete all timers
|
||||
}
|
||||
#undef N
|
||||
|
||||
@ -384,6 +388,7 @@ TEST_CASE("esp_timer for very short intervals", "[esp_timer]")
|
||||
vSemaphoreDelete(semaphore);
|
||||
TEST_ESP_OK(esp_timer_delete(timer1));
|
||||
TEST_ESP_OK(esp_timer_delete(timer2));
|
||||
vTaskDelay(3); // wait for the esp_timer task to delete all timers
|
||||
}
|
||||
|
||||
TEST_CASE("esp_timer_get_time call takes less than 1us", "[esp_timer]")
|
||||
@ -633,6 +638,7 @@ TEST_CASE("after esp_timer_impl_advance, timers run when expected", "[esp_timer]
|
||||
|
||||
ref_clock_deinit();
|
||||
TEST_ESP_OK(esp_timer_delete(timer));
|
||||
vTaskDelay(3); // wait for the esp_timer task to delete all timers
|
||||
}
|
||||
|
||||
static esp_timer_handle_t timer1;
|
||||
@ -670,6 +676,7 @@ TEST_CASE("Can start/stop timer from ISR context", "[esp_timer]")
|
||||
esp_deregister_freertos_tick_hook(test_tick_hook);
|
||||
TEST_ESP_OK( esp_timer_delete(timer1) );
|
||||
vSemaphoreDelete(sem);
|
||||
vTaskDelay(3); // wait for the esp_timer task to delete all timers
|
||||
}
|
||||
|
||||
#if !defined(CONFIG_FREERTOS_UNICORE) && SOC_DPORT_WORKAROUND
|
||||
@ -861,6 +868,7 @@ TEST_CASE("Test a latency between a call of callback and real event", "[esp_time
|
||||
TEST_ESP_OK(esp_timer_dump(stdout));
|
||||
TEST_ESP_OK(esp_timer_stop(periodic_timer));
|
||||
TEST_ESP_OK(esp_timer_delete(periodic_timer));
|
||||
vTaskDelay(3); // wait for the esp_timer task to delete all timers
|
||||
}
|
||||
|
||||
static void test_timer_triggered(void* timer1_trig)
|
||||
@ -909,6 +917,7 @@ TEST_CASE("periodic esp_timer can be restarted", "[esp_timer]")
|
||||
|
||||
TEST_ESP_OK( esp_timer_stop(timer1) );
|
||||
TEST_ESP_OK( esp_timer_delete(timer1) );
|
||||
vTaskDelay(3); // wait for the esp_timer task to delete all timers
|
||||
}
|
||||
|
||||
TEST_CASE("one-shot esp_timer can be restarted", "[esp_timer]")
|
||||
@ -943,6 +952,7 @@ TEST_CASE("one-shot esp_timer can be restarted", "[esp_timer]")
|
||||
TEST_ASSERT_EQUAL(0, timer_trig);
|
||||
|
||||
TEST_ESP_OK( esp_timer_delete(timer1) );
|
||||
vTaskDelay(3); // wait for the esp_timer task to delete all timers
|
||||
}
|
||||
|
||||
|
||||
@ -1002,6 +1012,7 @@ TEST_CASE("Test ESP_TIMER_ISR dispatch method", "[esp_timer]")
|
||||
TEST_ESP_OK(esp_timer_delete(periodic_timer2));
|
||||
printf("timers deleted\n");
|
||||
TEST_ESP_OK(esp_timer_dump(stdout));
|
||||
vTaskDelay(3); // wait for the esp_timer task to delete all timers
|
||||
}
|
||||
|
||||
static void dump_task(void* arg)
|
||||
@ -1062,6 +1073,7 @@ TEST_CASE("Test ESP_TIMER_ISR dispatch method is not blocked", "[esp_timer]")
|
||||
TEST_ESP_OK(esp_timer_delete(periodic_timer1));
|
||||
TEST_ESP_OK(esp_timer_delete(periodic_timer2));
|
||||
printf("timer deleted\n");
|
||||
vTaskDelay(3); // wait for the esp_timer task to delete all timers
|
||||
}
|
||||
|
||||
static void isr_callback1(void* arg)
|
||||
@ -1121,6 +1133,7 @@ TEST_CASE("Test ESP_TIMER_ISR, stop API cleans alarm reg if TASK timer list is e
|
||||
TEST_ESP_OK(esp_timer_delete(timer2));
|
||||
vSemaphoreDelete(done);
|
||||
printf("timer deleted\n");
|
||||
vTaskDelay(3); // wait for the esp_timer task to delete all timers
|
||||
}
|
||||
|
||||
static void isr_callback2(void* arg)
|
||||
@ -1176,6 +1189,7 @@ TEST_CASE("Test ESP_TIMER_ISR, stop API cleans alarm reg if ISR timer list is em
|
||||
TEST_ESP_OK(esp_timer_delete(timer2));
|
||||
vSemaphoreDelete(done);
|
||||
printf("timer deleted\n");
|
||||
vTaskDelay(3); // wait for the esp_timer task to delete all timers
|
||||
}
|
||||
|
||||
#ifndef CONFIG_FREERTOS_UNICORE
|
||||
@ -1214,6 +1228,7 @@ TEST_CASE("Test that CPU1 can handle esp_timer ISR even when CPU0 is blocked", "
|
||||
TEST_ESP_OK(esp_timer_dump(stdout));
|
||||
TEST_ASSERT_INT_WITHIN(3, 10, data);
|
||||
TEST_ESP_OK(esp_timer_delete(timer));
|
||||
vTaskDelay(3); // wait for the esp_timer task to delete all timers
|
||||
}
|
||||
#endif // not CONFIG_FREERTOS_UNICORE
|
||||
|
||||
@ -1283,6 +1298,7 @@ TEST_CASE("Test ISR dispatch callbacks are not blocked even if TASK callbacks ta
|
||||
TEST_ESP_OK(esp_timer_stop(isr_timer_handle));
|
||||
TEST_ESP_OK(esp_timer_delete(task_timer_handle));
|
||||
TEST_ESP_OK(esp_timer_delete(isr_timer_handle));
|
||||
vTaskDelay(3); // wait for the esp_timer task to delete all timers
|
||||
}
|
||||
|
||||
#endif // CONFIG_ESP_TIMER_SUPPORTS_ISR_DISPATCH_METHOD
|
||||
|
@ -8,6 +8,8 @@
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/param.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "esp_timer.h"
|
||||
#include "unity.h"
|
||||
#include "esp_rom_sys.h"
|
||||
@ -35,22 +37,26 @@ TEST_CASE("Test the periodic timer does not handle lost events during light slee
|
||||
|
||||
int period_cb_ms = 10;
|
||||
int interval_ms = 50;
|
||||
TEST_ESP_OK(esp_timer_start_periodic(periodic_timer, period_cb_ms * 1000));
|
||||
TEST_ESP_OK(esp_sleep_enable_timer_wakeup(interval_ms * 1000));
|
||||
printf("Run light sleep\n");
|
||||
printf("count_calls should be around = %d\n", interval_ms / period_cb_ms);
|
||||
TEST_ESP_OK(esp_sleep_enable_timer_wakeup(interval_ms * 1000));
|
||||
TEST_ESP_OK(esp_timer_start_periodic(periodic_timer, period_cb_ms * 1000));
|
||||
for (int i = 0; i < 3; i++) {
|
||||
count_calls = 0;
|
||||
TEST_ESP_OK(esp_light_sleep_start());
|
||||
do {
|
||||
count_calls = 0;
|
||||
} while (esp_light_sleep_start() != ESP_OK);
|
||||
esp_rom_delay_us(interval_ms * 1000);
|
||||
printf("count_calls = %d\n", count_calls);
|
||||
TEST_ASSERT_INT_WITHIN(2, interval_ms / period_cb_ms, count_calls);
|
||||
vTaskDelay(1); // wait for the esp_timer task to start on another core processing period_timer after sleep
|
||||
int saved_count_calls = count_calls;
|
||||
printf("count_calls = %d\n", saved_count_calls);
|
||||
TEST_ESP_OK(esp_timer_dump(stdout));
|
||||
TEST_ASSERT_INT_WITHIN(2, interval_ms / period_cb_ms, saved_count_calls);
|
||||
}
|
||||
TEST_ESP_OK(esp_timer_stop(periodic_timer));
|
||||
// times_skipped is about 12 (4 from each sleep time).
|
||||
TEST_ESP_OK(esp_timer_dump(stdout));
|
||||
TEST_ESP_OK(esp_timer_delete(periodic_timer));
|
||||
vTaskDelay(3); // wait for the esp_timer task to delete all timers
|
||||
}
|
||||
|
||||
#endif //#!TEMPORARY_DISABLED_FOR_TARGETS(ESP32P4)
|
||||
|
Loading…
Reference in New Issue
Block a user