36 #include "../Exception.h" 38 #include <type_traits> 43 #include <linux/spi/spidev.h> 44 #include <sys/ioctl.h> 60 class SpiException :
public Exception
63 SpiException(std::string message) : Exception(message) {}
66 enum class SpiModes : uint8_t
88 lsbFirst = SPI_LSB_FIRST,
98 threeWire = SPI_3WIRE,
111 inline SpiModes operator|(SpiModes lhs, SpiModes rhs)
113 return (SpiModes)(
static_cast<std::underlying_type<SpiModes>::type
>(lhs) |
static_cast<std::underlying_type<SpiModes>::type
>(rhs));
116 inline SpiModes& operator|=(SpiModes& lhs, SpiModes rhs)
118 lhs = (SpiModes)(
static_cast<std::underlying_type<SpiModes>::type
>(lhs) |
static_cast<std::underlying_type<SpiModes>::type
>(rhs));
122 inline SpiModes operator&(SpiModes lhs, SpiModes rhs)
124 return (SpiModes)(
static_cast<std::underlying_type<SpiModes>::type
>(lhs) &
static_cast<std::underlying_type<SpiModes>::type
>(rhs));
127 inline SpiModes& operator&=(SpiModes& lhs, SpiModes rhs)
129 lhs = (SpiModes)(
static_cast<std::underlying_type<SpiModes>::type
>(lhs) &
static_cast<std::underlying_type<SpiModes>::type
>(rhs));
145 Spi(
BaseLib::SharedObjects* baseLib, std::string device, SpiModes mode, uint8_t bitsPerWord, uint32_t speed);
151 void readwrite(std::vector<uint8_t>& data);
156 std::shared_ptr<FileDescriptor> _fileDescriptor;
157 std::string _lockfile;
158 std::mutex _sendMutex;
159 struct spi_ioc_transfer _transfer;
162 SpiModes _mode = SpiModes::none;
163 uint8_t _bitsPerWord = 8;
164 uint32_t _speed = 1000000;
This is the base library main class.
Definition: BaseLib.h:95
Definition: BaseLib.cpp:34