Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes sigmaDeltaAttach() when another peripheral is already attached using the same pin #9268

Merged
merged 1 commit into from
Feb 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions cores/esp32/esp32-hal-sigmadelta.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ static bool sigmaDeltaDetachBus(void * bus){
bool sigmaDeltaAttach(uint8_t pin, uint32_t freq) //freq 1220-312500
{
perimanSetBusDeinit(ESP32_BUS_TYPE_SIGMADELTA, sigmaDeltaDetachBus);
sdm_channel_handle_t bus = (sdm_channel_handle_t)perimanGetPinBus(pin, ESP32_BUS_TYPE_SIGMADELTA);
if(bus != NULL && !perimanClearPinBus(pin)){
sdm_channel_handle_t bus = NULL;
// pin may be previously attached to other peripheral -> detach it.
// if attached to sigmaDelta, detach it and set the new frequency
if(perimanGetPinBusType(pin) != ESP32_BUS_TYPE_INIT && !perimanClearPinBus(pin)){
log_e("Pin %u could not be detached.", pin);
return false;
}
bus = NULL;
sdm_config_t config = {
.gpio_num = (int)pin,
.clk_src = SDM_CLK_SRC_DEFAULT,
Expand Down