Skip to content

Commit

Permalink
Added check for -1 in pinMode
Browse files Browse the repository at this point in the history
  • Loading branch information
jgromes committed Dec 1, 2019
1 parent 2a3172b commit 67c6544
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void Module::init(uint8_t interface, uint8_t gpio) {
// select interface
switch(interface) {
case RADIOLIB_USE_SPI:
pinMode(_cs, OUTPUT);
setPin(_cs, OUTPUT);
digitalWrite(_cs, HIGH);
_spi->begin();
break;
Expand All @@ -76,14 +76,14 @@ void Module::init(uint8_t interface, uint8_t gpio) {
case RADIOLIB_INT_NONE:
break;
case RADIOLIB_INT_0:
pinMode(_int0, INPUT);
setPin(_int0, INPUT);
break;
case RADIOLIB_INT_1:
pinMode(_int1, INPUT);
setPin(_int1, INPUT);
break;
case RADIOLIB_INT_BOTH:
pinMode(_int0, INPUT);
pinMode(_int1, INPUT);
setPin(_int0, INPUT);
setPin(_int1, INPUT);
break;
}
}
Expand Down Expand Up @@ -252,3 +252,9 @@ void Module::SPItransfer(uint8_t cmd, uint8_t reg, uint8_t* dataOut, uint8_t* da
// end SPI transaction
_spi->endTransaction();
}

void Module::setPin(int16_t pin, uint8_t mode) {
if(pin != -1) {
pinMode(pin, mode);
}
}
2 changes: 2 additions & 0 deletions src/Module.h
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,8 @@ class Module {
SPISettings _spiSettings;

uint32_t _ATtimeout = 15000;

void setPin(int16_t pin, uint8_t mode);
};

#endif

0 comments on commit 67c6544

Please sign in to comment.