FastLED 3.9.15
Loading...
Searching...
No Matches
handler.h
Go to the documentation of this file.
1
3
4#pragma once
5
8#include "fl/stl/stdint.h"
9#include "fl/stl/cstddef.h"
10#include "fl/stl/noexcept.h"
11
12namespace fl {
13namespace isr {
14
16typedef void (*handler_fn)(void* user_data);
17
19struct config {
20 handler_fn handler; // Handler function pointer
21 void* user_data; // User context (passed to handler)
22 u32 frequency_hz; // Timer frequency in Hz (0 = GPIO/external interrupt)
23 u8 priority; // Priority level (platform-dependent range)
24 u32 flags; // Platform-specific flags (see constants.h)
25
27 : handler(nullptr)
28 , user_data(nullptr)
29 , frequency_hz(0)
31 , flags(0)
32 {}
33};
34
36struct handle {
37 void* platform_handle; // Platform-specific handle
38 handler_fn handler; // Handler function (for validation)
39 void* user_data; // User data (for validation)
40 u8 platform_id; // Platform identifier (for runtime checks)
41
43 : platform_handle(nullptr)
44 , handler(nullptr)
45 , user_data(nullptr)
46 , platform_id(0)
47 {}
48
49 bool is_valid() const { return platform_handle != nullptr; }
50};
51
52// Backward-compatible type aliases
56
58int attach_timer_handler(const config& cfg, handle* out_handle = nullptr);
59
61int attach_external_handler(u8 pin, const config& cfg, handle* out_handle = nullptr);
62
65
68
71
73bool is_handler_enabled(const handle& h);
74
76const char* get_error_string(int error_code);
77
79const char* get_platform_name();
80
83
86
89
91bool requires_assembly_handler(u8 priority);
92
93} // namespace isr
94} // namespace fl
ISR priority and flag constants.
u32 get_max_timer_frequency()
Get the maximum timer frequency supported by this platform.
int detach_handler(handle &h)
Detach an ISR handler.
bool is_handler_enabled(const handle &h)
Query if an ISR is currently enabled.
void(* handler_fn)(void *user_data)
ISR handler function signature.
Definition handler.h:16
int disable_handler(handle &h)
Disable an ISR temporarily (without detaching).
u32 get_min_timer_frequency()
Get the minimum timer frequency supported by this platform.
int enable_handler(handle &h)
Enable an ISR (after temporary disable).
int attach_timer_handler(const config &cfg, handle *out_handle)
Attach a timer-based ISR handler.
handler_fn isr_handler_t
Definition handler.h:53
u8 get_max_priority()
Get the maximum priority level supported by this platform.
const char * get_error_string(int error_code)
Get platform-specific error description.
int attach_external_handler(u8 pin, const config &cfg, handle *out_handle)
Attach an external interrupt handler (GPIO-based).
config isr_config_t
Definition handler.h:54
constexpr u8 ISR_PRIORITY_DEFAULT
Definition constants.h:14
handle isr_handle_t
Definition handler.h:55
const char * get_platform_name()
Get the platform name.
bool requires_assembly_handler(u8 priority)
Check if assembly is required for a given priority level.
unsigned char u8
Definition stdint.h:131
Base definition for an LED controller.
Definition crgb.hpp:179
#define FL_NOEXCEPT
handler_fn handler
Definition handler.h:20
void * user_data
Definition handler.h:21
config() FL_NOEXCEPT
Definition handler.h:26
Configuration for ISR attachment.
Definition handler.h:19
bool is_valid() const
Definition handler.h:49
handler_fn handler
Definition handler.h:38
handle() FL_NOEXCEPT
Definition handler.h:42
void * platform_handle
Definition handler.h:37
void * user_data
Definition handler.h:39
Opaque handle to an attached ISR.
Definition handler.h:36