mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-12-17 00:58:02 +00:00
Rename SPI classes
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
/**
|
||||
* @file
|
||||
* @brief SPI device interface.
|
||||
* @brief SPI bus peripheral device.
|
||||
*/
|
||||
#ifndef STA_CORE_SPI_DEVICE_HPP
|
||||
#define STA_CORE_SPI_DEVICE_HPP
|
||||
|
||||
#include <sta/gpio_pin.hpp>
|
||||
#include <sta/spi/interface.hpp>
|
||||
#include <sta/spi/spi.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
@@ -14,101 +14,101 @@
|
||||
|
||||
namespace sta
|
||||
{
|
||||
/**
|
||||
* @brief Interface for SPI devices.
|
||||
*
|
||||
* @ingroup staCoreSPI
|
||||
*/
|
||||
class SpiDevice
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @param intf SPI hardware interface
|
||||
* @param csPin Chip select pin
|
||||
*/
|
||||
SpiDevice(SpiInterface * intf, GpioPin * csPin);
|
||||
/**
|
||||
* @brief Peripheral device connected via SPI.
|
||||
*
|
||||
* @ingroup sta_core_spi
|
||||
*/
|
||||
class SPIDevice
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @param intf %SPI hardware interface
|
||||
* @param csPin Chip select pin
|
||||
*/
|
||||
SPIDevice(SPI * intf, GpioPin * csPin);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Start transmission with device.
|
||||
*
|
||||
* Must be called before any I/O operations.
|
||||
*/
|
||||
void beginTransmission();
|
||||
/**
|
||||
* @brief End transmission with device.
|
||||
*
|
||||
* Must be called after last I/O operation.
|
||||
*/
|
||||
void endTransmission();
|
||||
/**
|
||||
* @brief Start transmission with device.
|
||||
*
|
||||
* Must be called before any I/O operations.
|
||||
*/
|
||||
void beginTransmission();
|
||||
/**
|
||||
* @brief End transmission with device.
|
||||
*
|
||||
* Must be called after last I/O operation.
|
||||
*/
|
||||
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 value);
|
||||
/**
|
||||
* @brief Send data from buffer.
|
||||
*
|
||||
* @param buffer Source buffer
|
||||
* @param size Number of bytes to transfer
|
||||
*/
|
||||
void transfer(const uint8_t * buffer, size_t size);
|
||||
/**
|
||||
* @brief Send and receive data simultaneously.
|
||||
*
|
||||
* @param txBuffer Send buffer
|
||||
* @param rxBuffer Receive buffer
|
||||
* @param size Number of bytes to transfer
|
||||
*/
|
||||
void transfer(const uint8_t * txBuffer, uint8_t * rxBuffer, size_t size);
|
||||
/**
|
||||
* @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);
|
||||
/**
|
||||
* @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 value);
|
||||
/**
|
||||
* @brief Send data from buffer.
|
||||
*
|
||||
* @param buffer Source buffer
|
||||
* @param size Number of bytes to transfer
|
||||
*/
|
||||
void transfer(const uint8_t * buffer, size_t size);
|
||||
/**
|
||||
* @brief Send and receive data simultaneously.
|
||||
*
|
||||
* @param txBuffer Send buffer
|
||||
* @param rxBuffer Receive buffer
|
||||
* @param size Number of bytes to transfer
|
||||
*/
|
||||
void transfer(const uint8_t * txBuffer, uint8_t * rxBuffer, size_t size);
|
||||
/**
|
||||
* @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);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Send byte value repeatedly.
|
||||
*
|
||||
* @param value 8-bit value to repeat
|
||||
* @param count Number of repetitions
|
||||
*/
|
||||
void fill(uint8_t value, size_t count);
|
||||
/**
|
||||
* @brief Send byte value repeatedly.
|
||||
*
|
||||
* @param value 8-bit value to repeat
|
||||
* @param count Number of repetitions
|
||||
*/
|
||||
void fill(uint8_t value, size_t count);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get SPI interface settings.
|
||||
*
|
||||
* @return SPI settings
|
||||
*/
|
||||
const SpiSettings & settings() const;
|
||||
/**
|
||||
* @brief Get %SPI interface settings.
|
||||
*
|
||||
* @return SPI settings
|
||||
*/
|
||||
const SpiSettings & settings() const;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Activate device via CS pin.
|
||||
*/
|
||||
void select();
|
||||
/**
|
||||
* @brief Deactivate device via CS pin.
|
||||
*/
|
||||
void deselect();
|
||||
/**
|
||||
* @brief Activate device via CS pin.
|
||||
*/
|
||||
void select();
|
||||
/**
|
||||
* @brief Deactivate device via CS pin.
|
||||
*/
|
||||
void deselect();
|
||||
|
||||
private:
|
||||
SpiInterface * intf_; /**< SPI hardware interface */
|
||||
GpioPin * csPin_; /**< Chip select pin */
|
||||
};
|
||||
private:
|
||||
SPI * intf_; /**< %SPI hardware interface */
|
||||
GpioPin * csPin_; /**< Chip select pin */
|
||||
};
|
||||
} // namespace sta
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user