mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-10 04:43:33 +00:00
Add test for local interrupts, fix int disable code
This commit is contained in:
@@ -138,6 +138,62 @@ static void timer_test(int flags) {
|
||||
esp_intr_free(inth[3]);
|
||||
}
|
||||
|
||||
static volatile int int_timer_ctr;
|
||||
|
||||
|
||||
void int_timer_handler(void *arg) {
|
||||
xthal_set_ccompare(1, xthal_get_ccount()+8000000);
|
||||
int_timer_ctr++;
|
||||
}
|
||||
|
||||
void local_timer_test()
|
||||
{
|
||||
intr_handle_t ih;
|
||||
esp_err_t r;
|
||||
r=esp_intr_alloc(ETS_INTERNAL_TIMER1_INTR_SOURCE, 0, int_timer_handler, NULL, &ih);
|
||||
TEST_ASSERT(r==ESP_OK);
|
||||
printf("Int timer 1 intno %d\n", esp_intr_get_intno(ih));
|
||||
xthal_set_ccompare(1, xthal_get_ccount()+8000000);
|
||||
int_timer_ctr=0;
|
||||
vTaskDelay(1000 / portTICK_RATE_MS);
|
||||
printf("Timer val after 1 sec: %d\n", int_timer_ctr);
|
||||
TEST_ASSERT(int_timer_ctr!=0);
|
||||
printf("Disabling int\n");
|
||||
esp_intr_disable(ih);
|
||||
int_timer_ctr=0;
|
||||
vTaskDelay(1000 / portTICK_RATE_MS);
|
||||
printf("Timer val after 1 sec: %d\n", int_timer_ctr);
|
||||
TEST_ASSERT(int_timer_ctr==0);
|
||||
printf("Re-enabling\n");
|
||||
esp_intr_enable(ih);
|
||||
vTaskDelay(1000 / portTICK_RATE_MS);
|
||||
printf("Timer val after 1 sec: %d\n", int_timer_ctr);
|
||||
TEST_ASSERT(int_timer_ctr!=0);
|
||||
|
||||
printf("Free int, re-alloc disabled\n");
|
||||
r=esp_intr_free(ih);
|
||||
TEST_ASSERT(r==ESP_OK);
|
||||
r=esp_intr_alloc(ETS_INTERNAL_TIMER1_INTR_SOURCE, ESP_INTR_FLAG_INTRDISABLED, int_timer_handler, NULL, &ih);
|
||||
TEST_ASSERT(r==ESP_OK);
|
||||
int_timer_ctr=0;
|
||||
vTaskDelay(1000 / portTICK_RATE_MS);
|
||||
printf("Timer val after 1 sec: %d\n", int_timer_ctr);
|
||||
TEST_ASSERT(int_timer_ctr==0);
|
||||
printf("Re-enabling\n");
|
||||
esp_intr_enable(ih);
|
||||
vTaskDelay(1000 / portTICK_RATE_MS);
|
||||
printf("Timer val after 1 sec: %d\n", int_timer_ctr);
|
||||
TEST_ASSERT(int_timer_ctr!=0);
|
||||
r=esp_intr_free(ih);
|
||||
TEST_ASSERT(r==ESP_OK);
|
||||
printf("Done.\n");
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("Intr_alloc test, CPU-local int source", "[esp32]")
|
||||
{
|
||||
local_timer_test();
|
||||
}
|
||||
|
||||
TEST_CASE("Intr_alloc test, private ints", "[esp32]")
|
||||
{
|
||||
|
Reference in New Issue
Block a user