esp-idf/components/driver/gptimer
2024-04-09 17:33:26 +08:00
..
include/driver feat(gptimer): support set interrupt priority 2023-08-04 10:20:07 +08:00
gptimer_etm.c etm: update etm event task new API 2022-12-07 15:43:20 +08:00
gptimer_priv.c gptimer: fix race condition between start and stop 2023-03-10 23:27:29 +08:00
gptimer_priv.h feat(gptimer): support set interrupt priority 2023-08-04 10:20:07 +08:00
gptimer.c feat(gptimer): check the alarm config is not in flash 2024-04-09 17:33:26 +08:00
Kconfig.gptimer fix(gptimer): hal function placement under wrong condition 2023-08-14 02:31:16 +00:00
linker.lf fix(gptimer): hal function placement under wrong condition 2023-08-14 02:31:16 +00:00
README.md gptimer: fix race condition between start and stop 2023-03-10 23:27:29 +08:00

GPTimer Driver Design

State Transition

State transition is achieved by using the primitives provided by <stdatomic.h>.

Other functions won't change the driver state. The functions above labeled with * are allowed to be used in the interrupt context.

Concurrency

There might be race conditions when the user calls the APIs from a thread and interrupt at the same time. e.g. a Task is just running the gptimer_start, and suddenly an interrupt occurs, where the user calls gptimer_stop for the same timer handle. Which is possible to make a "stopped" timer continue to run if the interrupt is returned before the Task.

By introducing a "middle" state like run_wait and enable_wait, we make sure that the timer is in a safe state before we start/stop it. And if the state is invalid, it can return an error code to the user.