diff --git a/src/hal/hal.cpp b/src/hal/hal.cpp index 2a20e100..be5d5e56 100644 --- a/src/hal/hal.cpp +++ b/src/hal/hal.cpp @@ -192,11 +192,16 @@ static void hal_spi_init () { } #if (defined(CFG_sx1261_radio) || defined(CFG_sx1262_radio)) -bit_t is_busy() { +bit_t hal_radio_spi_is_busy() { // SX126x uses BUSY pin return digitalRead(pHalConfig->queryBusyPin()) ? true : false; } -#endif +#else +// supply a definition just in case, because the declaration is not conditional +bit_t hal_radio_spi_is_busy() { + return false; +} +#endif // (defined(CFG_sx1261_radio) || defined(CFG_sx1262_radio)) static void hal_spi_trx(u1_t cmd, u1_t* buf, size_t len, bit_t is_read) { uint32_t spi_freq; @@ -211,7 +216,7 @@ static void hal_spi_trx(u1_t cmd, u1_t* buf, size_t len, bit_t is_read) { // SX126x modems use BUSY pin. Only interact with SPI when BUSY goes LOW #if (defined(CFG_sx1261_radio) || defined(CFG_sx1262_radio)) - while (is_busy()); + while (hal_radio_spi_is_busy()); #endif SPI.transfer(cmd); @@ -248,7 +253,7 @@ void hal_spi_read_sx126x(u1_t cmd, u1_t* addr, size_t addr_len, u1_t* buf, size_ SPI.beginTransaction(settings); digitalWrite(nss, 0); - while (is_busy()); + while (hal_radio_spi_is_busy()); SPI.transfer(cmd); diff --git a/src/lmic/hal.h b/src/lmic/hal.h index 6195e2b0..fd92a840 100644 --- a/src/lmic/hal.h +++ b/src/lmic/hal.h @@ -191,7 +191,7 @@ uint8_t hal_getTxPowerPolicy( void hal_pollPendingIRQs_helper(); void hal_processPendingIRQs(void); -bit_t is_busy(); +bit_t hal_radio_spi_is_busy(); /// \brief check for any pending interrupts: stub if interrupts are enabled. static inline void hal_pollPendingIRQs(void) diff --git a/src/lmic/radio_sx126x.c b/src/lmic/radio_sx126x.c index 1b28cf2b..ec571fd9 100644 --- a/src/lmic/radio_sx126x.c +++ b/src/lmic/radio_sx126x.c @@ -766,7 +766,7 @@ void radio_config(void) { // Perform necessary operations from STDBY_RC mode if ((getStatus() | SX126x_GETSTATUS_CHIPMODE_MASK) != SX126x_CHIPMODE_STDBY_RC) { // Assume we've woken from sleep - while (is_busy()); + while (hal_radio_spi_is_busy()); setStandby(STDBY_RC); } @@ -1145,7 +1145,7 @@ int radio_init(void) { hal_waitUntil(os_getTime()+ms2osticks(1)); // wait >100us hal_pin_rst(2); // configure RST pin floating! hal_waitUntil(os_getTime()+ms2osticks(5)); // wait 5ms - while(is_busy()); // wait for busy pin to go low + while(hal_radio_spi_is_busy()); // wait for busy pin to go low // Check default LoRa sync word to verify the reset was successful u1_t syncWordMSB = readRegister(LoRaSyncWordMSB);