diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-07-26 11:23:36 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-07-26 11:23:36 +1000 |
| commit | f94be3db2f2bb6c1b359744cb915683095e4ee80 (patch) | |
| tree | 79d335db661720947c518a535bdde733fe669032 /src/drivers/gpios.cpp | |
| parent | d8194135bbaad97d1f3428a74c7fc54ba3f604ec (diff) | |
| download | tangara-fw-f94be3db2f2bb6c1b359744cb915683095e4ee80.tar.gz | |
make event queue go faster
Diffstat (limited to 'src/drivers/gpios.cpp')
| -rw-r--r-- | src/drivers/gpios.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/drivers/gpios.cpp b/src/drivers/gpios.cpp index 1d1f5281..f6293697 100644 --- a/src/drivers/gpios.cpp +++ b/src/drivers/gpios.cpp @@ -59,11 +59,8 @@ constexpr std::pair<uint8_t, uint8_t> unpack(uint16_t ba) { } void interrupt_isr(void* arg) { - Gpios* instance = reinterpret_cast<Gpios*>(arg); - auto listener = instance->listener(); - if (listener != nullptr) { - std::invoke(*listener); - } + SemaphoreHandle_t sem = reinterpret_cast<SemaphoreHandle_t>(arg); + xSemaphoreGive(sem); } auto Gpios::Create() -> Gpios* { @@ -79,7 +76,7 @@ auto Gpios::Create() -> Gpios* { Gpios::Gpios() : ports_(pack(kPortADefault, kPortBDefault)), inputs_(0), - listener_(nullptr) { + read_pending_(xSemaphoreCreateBinary()) { gpio_config_t config{ .pin_bit_mask = static_cast<uint64_t>(1) << GPIO_NUM_34, .mode = GPIO_MODE_INPUT, @@ -90,7 +87,6 @@ Gpios::Gpios() gpio_config(&config); gpio_install_isr_service(ESP_INTR_FLAG_LOWMED | ESP_INTR_FLAG_SHARED | ESP_INTR_FLAG_IRAM); - gpio_isr_handler_add(GPIO_NUM_34, &interrupt_isr, this); } Gpios::~Gpios() { @@ -145,4 +141,8 @@ auto Gpios::Read() -> bool { return true; } +auto Gpios::InstallReadPendingISR() -> void { + gpio_isr_handler_add(GPIO_NUM_34, &interrupt_isr, read_pending_); +} + } // namespace drivers |
