Skip to content

Preserver custom pin assigments with Wire.begin(custom_sda,custom_scl) #1239

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

Merged
merged 1 commit into from
Apr 6, 2018
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
20 changes: 14 additions & 6 deletions libraries/Wire/src/Wire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,27 @@ TwoWire::TwoWire(uint8_t bus_num)

void TwoWire::begin(int sdaPin, int sclPin, uint32_t frequency)
{
if(sdaPin < 0) {
if(sdaPin < 0) { // default param passed
if(num == 0) {
sdaPin = SDA;
if(sda==-1) sdaPin = SDA; //use Default Pin
else sdaPin = sda; // reuse prior pin
} else {
return;
if(sda==-1) {
log_e("no Default SDA Pin for Second Peripheral");
return; //no Default pin for Second Peripheral
} else sdaPin = sda; // reuse prior pin
}
}

if(sclPin < 0) {
if(sclPin < 0) { // default param passed
if(num == 0) {
sclPin = SCL;
if(scl==-1) sclPin = SCL; // use Default pin
else sclPin = scl; // reuse prior pin
} else {
return;
if(scl==-1){
log_e("no Default SCL Pin for Second Peripheral");
return; //no Default pin for Second Peripheral
} else sclPin = scl; // reuse prior pin
}
}

Expand Down