@@ -84,7 +84,7 @@ static bool find_free_timer(uint8_t speed_mode, uint8_t *timer_num) {
84
84
}
85
85
}
86
86
}
87
-
87
+
88
88
// Find first unused timer
89
89
for (uint8_t i = 0 ; i < SOC_LEDC_TIMER_NUM ; i ++ ) {
90
90
if (!(used_timers & (1 << i ))) {
@@ -100,7 +100,7 @@ static bool find_free_timer(uint8_t speed_mode, uint8_t *timer_num) {
100
100
// Helper function to remove a channel from a timer and clear timer if no channels are using it
101
101
static void remove_channel_from_timer (uint8_t speed_mode , uint8_t timer_num , uint8_t channel ) {
102
102
log_d ("Removing channel %u from timer %u in speed_mode %u" , channel , timer_num , speed_mode );
103
-
103
+
104
104
// Check if any other channels are using this timer
105
105
bool timer_in_use = false;
106
106
for (uint8_t i = 0 ; i < SOC_GPIO_PIN_COUNT ; i ++ ) {
@@ -110,8 +110,7 @@ static void remove_channel_from_timer(uint8_t speed_mode, uint8_t timer_num, uin
110
110
peripheral_bus_type_t type = perimanGetPinBusType (i );
111
111
if (type == ESP32_BUS_TYPE_LEDC ) {
112
112
ledc_channel_handle_t * bus = (ledc_channel_handle_t * )perimanGetPinBus (i , ESP32_BUS_TYPE_LEDC );
113
- if (bus != NULL && (bus -> channel / 8 ) == speed_mode &&
114
- bus -> timer_num == timer_num && bus -> channel != channel ) {
113
+ if (bus != NULL && (bus -> channel / 8 ) == speed_mode && bus -> timer_num == timer_num && bus -> channel != channel ) {
115
114
log_d ("Timer %u is still in use by channel %u" , timer_num , bus -> channel );
116
115
timer_in_use = true;
117
116
break ;
@@ -208,9 +207,9 @@ bool ledcAttachChannel(uint8_t pin, uint32_t freq, uint8_t resolution, uint8_t c
208
207
}
209
208
210
209
uint8_t group = (channel / 8 );
211
- uint8_t timer = 0 ;
210
+ uint8_t timer = 0 ;
212
211
bool channel_used = ledc_handle .used_channels & (1UL << channel );
213
-
212
+
214
213
if (channel_used ) {
215
214
log_i ("Channel %u is already set up, given frequency and resolution will be ignored" , channel );
216
215
if (ledc_set_pin (pin , group , channel % 8 ) != ESP_OK ) {
@@ -224,7 +223,7 @@ bool ledcAttachChannel(uint8_t pin, uint32_t freq, uint8_t resolution, uint8_t c
224
223
log_e ("No free timers available for speed mode %u" , group );
225
224
return false;
226
225
}
227
-
226
+
228
227
// Configure the timer if we're using a new one
229
228
ledc_timer_config_t ledc_timer ;
230
229
memset ((void * )& ledc_timer , 0 , sizeof (ledc_timer_config_t ));
0 commit comments