File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -27,11 +27,13 @@ static bool sigmaDeltaDetachBus(void * bus){
2727bool sigmaDeltaAttach (uint8_t pin , uint32_t freq ) //freq 1220-312500
2828{
2929 perimanSetBusDeinit (ESP32_BUS_TYPE_SIGMADELTA , sigmaDeltaDetachBus );
30- sdm_channel_handle_t bus = (sdm_channel_handle_t )perimanGetPinBus (pin , ESP32_BUS_TYPE_SIGMADELTA );
31- if (bus != NULL && !perimanClearPinBus (pin )){
30+ sdm_channel_handle_t bus = NULL ;
31+ // pin may be previously attached to other peripheral -> detach it.
32+ // if attached to sigmaDelta, detach it and set the new frequency
33+ if (perimanGetPinBusType (pin ) != ESP32_BUS_TYPE_INIT && !perimanClearPinBus (pin )){
34+ log_e ("Pin %u could not be detached." , pin );
3235 return false;
3336 }
34- bus = NULL ;
3537 sdm_config_t config = {
3638 .gpio_num = (int )pin ,
3739 .clk_src = SDM_CLK_SRC_DEFAULT ,
You can’t perform that action at this time.
0 commit comments