diff --git a/Adafruit_SPIDevice.cpp b/Adafruit_SPIDevice.cpp index 3cca367..45a2e65 100644 --- a/Adafruit_SPIDevice.cpp +++ b/Adafruit_SPIDevice.cpp @@ -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 * management. diff --git a/Adafruit_SPIDevice.h b/Adafruit_SPIDevice.h index 4c8d7bf..7639a9b 100644 --- a/Adafruit_SPIDevice.h +++ b/Adafruit_SPIDevice.h @@ -88,6 +88,8 @@ public: void transfer(uint8_t *buffer, size_t len); void beginTransaction(void); void endTransaction(void); + void beginTransactionWithAssertingCS(); + void endTransactionWithDeassertingCS(); private: SPIClass *_spi;