mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-08-06 02:27:33 +00:00
Added timeout to bus communication and added error handling via return values
This commit is contained in:
@@ -30,6 +30,7 @@ namespace sta
|
||||
SPIDevice(SPI * intf, GpioPin * csPin);
|
||||
|
||||
using Device::transfer;
|
||||
|
||||
/**
|
||||
* @brief Send and receive data simultaneously.
|
||||
*
|
||||
@@ -37,7 +38,7 @@ namespace sta
|
||||
* @param rxBuffer Receive buffer
|
||||
* @param size Number of bytes to transfer
|
||||
*/
|
||||
void transfer(const uint8_t * txBuffer, uint8_t * rxBuffer, size_t size);
|
||||
bool transfer(const uint8_t * txBuffer, uint8_t * rxBuffer, size_t size, uint32_t timeout = STA_MAX_TIMEOUT);
|
||||
|
||||
/**
|
||||
* @brief Get %SPI interface settings.
|
||||
|
@@ -38,7 +38,25 @@ namespace sta
|
||||
* @param rxBuffer Receive buffer
|
||||
* @param size Number of bytes to transfer
|
||||
*/
|
||||
virtual void transfer(const uint8_t * txBuffer, uint8_t * rxBuffer, size_t size) = 0;
|
||||
virtual bool transfer(const uint8_t * txBuffer, uint8_t * rxBuffer, size_t size, uint32_t timeout = STA_MAX_TIMEOUT) = 0;
|
||||
|
||||
/**
|
||||
* @brief Write data to a specific memory address of the peripheral.
|
||||
*
|
||||
* @param regAddr The memory address.
|
||||
* @param buffer The buffer of data to write to the address
|
||||
* @param size The number of bytes to write to the peripheral.
|
||||
*/
|
||||
bool writeMemory(uint8_t regAddr, const uint8_t * buffer, size_t size, uint32_t timeout = STA_MAX_TIMEOUT) override;
|
||||
|
||||
/**
|
||||
* @brief Read data from a specific memory address of the peripheral.
|
||||
*
|
||||
* @param regAddr The memory address.
|
||||
* @param buffer The buffer of data to write the received data to.
|
||||
* @param size The number of bytes to receive from the peripheral.
|
||||
*/
|
||||
bool readMemory(uint8_t regAddr, uint8_t * buffer, size_t size, uint32_t timeout = STA_MAX_TIMEOUT) override;
|
||||
|
||||
/**
|
||||
* @brief Get %SPI interface settings.
|
||||
@@ -46,7 +64,6 @@ namespace sta
|
||||
* @return %SPI settings
|
||||
*/
|
||||
const SPISettings & settings();
|
||||
|
||||
private:
|
||||
SPISettings settings_; /**< %SPI settings */
|
||||
};
|
||||
|
Reference in New Issue
Block a user