Logo Pico-Framework A web-first embedded framework for C++
Loading...
Searching...
No Matches
Notification.h
Go to the documentation of this file.
1#pragma once
2#include <stdint.h>
4
5// * @param userCode User-defined notification code
6
10enum class NotificationKind : uint8_t {
11 System,
12 User
13};
14
31
33 "Too many NotificationKind values for FreeRTOS notification slots.");
34
40
41 union {
43 uint8_t user_code;
44 };
45
51
58
64 Notification(uint8_t userCode) : kind(NotificationKind::User), user_code(userCode) {}
65
73 uint8_t code() const {
75 ? static_cast<uint8_t>(system)
76 : user_code;
77 }
78};
79
88template<typename Enum>
89inline constexpr uint32_t eventMask(Enum e) {
90 return 1u << static_cast<uint32_t>(static_cast<std::underlying_type_t<Enum>>(e));
91}
92
93
94// Multi-value variadic overload
95template<typename Enum, typename... Rest>
96inline constexpr uint32_t eventMask(Enum first, Rest... rest) {
97 return eventMask(first) | eventMask(rest...);
98}
99
#define configTASK_NOTIFICATION_ARRAY_ENTRIES
constexpr uint32_t eventMask(Enum e)
Helper function to create an event mask from an enum value.
SystemNotification
System-defined notification types reserved by the framework.
NotificationKind
Identifies the source of a notification.
A tagged union representing either a system or user-defined notification.
Notification()
Default constructor initializes to a system notification of None.
SystemNotification system
NotificationKind kind
uint8_t user_code
uint8_t code() const
Get the notification code.
Notification(uint8_t userCode)
Construct a Notification with a user-defined code.
Notification(SystemNotification s)
Construct a Notification with a specific system notification type.