[nRF24] Added Module overrides for all Arduino core functions
This commit is contained in:
parent
123b2f507f
commit
3bbe84a899
1 changed files with 20 additions and 20 deletions
|
@ -16,7 +16,7 @@ int16_t nRF24::begin(int16_t freq, int16_t dataRate, int8_t power, uint8_t addrW
|
|||
Module::digitalWrite(_mod->getRst(), LOW);
|
||||
|
||||
// wait for minimum power-on reset duration
|
||||
delay(100);
|
||||
Module::delay(100);
|
||||
|
||||
// check SPI connection
|
||||
int16_t val = _mod->SPIgetRegValue(NRF24_REG_SETUP_AW);
|
||||
|
@ -69,7 +69,7 @@ int16_t nRF24::standby() {
|
|||
// make sure carrier output is disabled
|
||||
_mod->SPIsetRegValue(NRF24_REG_RF_SETUP, NRF24_CONT_WAVE_OFF, 7, 7);
|
||||
_mod->SPIsetRegValue(NRF24_REG_RF_SETUP, NRF24_PLL_LOCK_OFF, 4, 4);
|
||||
digitalWrite(_mod->getRst(), LOW);
|
||||
Module::digitalWrite(_mod->getRst(), LOW);
|
||||
|
||||
// use standby-1 mode
|
||||
return(_mod->SPIsetRegValue(NRF24_REG_CONFIG, NRF24_POWER_UP, 1, 1));
|
||||
|
@ -81,9 +81,9 @@ int16_t nRF24::transmit(uint8_t* data, size_t len, uint8_t addr) {
|
|||
RADIOLIB_ASSERT(state);
|
||||
|
||||
// wait until transmission is finished
|
||||
uint32_t start = micros();
|
||||
while(digitalRead(_mod->getIrq())) {
|
||||
yield();
|
||||
uint32_t start = Module::micros();
|
||||
while(Module::digitalRead(_mod->getIrq())) {
|
||||
Module::yield();
|
||||
|
||||
// check maximum number of retransmits
|
||||
if(getStatus(NRF24_MAX_RT)) {
|
||||
|
@ -93,7 +93,7 @@ int16_t nRF24::transmit(uint8_t* data, size_t len, uint8_t addr) {
|
|||
}
|
||||
|
||||
// check timeout: 15 retries * 4ms (max Tx time as per datasheet)
|
||||
if(micros() - start >= 60000) {
|
||||
if(Module::micros() - start >= 60000) {
|
||||
standby();
|
||||
clearIRQ();
|
||||
return(ERR_TX_TIMEOUT);
|
||||
|
@ -112,12 +112,12 @@ int16_t nRF24::receive(uint8_t* data, size_t len) {
|
|||
RADIOLIB_ASSERT(state);
|
||||
|
||||
// wait for Rx_DataReady or timeout
|
||||
uint32_t start = micros();
|
||||
while(digitalRead(_mod->getIrq())) {
|
||||
yield();
|
||||
uint32_t start = Module::micros();
|
||||
while(Module::digitalRead(_mod->getIrq())) {
|
||||
Module::yield();
|
||||
|
||||
// check timeout: 15 retries * 4ms (max Tx time as per datasheet)
|
||||
if(micros() - start >= 60000) {
|
||||
if(Module::micros() - start >= 60000) {
|
||||
standby();
|
||||
clearIRQ();
|
||||
return(ERR_RX_TIMEOUT);
|
||||
|
@ -139,7 +139,7 @@ int16_t nRF24::transmitDirect(uint32_t frf) {
|
|||
int16_t state = _mod->SPIsetRegValue(NRF24_REG_CONFIG, NRF24_PTX, 0, 0);
|
||||
state |= _mod->SPIsetRegValue(NRF24_REG_RF_SETUP, NRF24_CONT_WAVE_ON, 7, 7);
|
||||
state |= _mod->SPIsetRegValue(NRF24_REG_RF_SETUP, NRF24_PLL_LOCK_ON, 4, 4);
|
||||
digitalWrite(_mod->getRst(), HIGH);
|
||||
Module::digitalWrite(_mod->getRst(), HIGH);
|
||||
return(state);
|
||||
}
|
||||
|
||||
|
@ -150,7 +150,7 @@ int16_t nRF24::receiveDirect() {
|
|||
}
|
||||
|
||||
void nRF24::setIrqAction(void (*func)(void)) {
|
||||
attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq()), func, FALLING);
|
||||
Module::attachInterrupt(RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(_mod->getIrq()), func, FALLING);
|
||||
}
|
||||
|
||||
int16_t nRF24::startTransmit(uint8_t* data, size_t len, uint8_t addr) {
|
||||
|
@ -186,9 +186,9 @@ int16_t nRF24::startTransmit(uint8_t* data, size_t len, uint8_t addr) {
|
|||
SPIwriteTxPayload(data, len);
|
||||
|
||||
// CE high to start transmitting
|
||||
digitalWrite(_mod->getRst(), HIGH);
|
||||
delay(1);
|
||||
digitalWrite(_mod->getRst(), LOW);
|
||||
Module::digitalWrite(_mod->getRst(), HIGH);
|
||||
Module::delay(1);
|
||||
Module::digitalWrite(_mod->getRst(), LOW);
|
||||
|
||||
return(state);
|
||||
}
|
||||
|
@ -211,10 +211,10 @@ int16_t nRF24::startReceive() {
|
|||
SPItransfer(NRF24_CMD_FLUSH_RX);
|
||||
|
||||
// CE high to start receiving
|
||||
digitalWrite(_mod->getRst(), HIGH);
|
||||
Module::digitalWrite(_mod->getRst(), HIGH);
|
||||
|
||||
// wait to enter Rx state
|
||||
delay(1);
|
||||
Module::delay(1);
|
||||
|
||||
return(state);
|
||||
}
|
||||
|
@ -539,7 +539,7 @@ int16_t nRF24::config() {
|
|||
|
||||
// power up
|
||||
_mod->SPIsetRegValue(NRF24_REG_CONFIG, NRF24_POWER_UP, 1, 1);
|
||||
delay(5);
|
||||
Module::delay(5);
|
||||
|
||||
return(state);
|
||||
}
|
||||
|
@ -558,7 +558,7 @@ void nRF24::SPItransfer(uint8_t cmd, bool write, uint8_t* dataOut, uint8_t* data
|
|||
SPISettings spiSettings = _mod->getSpiSettings();
|
||||
|
||||
// start transfer
|
||||
digitalWrite(_mod->getCs(), LOW);
|
||||
Module::digitalWrite(_mod->getCs(), LOW);
|
||||
spi->beginTransaction(spiSettings);
|
||||
|
||||
// send command
|
||||
|
@ -577,7 +577,7 @@ void nRF24::SPItransfer(uint8_t cmd, bool write, uint8_t* dataOut, uint8_t* data
|
|||
|
||||
// stop transfer
|
||||
spi->endTransaction();
|
||||
digitalWrite(_mod->getCs(), HIGH);
|
||||
Module::digitalWrite(_mod->getCs(), HIGH);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue