[MOD] Moved CS pin toggling inside SPI transaction block
This commit is contained in:
parent
86724197ec
commit
3e5c0d59c7
1 changed files with 4 additions and 4 deletions
|
@ -166,11 +166,11 @@ void Module::SPItransfer(uint8_t cmd, uint16_t reg, uint8_t* dataOut, uint8_t* d
|
||||||
}
|
}
|
||||||
|
|
||||||
// do the transfer
|
// do the transfer
|
||||||
this->hal->digitalWrite(this->csPin, this->hal->GpioLevelLow);
|
|
||||||
this->hal->spiBeginTransaction();
|
this->hal->spiBeginTransaction();
|
||||||
|
this->hal->digitalWrite(this->csPin, this->hal->GpioLevelLow);
|
||||||
this->hal->spiTransfer(buffOut, buffLen, buffIn);
|
this->hal->spiTransfer(buffOut, buffLen, buffIn);
|
||||||
this->hal->spiEndTransaction();
|
|
||||||
this->hal->digitalWrite(this->csPin, this->hal->GpioLevelHigh);
|
this->hal->digitalWrite(this->csPin, this->hal->GpioLevelHigh);
|
||||||
|
this->hal->spiEndTransaction();
|
||||||
|
|
||||||
// copy the data
|
// copy the data
|
||||||
if(cmd == SPIreadCommand) {
|
if(cmd == SPIreadCommand) {
|
||||||
|
@ -298,11 +298,11 @@ int16_t Module::SPItransferStream(uint8_t* cmd, uint8_t cmdLen, bool write, uint
|
||||||
}
|
}
|
||||||
|
|
||||||
// do the transfer
|
// do the transfer
|
||||||
this->hal->digitalWrite(this->csPin, this->hal->GpioLevelLow);
|
|
||||||
this->hal->spiBeginTransaction();
|
this->hal->spiBeginTransaction();
|
||||||
|
this->hal->digitalWrite(this->csPin, this->hal->GpioLevelLow);
|
||||||
this->hal->spiTransfer(buffOut, buffLen, buffIn);
|
this->hal->spiTransfer(buffOut, buffLen, buffIn);
|
||||||
this->hal->spiEndTransaction();
|
|
||||||
this->hal->digitalWrite(this->csPin, this->hal->GpioLevelHigh);
|
this->hal->digitalWrite(this->csPin, this->hal->GpioLevelHigh);
|
||||||
|
this->hal->spiEndTransaction();
|
||||||
|
|
||||||
// wait for GPIO to go high and then low
|
// wait for GPIO to go high and then low
|
||||||
if(waitForGpio) {
|
if(waitForGpio) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue