11 #include <RADCore/RADCore.h>
61 bool open(
int bus,
int address,
const DevicePaths& paths = {}, std::string* error =
nullptr);
65 ssize_t
write(
const std::vector<uint8_t>& bytes);
67 std::vector<uint8_t>
read(
size_t count);
85 bool open(
int bus,
int chipSelect,
const DevicePaths& paths = {}, std::string* error =
nullptr);
89 bool configure(uint8_t mode, uint8_t bitsPerWord, uint32_t speedHz, std::string* error =
nullptr);
91 std::vector<uint8_t>
transfer(
const std::vector<uint8_t>& tx, std::string* error =
nullptr);
99 uint32_t speedHz_ = 1000000;
100 uint8_t bitsPerWord_ = 8;
117 bool writeValue(
bool high, std::string* error =
nullptr)
const;
136 bool setEnabled(
bool enabled, std::string* error =
nullptr)
const;
138 bool setPeriodNs(uint64_t periodNs, std::string* error =
nullptr)
const;
176 bool open(
int index = 0,
const DevicePaths& paths = {}, std::string* error =
nullptr);
Success-or-error return value for APIs that should not throw.
Definition: RADCore.h:126
IIO ADC channel reader.
Definition: RADDevice.h:151
RADCore::RADResult< double > readScaled() const
Reads scaled voltage/value when scale is available.
AdcChannel(int device, int channel, DevicePaths paths={})
Creates an ADC channel wrapper.
RADCore::RADResult< double > readScale() const
Reads scale value when available.
RADCore::RADResult< int > readRaw() const
Reads raw integer sample.
GPIO sysfs helper.
Definition: RADDevice.h:104
bool writeValue(bool high, std::string *error=nullptr) const
Writes 0 or 1.
bool setEdge(GpioEdge edge, std::string *error=nullptr) const
Sets pin edge mode.
bool setDirection(GpioDirection direction, std::string *error=nullptr) const
Sets pin direction.
bool exportPin(std::string *error=nullptr) const
Exports the pin through sysfs.
bool unexportPin(std::string *error=nullptr) const
Unexports the pin through sysfs.
std::string pinPath() const
Returns sysfs pin directory.
RADCore::RADResult< bool > readValue() const
Reads current value.
GpioPin(int number, DevicePaths paths={})
Creates a GPIO pin wrapper.
Parity-free I2C device wrapper using /dev/i2c-* and I2C_SLAVE ioctl.
Definition: RADDevice.h:54
bool open(int bus, int address, const DevicePaths &paths={}, std::string *error=nullptr)
Opens bus number and selects 7-bit address.
void close()
Closes the descriptor.
~I2CDevice()
Closes the device.
ssize_t write(const std::vector< uint8_t > &bytes)
Writes bytes to the selected device.
std::vector< uint8_t > read(size_t count)
Reads bytes from the selected device.
bool isOpen() const
Returns true when open.
I2CDevice()
Creates a closed I2C device wrapper.
int fd() const
Returns owned file descriptor.
LED sysfs helper.
Definition: RADDevice.h:189
RADCore::RADResult< int > maxBrightness() const
Returns maximum brightness.
bool setBrightness(int brightness, std::string *error=nullptr) const
Writes brightness.
Led(std::string name, DevicePaths paths={})
Creates an LED wrapper.
RADCore::RADResult< int > brightness() const
Reads brightness.
PWM sysfs channel helper.
Definition: RADDevice.h:129
std::string channelPath() const
Returns sysfs PWM path.
bool exportChannel(std::string *error=nullptr) const
Exports the PWM channel.
bool setDutyCycleNs(uint64_t dutyNs, std::string *error=nullptr) const
Sets duty cycle in nanoseconds.
bool setPeriodNs(uint64_t periodNs, std::string *error=nullptr) const
Sets period in nanoseconds.
bool setEnabled(bool enabled, std::string *error=nullptr) const
Enables or disables output.
PwmChannel(int chip, int channel, DevicePaths paths={})
Creates a PWM channel wrapper.
SPI device wrapper using /dev/spidev* and SPI_IOC_MESSAGE.
Definition: RADDevice.h:78
SPIDevice()
Creates a closed SPI device wrapper.
bool isOpen() const
Returns true when open.
std::vector< uint8_t > transfer(const std::vector< uint8_t > &tx, std::string *error=nullptr)
Full-duplex transfer.
bool open(int bus, int chipSelect, const DevicePaths &paths={}, std::string *error=nullptr)
Opens a SPI bus/chip-select device.
bool configure(uint8_t mode, uint8_t bitsPerWord, uint32_t speedHz, std::string *error=nullptr)
Configures mode, bits, and max speed through ioctl.
void close()
Closes the descriptor.
int fd() const
Returns owned file descriptor.
~SPIDevice()
Closes the device.
Linux watchdog wrapper.
Definition: RADDevice.h:169
Watchdog()
Creates a closed watchdog wrapper.
~Watchdog()
Closes the descriptor.
bool isOpen() const
Returns true when open.
void close()
Closes the descriptor.
bool open(int index=0, const DevicePaths &paths={}, std::string *error=nullptr)
Opens /dev/watchdogN.
bool keepAlive(std::string *error=nullptr)
Pings the watchdog through ioctl.
Definition: RADDevice.h:17
GpioDirection
GPIO direction.
Definition: RADDevice.h:34
std::vector< std::string > listIioDevices(const DevicePaths &paths={})
Lists visible IIO device directory names.
std::vector< std::string > listLeds(const DevicePaths &paths={})
Lists LED device names.
GpioEdge
GPIO edge trigger mode.
Definition: RADDevice.h:42
Filesystem roots used for real devices or test fixtures.
Definition: RADDevice.h:20
std::string sysClassGpio
GPIO sysfs root.
Definition: RADDevice.h:22
std::string sysBusIio
IIO sysfs root.
Definition: RADDevice.h:26
std::string sysClassPwm
PWM sysfs root.
Definition: RADDevice.h:24
std::string sysClassLeds
LED sysfs root.
Definition: RADDevice.h:28
std::string devRoot
Device node root.
Definition: RADDevice.h:30