beginTransactionWithAssertingCS() and endTransactionWithDeassertingCS()

These two methods are similar to beginTransaction() and endTransaction(),
but, as the name implies, with CS management. They are both public, as
beginTransaction() and endTransaction() are too.
This commit is contained in:
Christian Riggenbach 2022-05-02 22:35:38 +02:00
parent 4ca049393f
commit 41635e3c68
2 changed files with 22 additions and 0 deletions

View File

@ -282,6 +282,26 @@ void Adafruit_SPIDevice::endTransaction(void) {
} }
} }
/*!
* @brief Write a buffer or two to the SPI device, with transaction
* management.
* @brief Manually begin a transaction (calls beginTransaction if hardware
* SPI) with asserting the CS pin
*/
void Adafruit_SPIDevice::beginTransactionWithAssertingCS() {
beginTransaction();
setChipSelect(LOW);
}
/*!
* @brief Manually end a transaction (calls endTransaction if hardware SPI)
* with deasserting the CS pin
*/
void Adafruit_SPIDevice::endTransactionWithDeassertingCS() {
setChipSelect(HIGH);
endTransaction();
}
/*! /*!
* @brief Write a buffer or two to the SPI device, with transaction * @brief Write a buffer or two to the SPI device, with transaction
* management. * management.

View File

@ -88,6 +88,8 @@ public:
void transfer(uint8_t *buffer, size_t len); void transfer(uint8_t *buffer, size_t len);
void beginTransaction(void); void beginTransaction(void);
void endTransaction(void); void endTransaction(void);
void beginTransactionWithAssertingCS();
void endTransactionWithDeassertingCS();
private: private:
SPIClass *_spi; SPIClass *_spi;