From 3e5c0d59c77f2c0ae35368a4050b418a676fc3d7 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 12 Aug 2023 18:35:08 +0200 Subject: [PATCH] [MOD] Moved CS pin toggling inside SPI transaction block --- src/Module.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Module.cpp b/src/Module.cpp index 2e734034..68fbcf0c 100644 --- a/src/Module.cpp +++ b/src/Module.cpp @@ -166,11 +166,11 @@ void Module::SPItransfer(uint8_t cmd, uint16_t reg, uint8_t* dataOut, uint8_t* d } // do the transfer - this->hal->digitalWrite(this->csPin, this->hal->GpioLevelLow); this->hal->spiBeginTransaction(); + this->hal->digitalWrite(this->csPin, this->hal->GpioLevelLow); this->hal->spiTransfer(buffOut, buffLen, buffIn); - this->hal->spiEndTransaction(); this->hal->digitalWrite(this->csPin, this->hal->GpioLevelHigh); + this->hal->spiEndTransaction(); // copy the data if(cmd == SPIreadCommand) { @@ -298,11 +298,11 @@ int16_t Module::SPItransferStream(uint8_t* cmd, uint8_t cmdLen, bool write, uint } // do the transfer - this->hal->digitalWrite(this->csPin, this->hal->GpioLevelLow); this->hal->spiBeginTransaction(); + this->hal->digitalWrite(this->csPin, this->hal->GpioLevelLow); this->hal->spiTransfer(buffOut, buffLen, buffIn); - this->hal->spiEndTransaction(); this->hal->digitalWrite(this->csPin, this->hal->GpioLevelHigh); + this->hal->spiEndTransaction(); // wait for GPIO to go high and then low if(waitForGpio) {