mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-06-14 10:15:59 +00:00
70 lines
2.2 KiB
C++
70 lines
2.2 KiB
C++
#ifndef STA_CORE_ARDUINO_SPI_HPP
|
|
#define STA_CORE_ARDUINO_SPI_HPP
|
|
|
|
#include <sta/config.hpp>
|
|
#ifdef STA_PLATFORM_ARDUINO
|
|
|
|
#include <sta/bus/spi/device.hpp>
|
|
#include <sta/bus/spi/spi.hpp>
|
|
|
|
#include <sta/devices/arduino/gpio_pin.hpp>
|
|
#include <sta/devices/arduino/hal.hpp>
|
|
|
|
namespace sta
|
|
{
|
|
#ifdef STA_PLATFORM_ARDUINO_DEVICE_ESP32
|
|
enum SPIBus
|
|
{
|
|
BUS_HSPI = HSPI,
|
|
BUS_FSPI = FSPI
|
|
# ifndef STA_MCU_ESP32_S3
|
|
, BUS_VSPI = VSPI
|
|
# endif // !STA_MCU_ESP32_S3
|
|
};
|
|
#endif // STA_PLATFORM_ARDUINO_DEVICE_ESP32
|
|
|
|
class ArduinoSPI : public SPI
|
|
{
|
|
public:
|
|
#ifndef STA_PLATFORM_ARDUINO_DEVICE_ESP32
|
|
/**
|
|
* @brief Construct an SPI bus interface using the Arduino framework.
|
|
*
|
|
* @param settings The settings for the spi bus.
|
|
* @param mutex A mutex for managing bus access in multithreaded applications. Default is a dummy mutex that is always free.
|
|
*/
|
|
ArduinoSPI(const SPISettings & settings, Mutex * mutex = sta::Mutex::ALWAYS_FREE);
|
|
#else
|
|
/**
|
|
* @brief Construct an SPI bus interface using the Arduino framework.
|
|
*
|
|
* @param bus The bus to use.
|
|
* @param settings The settings for the spi bus.
|
|
* @param mutex A mutex for managing bus access in multithreaded applications. Default is a dummy mutex that is always free.
|
|
*/
|
|
ArduinoSPI(SPIBus bus, const SPISettings & settings, Mutex * mutex = sta::Mutex::ALWAYS_FREE);
|
|
#endif // !STA_PLATFORM_ARDUINO_DEVICE_ESP32
|
|
void transfer(uint8_t value) override;
|
|
void transfer16(uint16_t value) override;
|
|
void transfer(const uint8_t * buffer, size_t size) override;
|
|
void transfer(const uint8_t * txBuffer, uint8_t * rxBuffer, size_t size) override;
|
|
void receive(uint8_t * buffer, size_t size) override;
|
|
|
|
void fill(uint8_t value, size_t count) override;
|
|
|
|
void acquire() override;
|
|
void release() override;
|
|
private:
|
|
SPIClass spi_;
|
|
};
|
|
|
|
class ArduinoSPIDevice : public SPIDevice
|
|
{
|
|
public:
|
|
ArduinoSPIDevice(ArduinoSPI * intf, ArduinoGpioPin * csPin);
|
|
};
|
|
} // namespace sta
|
|
|
|
#endif // STA_PLATFORM_ARDUINO
|
|
|
|
#endif // STA_CORE_ARDUINO_SPI_HPP
|