Skip to content

Commit b7034d3

Browse files
committed
UM SHT: Check for IOs gt zero
1 parent 9217e83 commit b7034d3

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

usermods/sht/usermod_sht.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,8 @@ void ShtUsermod::setup()
245245
{
246246
if (enabled) {
247247
PinManagerPinType pins[2] = { { i2c_sda, true }, { i2c_scl, true } };
248-
if (!pinManager.allocateMultiplePins(pins, 2, PinOwner::HW_I2C)) {
248+
// GPIOs can be set to -1 and allocateMultiplePins() will return true, so check they're gt zero
249+
if (i2c_sda < 0 || i2c_scl < 0 || !pinManager.allocateMultiplePins(pins, 2, PinOwner::HW_I2C)) {
249250
DEBUG_PRINTF("[%s] SHT pin allocation failed!\n", _name);
250251
cleanup();
251252
return;

0 commit comments

Comments
 (0)