mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-08-06 10:27:34 +00:00
Rework SPI interfaces
This commit is contained in:
@@ -23,6 +23,7 @@ namespace sta
|
||||
*/
|
||||
SpiDevice(SpiInterface * intf);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Start transmission with device.
|
||||
*
|
||||
@@ -36,12 +37,19 @@ namespace sta
|
||||
*/
|
||||
void endTransmission();
|
||||
|
||||
|
||||
/**
|
||||
* @brief Send single byte of data.
|
||||
*
|
||||
* @param value 8-bit value
|
||||
*/
|
||||
void transfer(uint8_t value);
|
||||
/**
|
||||
* @brief Send two bytes of data.
|
||||
*
|
||||
* @param value 16-bit value
|
||||
*/
|
||||
void transfer16(uint16_t data);
|
||||
/**
|
||||
* @brief Send data from buffer.
|
||||
*
|
||||
@@ -58,11 +66,13 @@ namespace sta
|
||||
*/
|
||||
void transfer(const uint8_t * txBuffer, uint8_t * rxBuffer, size_t size);
|
||||
/**
|
||||
* @brief Send two bytes of data.
|
||||
* @brief Read incoming data to buffer.
|
||||
*
|
||||
* @param value 16-bit value
|
||||
* @param buffer Destination buffer
|
||||
* @param size Number of bytes to read
|
||||
*/
|
||||
void transfer16(uint16_t data);
|
||||
void receive(uint8_t * buffer, size_t size);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Send byte value repeatedly.
|
||||
@@ -71,21 +81,6 @@ namespace sta
|
||||
* @param count Number of repetitions
|
||||
*/
|
||||
void fill(uint8_t value, size_t count);
|
||||
/**
|
||||
* @brief Send 32-bit value repeatedly.
|
||||
*
|
||||
* @param value 32-bit value to repeat
|
||||
* @param count Number of repetitions
|
||||
*/
|
||||
void fill32(uint32_t value, size_t count);
|
||||
|
||||
/**
|
||||
* @brief Read incoming data to buffer.
|
||||
*
|
||||
* @param buffer Destination buffer
|
||||
* @param size Number of bytes to read
|
||||
*/
|
||||
void receive(uint8_t * buffer, size_t size);
|
||||
|
||||
|
||||
/**
|
||||
|
@@ -23,7 +23,7 @@ namespace sta
|
||||
* @param settings SPI interface settings
|
||||
* @param mutex Mutex object for managing shared access. Pass nullptr for no access control
|
||||
*/
|
||||
SpiInterface(const SpiSettings & settings, Mutex * mutex = nullptr);
|
||||
SpiInterface(Mutex * mutex = nullptr);
|
||||
|
||||
|
||||
/**
|
||||
@@ -32,6 +32,12 @@ namespace sta
|
||||
* @param value 8-bit value
|
||||
*/
|
||||
virtual void transfer(uint8_t value) = 0;
|
||||
/**
|
||||
* @brief Send two bytes of data.
|
||||
*
|
||||
* @param value 16-bit value
|
||||
*/
|
||||
virtual void transfer16(uint16_t value) = 0;
|
||||
/**
|
||||
* @brief Send data from buffer.
|
||||
*
|
||||
@@ -47,29 +53,6 @@ namespace sta
|
||||
* @param size Number of bytes to transfer
|
||||
*/
|
||||
virtual void transfer(const uint8_t * txBuffer, uint8_t * rxBuffer, size_t size) = 0;
|
||||
|
||||
/**
|
||||
* @brief Send two bytes of data.
|
||||
*
|
||||
* @param value 16-bit value
|
||||
*/
|
||||
virtual void transfer16(uint16_t value) = 0;
|
||||
|
||||
/**
|
||||
* @brief Send byte value repeatedly.
|
||||
*
|
||||
* @param value 8-bit value to repeat
|
||||
* @param count Number of repetitions
|
||||
*/
|
||||
virtual void fill(uint8_t value, size_t count) = 0;
|
||||
/**
|
||||
* @brief Send 32-bit value repeatedly.
|
||||
*
|
||||
* @param value 32-bit value to repeat
|
||||
* @param count Number of repetitions
|
||||
*/
|
||||
virtual void fill32(uint32_t value, size_t count) = 0;
|
||||
|
||||
/**
|
||||
* @brief Read incoming data to buffer.
|
||||
*
|
||||
@@ -79,12 +62,21 @@ namespace sta
|
||||
virtual void receive(uint8_t * buffer, size_t size) = 0;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Send byte value repeatedly.
|
||||
*
|
||||
* @param value 8-bit value to repeat
|
||||
* @param count Number of repetitions
|
||||
*/
|
||||
virtual void fill(uint8_t value, size_t count) = 0;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get SPI interface settings.
|
||||
*
|
||||
* @return SPI settings
|
||||
*/
|
||||
const SpiSettings & settings() const;
|
||||
virtual const SpiSettings & settings() const = 0;
|
||||
|
||||
|
||||
/**
|
||||
@@ -101,7 +93,6 @@ namespace sta
|
||||
virtual void release();
|
||||
|
||||
private:
|
||||
SpiSettings settings_; /** SPI settings */
|
||||
Mutex * mutex_; /**< Mutex object */
|
||||
};
|
||||
} // namespace sta
|
||||
|
@@ -28,8 +28,8 @@ namespace sta
|
||||
|
||||
enum class SpiDataSize
|
||||
{
|
||||
BIT_8,
|
||||
BIT_16
|
||||
SIZE_8,
|
||||
SIZE_16
|
||||
};
|
||||
|
||||
enum class SpiBitOrder
|
||||
@@ -40,14 +40,14 @@ namespace sta
|
||||
|
||||
enum class SpiBaudRatePrescaler
|
||||
{
|
||||
BRP_2,
|
||||
BRP_4,
|
||||
BRP_8,
|
||||
BRP_16,
|
||||
BRP_32,
|
||||
BRP_64,
|
||||
BRP_128,
|
||||
BRP_256
|
||||
DIV_2,
|
||||
DIV_4,
|
||||
DIV_8,
|
||||
DIV_16,
|
||||
DIV_32,
|
||||
DIV_64,
|
||||
DIV_128,
|
||||
DIV_256
|
||||
};
|
||||
|
||||
|
||||
@@ -56,9 +56,7 @@ namespace sta
|
||||
SpiMode mode;
|
||||
SpiDataSize dataSize;
|
||||
SpiBitOrder bitOrder;
|
||||
|
||||
uint32_t clkSpeed;
|
||||
SpiBaudRatePrescaler baudRatePrescaler; /**< Subject to change */
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user