@@ -84,7 +84,7 @@ static bool find_free_timer(uint8_t speed_mode, uint8_t *timer_num) {
8484 }
8585 }
8686 }
87-
87+
8888 // Find first unused timer
8989 for (uint8_t i = 0 ; i < SOC_LEDC_TIMER_NUM ; i ++ ) {
9090 if (!(used_timers & (1 << i ))) {
@@ -100,7 +100,7 @@ static bool find_free_timer(uint8_t speed_mode, uint8_t *timer_num) {
100100// Helper function to remove a channel from a timer and clear timer if no channels are using it
101101static void remove_channel_from_timer (uint8_t speed_mode , uint8_t timer_num , uint8_t channel ) {
102102 log_d ("Removing channel %u from timer %u in speed_mode %u" , channel , timer_num , speed_mode );
103-
103+
104104 // Check if any other channels are using this timer
105105 bool timer_in_use = false;
106106 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
110110 peripheral_bus_type_t type = perimanGetPinBusType (i );
111111 if (type == ESP32_BUS_TYPE_LEDC ) {
112112 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 ) {
115114 log_d ("Timer %u is still in use by channel %u" , timer_num , bus -> channel );
116115 timer_in_use = true;
117116 break ;
@@ -208,9 +207,9 @@ bool ledcAttachChannel(uint8_t pin, uint32_t freq, uint8_t resolution, uint8_t c
208207 }
209208
210209 uint8_t group = (channel / 8 );
211- uint8_t timer = 0 ;
210+ uint8_t timer = 0 ;
212211 bool channel_used = ledc_handle .used_channels & (1UL << channel );
213-
212+
214213 if (channel_used ) {
215214 log_i ("Channel %u is already set up, given frequency and resolution will be ignored" , channel );
216215 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
224223 log_e ("No free timers available for speed mode %u" , group );
225224 return false;
226225 }
227-
226+
228227 // Configure the timer if we're using a new one
229228 ledc_timer_config_t ledc_timer ;
230229 memset ((void * )& ledc_timer , 0 , sizeof (ledc_timer_config_t ));
0 commit comments