FastLED 3.10.8
Loading...
Searching...
No Matches

◆ pwm_isr_handler()

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

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

125 {
126 (void)user_data;
127 // The ISR is attached only after setPwmFrequency() has created the
128 // state, so read the singleton directly instead of republishing g_state.
130
131 for (u8 i = 0; i < MAX_PWM_CHANNELS; i++) {
132 PwmPinState& ch = st.channels[i];
133 if (ch.pin < 0 || ch.backend != PwmBackend::IsrSoftware) continue;
134
135 ch.tick_counter++;
136
137 // Turn LOW at duty cycle boundary
138 if (ch.tick_counter == ch.high_ticks && ch.pin_state) {
140 ch.pin_state = false;
141 }
142 // Start new period: reset counter, turn HIGH if duty > 0
143 else if (ch.tick_counter >= ch.period_ticks) {
144 ch.tick_counter = 0;
145 if (ch.high_ticks > 0) {
147 ch.pin_state = true;
148 }
149 }
150 }
151}
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: