MCPcopy Create free account
hub / github.com/FastLED/FastLED / stub_attach_timer_handler

Function stub_attach_timer_handler

src/platforms/stub/isr_stub.hpp:275–317  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

273// =============================================================================
274
275inline int stub_attach_timer_handler(const isr_config_t& config, isr_handle_t* out_handle) FL_NOEXCEPT {
276 if (!config.handler) {
277 STUB_LOG("attachTimerHandler: handler is null");
278 return -1; // Invalid parameter
279 }
280
281 if (config.frequency_hz == 0) {
282 STUB_LOG("attachTimerHandler: frequency_hz is 0");
283 return -2; // Invalid frequency
284 }
285
286 // Allocate handle data
287 auto handle_owner = fl::make_unique<stub_isr_handle_data>();
288 auto* handle_data = handle_owner.get();
289 if (!handle_data) {
290 STUB_LOG("attachTimerHandler: failed to allocate handle data");
291 return -3; // Out of memory
292 }
293
294 handle_data->mIsTimer = true;
295 handle_data->mUserHandler = config.handler;
296 handle_data->mUserData = config.user_data;
297 handle_data->mFrequencyHz = config.frequency_hz;
298 handle_data->mIsOneShot = (config.flags & ISR_FLAG_ONE_SHOT) != 0;
299
300 // Add to global timer thread manager (unless manual tick mode)
301 if (!(config.flags & ISR_FLAG_MANUAL_TICK)) {
302 TimerThreadManager::instance().add_handler(handle_data);
303 }
304
305 // Release ownership - pointer is now managed by the C API (TimerThreadManager + out_handle)
306 handle_owner.release();
307
308 // Populate output handle
309 if (out_handle) {
310 out_handle->platform_handle = handle_data;
311 out_handle->handler = config.handler;
312 out_handle->user_data = config.user_data;
313 out_handle->platform_id = STUB_PLATFORM_ID;
314 }
315
316 return 0; // Success
317}
318
319inline int stub_attach_external_handler(u8 pin, const isr_config_t& config, isr_handle_t* out_handle) FL_NOEXCEPT {
320 (void)pin; // Unused in stub implementation

Callers 1

attach_timer_handlerFunction · 0.85

Calls 3

getMethod · 0.45
add_handlerMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected