Class pn532::esp32::irq_assert
Defined in File irq_assert.hpp
Class Documentation
-
class irq_assert
Semaphore-like class which responds to a ESP32 GPIO interrupt. You can invoke operator()() of this class, and the current task will stay suspended until the selected interrupt triggers on the given GPIO. Internally, it uses the ESP32’s interrupt system, so that the CPU is effectively available for other tasks.
Note
This class currently only supports one type of trigger.
Enforced move semantics
-
irq_assert(irq_assert&&) noexcept
-
irq_assert &operator=(irq_assert&&) noexcept
-
irq_assert(irq_assert const&) noexcept = delete
-
irq_assert &operator=(irq_assert const&) noexcept = delete
Public Functions
-
irq_assert()
Default constructor: always asserts
true
when calling operator()().
-
explicit irq_assert(bool manage_isr_service, gpio_num_t pin, gpio_int_type_t interrupt_type = GPIO_INTR_NEGEDGE)
Constructs a new class that is able to wait for a GPIO interrupt.
- Parameters:
manage_isr_service – If true, this class will call
gpio_install_isr_service
and the correspondinggpio_uninstall_isr_service
upon construction and destruction, respectively.pin – GPIO pin where to listen for an interrupt.
interrupt_type – Type of interrupt to receive, by default negative edge.
-
gpio_num_t pin() const
The pin on which this instance has set up an interrupt.
- Returns:
A pin number or
GPIO_NUM_NC
, if this instance was default-constructed.
-
bool operator()(mlab::ms timeout)
Hangs until the interrupt triggers. Waits at most
timeout
and returns true if and only if pin asserts the interrupt.Note
Always asserts true if irq_assert was default constructed.
- Parameters:
timeout – Maximum timeout before returning false.
- Returns:
True if the interrupt specified at runtime has been triggered on the given pin.
-
~irq_assert()
Releases all resources, and, if specified, calls
gpio_uninstall_isr_service
.
-
irq_assert(irq_assert&&) noexcept