Ensure ISR timer is running (lazy init)
| 173 | |
| 174 | // Ensure ISR timer is running (lazy init) |
| 175 | int ensureIsrActive() { |
| 176 | PwmStateData& st = state(); |
| 177 | if (st.isr_active) return 0; |
| 178 | |
| 179 | fl::isr::config cfg; |
| 180 | cfg.handler = pwm_isr_handler; |
| 181 | cfg.frequency_hz = ISR_FREQUENCY_HZ; |
| 182 | cfg.priority = fl::isr::ISR_PRIORITY_MEDIUM; |
| 183 | cfg.flags = fl::isr::ISR_FLAG_IRAM_SAFE; |
| 184 | |
| 185 | int result = fl::isr::attach_timer_handler(cfg, &st.isr_handle); |
| 186 | if (result != 0) { |
| 187 | FL_WARN("PWM: ISR attach failed: " << fl::isr::get_error_string(result)); |
| 188 | return result; |
| 189 | } |
| 190 | st.isr_active = true; |
| 191 | return 0; |
| 192 | } |
| 193 | |
| 194 | // Shutdown ISR if no ISR-backend channels remain |
| 195 | void maybeShutdownIsr() { |
no test coverage detected