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

Function pwm_isr_handler

src/fl/system/pin.cpp.hpp:114–138  ·  view source on GitHub ↗

ISR handler — services only ISR-backend entries

Source from the content-addressed store, hash-verified

112
113// ISR handler — services only ISR-backend entries
114void FL_IRAM pwm_isr_handler(void* user_data) {
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) {
126 fl::digitalWrite(ch.pin, fl::PinValue::Low);
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) {
133 fl::digitalWrite(ch.pin, fl::PinValue::High);
134 ch.pin_state = true;
135 }
136 }
137 }
138}
139
140// Find channel by pin number
141PwmPinState* findByPin(int pin) {

Callers

nothing calls this directly

Calls 1

digitalWriteFunction · 0.70

Tested by

no test coverage detected