From 8e35b14faeafe3c82b46cb8d6ec3f89ec75796db Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 29 Dec 2024 09:33:53 +0100 Subject: [PATCH] [nRF24] Use Module SPI transfer stream --- src/modules/nRF24/nRF24.cpp | 38 +------------------------------------ 1 file changed, 1 insertion(+), 37 deletions(-) diff --git a/src/modules/nRF24/nRF24.cpp b/src/modules/nRF24/nRF24.cpp index deafef27e..0218ddd7a 100644 --- a/src/modules/nRF24/nRF24.cpp +++ b/src/modules/nRF24/nRF24.cpp @@ -615,43 +615,7 @@ void nRF24::SPIwriteTxPayload(uint8_t* data, uint8_t numBytes) { } void nRF24::SPItransfer(uint8_t cmd, bool write, uint8_t* dataOut, uint8_t* dataIn, uint8_t numBytes) { - // prepare the buffers - size_t buffLen = 1 + numBytes; - #if RADIOLIB_STATIC_ONLY - uint8_t buffOut[RADIOLIB_STATIC_ARRAY_SIZE]; - uint8_t buffIn[RADIOLIB_STATIC_ARRAY_SIZE]; - #else - uint8_t* buffOut = new uint8_t[buffLen]; - uint8_t* buffIn = new uint8_t[buffLen]; - #endif - uint8_t* buffOutPtr = buffOut; - - // copy the command - *(buffOutPtr++) = cmd; - - // copy the data - if(write) { - memcpy(buffOutPtr, dataOut, numBytes); - } else { - memset(buffOutPtr, 0x00, numBytes); - } - - // do the transfer - this->mod->hal->digitalWrite(this->mod->getCs(), this->mod->hal->GpioLevelLow); - this->mod->hal->spiBeginTransaction(); - this->mod->hal->spiTransfer(buffOut, buffLen, buffIn); - this->mod->hal->spiEndTransaction(); - this->mod->hal->digitalWrite(this->mod->getCs(), this->mod->hal->GpioLevelHigh); - - // copy the data - if(!write) { - memcpy(dataIn, &buffIn[1], numBytes); - } - - #if !RADIOLIB_STATIC_ONLY - delete[] buffOut; - delete[] buffIn; - #endif + (void)this->mod->SPItransferStream(&cmd, 1, write, dataOut, dataIn, numBytes, false); } #endif