Skip to content

Commit

Permalink
Fix #972: rename is_busy() to hal_radio_spi_is_busy()
Browse files Browse the repository at this point in the history
  • Loading branch information
terrillmoore committed Oct 29, 2024
1 parent 12d9669 commit b6d2be2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
13 changes: 9 additions & 4 deletions src/hal/hal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/lmic/hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/lmic/radio_sx126x.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit b6d2be2

Please sign in to comment.