Unverified Commit 456b474a authored by Earle F. Philhower, III's avatar Earle F. Philhower, III Committed by GitHub

Allow re-setting identical pins without panic() (#1655)

Setting a pin to the current value is a no-op, not fatal.

Fixes #1652
parent f11cc4db
......@@ -40,6 +40,10 @@ bool SerialUART::setRX(pin_size_t pin) {
return true;
}
if (_rx == pin) {
return true;
}
if (_running) {
panic("FATAL: Attempting to set Serial%d.RX while running", uart_get_index(_uart) + 1);
} else {
......@@ -57,6 +61,10 @@ bool SerialUART::setTX(pin_size_t pin) {
return true;
}
if (_tx == pin) {
return true;
}
if (_running) {
panic("FATAL: Attempting to set Serial%d.TX while running", uart_get_index(_uart) + 1);
} else {
......@@ -74,6 +82,10 @@ bool SerialUART::setRTS(pin_size_t pin) {
return true;
}
if (_rts == pin) {
return true;
}
if (_running) {
panic("FATAL: Attempting to set Serial%d.RTS while running", uart_get_index(_uart) + 1);
} else {
......@@ -91,6 +103,10 @@ bool SerialUART::setCTS(pin_size_t pin) {
return true;
}
if (_cts == pin) {
return true;
}
if (_running) {
panic("FATAL: Attempting to set Serial%d.CTS while running", uart_get_index(_uart) + 1);
} else {
......
......@@ -206,6 +206,10 @@ bool SPIClassRP2040::setRX(pin_size_t pin) {
return true;
}
if (_RX == pin) {
return true;
}
if (_running) {
panic("FATAL: Attempting to set SPI%s.RX while running", spi_get_index(_spi) ? "1" : "");
} else {
......@@ -223,6 +227,10 @@ bool SPIClassRP2040::setCS(pin_size_t pin) {
return true;
}
if (_CS == pin) {
return true;
}
if (_running) {
panic("FATAL: Attempting to set SPI%s.CS while running", spi_get_index(_spi) ? "1" : "");
} else {
......@@ -240,6 +248,10 @@ bool SPIClassRP2040::setSCK(pin_size_t pin) {
return true;
}
if (_SCK == pin) {
return true;
}
if (_running) {
panic("FATAL: Attempting to set SPI%s.SCK while running", spi_get_index(_spi) ? "1" : "");
} else {
......@@ -257,6 +269,10 @@ bool SPIClassRP2040::setTX(pin_size_t pin) {
return true;
}
if (_TX == pin) {
return true;
}
if (_running) {
panic("FATAL: Attempting to set SPI%s.TX while running", spi_get_index(_spi) ? "1" : "");
} else {
......
......@@ -56,6 +56,10 @@ bool TwoWire::setSDA(pin_size_t pin) {
return true;
}
if (_sda == pin) {
return true;
}
if (_running) {
panic("FATAL: Attempting to set Wire%s.SDA while running", i2c_hw_index(_i2c) ? "1" : "");
} else {
......@@ -73,6 +77,10 @@ bool TwoWire::setSCL(pin_size_t pin) {
return true;
}
if (_scl == pin) {
return true;
}
if (_running) {
panic("FATAL: Attempting to set Wire%s.SCL while running", i2c_hw_index(_i2c) ? "1" : "");
} else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment