UM SHT: Check for IOs gt zero

pull/2942/head
ezcGman 2022-12-18 21:33:25 +01:00
rodzic 9217e8336d
commit b7034d3213
1 zmienionych plików z 2 dodań i 1 usunięć

Wyświetl plik

@ -245,7 +245,8 @@ void ShtUsermod::setup()
{
if (enabled) {
PinManagerPinType pins[2] = { { i2c_sda, true }, { i2c_scl, true } };
if (!pinManager.allocateMultiplePins(pins, 2, PinOwner::HW_I2C)) {
// GPIOs can be set to -1 and allocateMultiplePins() will return true, so check they're gt zero
if (i2c_sda < 0 || i2c_scl < 0 || !pinManager.allocateMultiplePins(pins, 2, PinOwner::HW_I2C)) {
DEBUG_PRINTF("[%s] SHT pin allocation failed!\n", _name);
cleanup();
return;