ELEC-C7222
Libraries for ELEC C7222 Course Work
Loading...
Searching...
No Matches
button_event.hpp
Go to the documentation of this file.
1
5#ifndef ELEC_C7222_EXAMPLES_BUTTON_EVENT_HPP
6#define ELEC_C7222_EXAMPLES_BUTTON_EVENT_HPP
7
8#include <condition_variable>
9#include <cstdint>
10#include <mutex>
11
12namespace c7222 {
13
41 public:
45 void SetEvents(std::uint32_t new_events);
46
54 bool GetEvents(std::uint32_t timeout_ms, std::uint32_t& events_out);
55
56 private:
58 std::uint32_t events_{0};
60 bool event_ready_{false};
62 std::mutex mutex_;
64 std::condition_variable cv_;
65};
66
67} // namespace c7222
68
69#endif // ELEC_C7222_EXAMPLES_BUTTON_EVENT_HPP
Thread-safe event wrapper for button IRQ notifications.
Definition button_event.hpp:40
void SetEvents(std::uint32_t new_events)
Set the event bitmask and notify waiters.
Definition button_event.cpp:8
bool GetEvents(std::uint32_t timeout_ms, std::uint32_t &events_out)
Wait for events with a timeout.
Definition button_event.cpp:17
C7222 course abstractions namespace.
Definition ble.hpp:20