FastLED 3.10.9
Loading...
Searching...
No Matches

◆ pwm_isr_handler()

void FL_IRAM fl::pwm_state::pwm_isr_handler ( void * user_data)

Definition at line 126 of file pin.cpp.hpp.

126 {
127 (void)user_data;
128 // The ISR is attached only after setPwmFrequency() has created the
129 // state, so read the singleton directly instead of republishing g_state.
131
132 for (u8 i = 0; i < MAX_PWM_CHANNELS; i++) {
133 PwmPinState& ch = st.channels[i];
134 if (ch.pin < 0 || ch.backend != PwmBackend::IsrSoftware) continue;
135
136 ch.tick_counter++;
137
138 // Turn LOW at duty cycle boundary
139 if (ch.tick_counter == ch.high_ticks && ch.pin_state) {
141 ch.pin_state = false;
142 }
143 // Start new period: reset counter, turn HIGH if duty > 0
144 else if (ch.tick_counter >= ch.period_ticks) {
145 ch.tick_counter = 0;
146 if (ch.high_ticks > 0) {
148 ch.pin_state = true;
149 }
150 }
151 }
152}
static T & instance() FL_NO_EXCEPT
Definition singleton.h:41
constexpr u8 MAX_PWM_CHANNELS
Definition pin.cpp.hpp:78
unsigned char u8
Definition stdint.h:131
@ Low
Logic low (0V / GND)
Definition pin.h:51
@ High
Logic high (3.3V / 5V, platform-dependent)
Definition pin.h:52
void digitalWrite(int pin, PinValue val) FL_NO_EXCEPT
Write digital value to pin.
Definition pin.cpp.hpp:51
PwmPinState channels[MAX_PWM_CHANNELS]
Definition pin.cpp.hpp:100

References fl::pwm_state::PwmPinState::backend, fl::pwm_state::PwmStateData::channels, fl::digitalWrite(), FL_IRAM, fl::FL_NO_EXCEPT, fl::High, fl::pwm_state::PwmPinState::high_ticks, fl::Singleton< T, N >::instance(), IsrSoftware, fl::Low, MAX_PWM_CHANNELS, fl::pwm_state::PwmPinState::period_ticks, fl::pwm_state::PwmPinState::pin, fl::pwm_state::PwmPinState::pin_state, and fl::pwm_state::PwmPinState::tick_counter.

Referenced by ensureIsrActive().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: