mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-08-05 18:21:54 +00:00
Added SPI implementation based on Linux library
This commit is contained in:
@@ -31,10 +31,18 @@ namespace sta
|
||||
|
||||
void setState(GpioPinState state) override;
|
||||
|
||||
static RaspiGpioPin DUMMY_GPIO;
|
||||
|
||||
private:
|
||||
uint8_t pin_;
|
||||
GpioMode mode_;
|
||||
};
|
||||
|
||||
class DummyGpioPin : RaspiGpioPin {
|
||||
DummyGpioPin();
|
||||
|
||||
void setState(GpioPinState state) override;
|
||||
}
|
||||
} // namespace sta
|
||||
|
||||
#endif // STA_RASPI_GPIO_ENABLED
|
||||
|
@@ -2,7 +2,7 @@
|
||||
#define STA_CORE_RASPI_HAL_HPP
|
||||
|
||||
#include <wiringPi.h>
|
||||
#include <wiringPiSPI.h>
|
||||
#include <wiringPiI2C.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#endif //STA_CORE_RASPI_HAL_HPP
|
||||
|
@@ -1,19 +1,50 @@
|
||||
#ifndef STA_CORE_RASPI_SPI_HPP
|
||||
#define STA_CORE_RASPI_SPI_HPP
|
||||
|
||||
#include <sta/config.hpp>
|
||||
#ifdef STA_PLATFORM_RASPI
|
||||
|
||||
#include <sta/spi/device.hpp>
|
||||
#include <sta/spi/spi.hpp>
|
||||
|
||||
namespace sta
|
||||
{
|
||||
class RaspiSPI : SPI
|
||||
class RaspiSPI : public SPI
|
||||
{
|
||||
public:
|
||||
RaspiSPI(const char * dev, const SPISettings & settings, Mutex * mutex = nullptr);
|
||||
~RaspiSPI();
|
||||
|
||||
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:
|
||||
char * spidev_;
|
||||
int spifd_;
|
||||
bool open_;
|
||||
|
||||
void update_setting(int setting, int value);
|
||||
};
|
||||
|
||||
class RaspiSPIDevice : SPIDevice
|
||||
{
|
||||
public:
|
||||
RaspiSPIDevice(RaspiSPI * intf);
|
||||
|
||||
void select() override;
|
||||
|
||||
void deselect() override;
|
||||
};
|
||||
} // namespace sta
|
||||
|
||||
#endif // STA_PLATFORM_RASPI
|
||||
|
||||
#endif // STA_CORE_RASPI_HPP
|
Reference in New Issue
Block a user