@@ -67,7 +67,7 @@ bool ledcAttach(uint8_t pin, uint32_t freq, uint8_t resolution)
67
67
68
68
perimanSetBusDeinit (ESP32_BUS_TYPE_LEDC , ledcDetachBus );
69
69
ledc_channel_handle_t * bus = (ledc_channel_handle_t * )perimanGetPinBus (pin , ESP32_BUS_TYPE_LEDC );
70
- if (bus != NULL && !perimanSetPinBus (pin , ESP32_BUS_TYPE_INIT , NULL )){
70
+ if (bus != NULL && !perimanClearPinBus (pin )){
71
71
return false;
72
72
}
73
73
@@ -110,7 +110,7 @@ bool ledcAttach(uint8_t pin, uint32_t freq, uint8_t resolution)
110
110
#endif
111
111
ledc_handle .used_channels |= 1UL << channel ;
112
112
113
- if (!perimanSetPinBus (pin , ESP32_BUS_TYPE_LEDC , (void * )handle )){
113
+ if (!perimanSetPinBus (pin , ESP32_BUS_TYPE_LEDC , (void * )handle , group , channel )){
114
114
ledcDetachBus ((void * )handle );
115
115
return false;
116
116
}
@@ -216,7 +216,7 @@ bool ledcDetach(uint8_t pin)
216
216
ledc_channel_handle_t * bus = (ledc_channel_handle_t * )perimanGetPinBus (pin , ESP32_BUS_TYPE_LEDC );
217
217
if (bus != NULL ){
218
218
// will call ledcDetachBus
219
- return perimanSetPinBus (pin , ESP32_BUS_TYPE_INIT , NULL );
219
+ return perimanClearPinBus (pin );
220
220
} else {
221
221
log_e ("pin %u is not attached to LEDC" , pin );
222
222
}
@@ -360,7 +360,7 @@ void analogWrite(uint8_t pin, int value) {
360
360
// Use ledc hardware for internal pins
361
361
if (pin < SOC_GPIO_PIN_COUNT ) {
362
362
ledc_channel_handle_t * bus = (ledc_channel_handle_t * )perimanGetPinBus (pin , ESP32_BUS_TYPE_LEDC );
363
- if (bus == NULL && perimanSetPinBus (pin , ESP32_BUS_TYPE_INIT , NULL )){
363
+ if (bus == NULL && perimanClearPinBus (pin )){
364
364
if (ledcAttach (pin , analog_frequency , analog_resolution ) == 0 ){
365
365
log_e ("analogWrite setup failed (freq = %u, resolution = %u). Try setting different resolution or frequency" );
366
366
return ;
0 commit comments