|
ELEC-C7222
Libraries for ELEC C7222 Course Work
|
Thread-safe event wrapper for button IRQ notifications. More...
#include <button_event.hpp>

Public Member Functions | |
| void | SetEvents (std::uint32_t new_events) |
| Set the event bitmask and notify waiters. | |
| bool | GetEvents (std::uint32_t timeout_ms, std::uint32_t &events_out) |
| Wait for events with a timeout. | |
Thread-safe event wrapper for button IRQ notifications.
Synchronization model and purpose:
std::mutex to protect the shared event state (events_ and event_ready_) from concurrent access by the ISR-dispatcher path and the consumer task.std::condition_variable to block the consumer task efficiently until new events arrive, with optional timeout.event_ready_ is the condition predicate that prevents missed wake-ups (the consumer re-checks the flag after waking).GetEvents() via std::unique_lock, ensuring the mutex is released on all exit paths.Intended usage:
SetEvents() is called by the IRQ dispatcher task or timer callback when a GPIO interrupt occurs.GetEvents() is called by a consumer task that wants to wait for the next event without polling. | bool c7222::ButtonEvent::GetEvents | ( | std::uint32_t | timeout_ms, |
| std::uint32_t & | events_out | ||
| ) |
Wait for events with a timeout.
| timeout_ms | Maximum time to wait in milliseconds. |
| events_out | Filled with event bitmask on success. |

| void c7222::ButtonEvent::SetEvents | ( | std::uint32_t | new_events | ) |
Set the event bitmask and notify waiters.
