gptimer: fix race condition between start and stop

Added state transition in gptimer_start/stop functions.
So that it's not possible to make a stopped timer continue to run
because of race condition.
This commit is contained in:
morris
2023-03-06 13:32:35 +08:00
parent ed97d230c8
commit 2d52334e5d
11 changed files with 153 additions and 74 deletions

View File

@@ -89,12 +89,12 @@ static void test_gpio_intr_callback(void *args)
// put the simulation code in the IRAM to avoid cache miss
NOINLINE_ATTR IRAM_ATTR static void test_gpio_simulate_glitch_pulse(void)
{
static portMUX_TYPE g_lock = portMUX_INITIALIZER_UNLOCKED;
static portMUX_TYPE s_lock = portMUX_INITIALIZER_UNLOCKED;
// the following code is used to generate a short glitch pulse
// around 20ns @CPU160MHz, 40ns @CPU96MHz
// pull high for 4 CPU cycles, to ensure the short pulse can be sampled by GPIO
// we don't want any preemption to happen during the glitch signal generation
portENTER_CRITICAL(&g_lock);
portENTER_CRITICAL(&s_lock);
asm volatile(
"csrrsi zero, %0, 0x1\n"
"csrrsi zero, %0, 0x1\n"
@@ -103,7 +103,7 @@ NOINLINE_ATTR IRAM_ATTR static void test_gpio_simulate_glitch_pulse(void)
"csrrci zero, %0, 0x1"
:: "i"(CSR_GPIO_OUT_USER)
);
portEXIT_CRITICAL(&g_lock);
portEXIT_CRITICAL(&s_lock);
}
TEST_CASE("GPIO flex glitch filter enable/disable", "[gpio_filter]")