FastLED 3.9.15
Loading...
Searching...
No Matches

◆ pwm_isr_handler()

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

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

114 {
115 (void)user_data;
116 PwmStateData& st = state();
117
118 for (u8 i = 0; i < MAX_PWM_CHANNELS; i++) {
119 PwmPinState& ch = st.channels[i];
120 if (ch.pin < 0 || ch.backend != PwmBackend::IsrSoftware) continue;
121
122 ch.tick_counter++;
123
124 // Turn LOW at duty cycle boundary
125 if (ch.tick_counter == ch.high_ticks && ch.pin_state) {
127 ch.pin_state = false;
128 }
129 // Start new period: reset counter, turn HIGH if duty > 0
130 else if (ch.tick_counter >= ch.period_ticks) {
131 ch.tick_counter = 0;
132 if (ch.high_ticks > 0) {
134 ch.pin_state = true;
135 }
136 }
137 }
138}
constexpr u8 MAX_PWM_CHANNELS
Definition pin.cpp.hpp:79
PwmStateData & state()
Definition pin.cpp.hpp:109
unsigned char u8
Definition stdint.h:131
@ Low
Logic low (0V / GND)
Definition pin.h:50
@ High
Logic high (3.3V / 5V, platform-dependent)
Definition pin.h:51
void digitalWrite(int pin, PinValue val)
Write digital value to pin.
Definition pin.cpp.hpp:51
PwmPinState channels[MAX_PWM_CHANNELS]
Definition pin.cpp.hpp:101

References fl::pwm_state::PwmPinState::backend, fl::pwm_state::PwmStateData::channels, fl::digitalWrite(), FL_IRAM, fl::High, fl::pwm_state::PwmPinState::high_ticks, IsrSoftware, fl::Low, MAX_PWM_CHANNELS, fl::pwm_state::PwmPinState::period_ticks, fl::pwm_state::PwmPinState::pin, fl::pwm_state::PwmPinState::pin_state, 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: