6#include "dawn/io/rgbled.hxx"
12int CIORgbLed::configureDesc(
const CDescObject &desc)
17 for (
size_t i = 0; i < desc.
getSize(); i++)
24 DAWNERR(
"unsupported rgbled cfg 0x08%" PRIx32
"\n", item->
cfgid.
v);
36 case IO_RGBLED_CFG_INITVAL:
39 initVal = *
reinterpret_cast<const uint32_t *
>(&item->
data[0]);
45 DAWNERR(
"unsupported rgbled cfg id %u\n", item->
cfgid.
s.
id);
53CIORgbLed::~CIORgbLed()
64 DAWNERR(
"RGBLED requires DTYPE_UINT32\n");
76 DAWNERR(
"RGBLED device number not configured\n");
80 snprintf(path,
sizeof(path), RGBLED_PATH_FMT,
getCmnDevno());
82 fd = rgbled_open(path);
85 DAWNERR(
"rgbled_open failed %d\n", fd);
99 return writeRgb(initVal);
109int CIORgbLed::writeRgb(uint32_t val)
124 static_cast<unsigned int>((val >> 16) & 0xffu),
125 static_cast<unsigned int>((val >> 8) & 0xffu),
126 static_cast<unsigned int>(val & 0xffu));
128 ret = rgbled_write(fd, rgb,
sizeof(rgb));
131 DAWNERR(
"rgbled_write failed %d\n", ret);
135 currentVal = val & 0x00ffffffu;
137#ifdef CONFIG_DAWN_IO_TIMESTAMP
156 val =
static_cast<uint32_t *
>(data.
getDataPtr());
159#ifdef CONFIG_DAWN_IO_TIMESTAMP
171 uint32_t *val =
static_cast<uint32_t *
>(data.
getDataPtr());
173 return writeRgb(*val);
178 return sizeof(uint32_t);
Descriptor wrapper for individual object configuration.
size_t getSize() const
Get number of configuration items for this object.
SObjectCfg::SObjectCfgItem * objectCfgItemAtOffset(size_t offset) const
Get configuration item at specified offset.
uint64_t getTimestamp()
Get current timestamp.
bool isTimestamp() const
Check if I/O supports timestamp.
int getCmnDevno() const
Get device number for this I/O.
size_t cfgCmnOffset(const SObjectCfg::SObjectCfgItem *cfg)
Get offset of configuration item in descriptor.
@ IO_CLASS_ANY
Any I/O class.
@ IO_CLASS_RGBLED
RGB LED output.
int getDataImpl(IODataCmn &data, size_t len)
Get data implementation (override in derived classes).
size_t getDataDim() const
Get data vector dimension.
int setDataImpl(IODataCmn &data)
Set data implementation (override in derived classes).
int init()
One-time initialize object after bindings are resolved.
int deinit()
De-initialize object.
size_t getDataSize() const
Get data size in bytes.
int configure()
Configure object from descriptor data.
CDescObject & getDesc()
Get descriptor object for this object.
uint8_t getDtype() const
Get data type field.
Out-of-tree user-extension hooks for Dawn.
Base interface for I/O data buffers (static and dynamic).
virtual void * getDataPtr(size_t batch=0)=0
Get pointer to data only (skips timestamp if present).
virtual uint64_t & getTs(size_t batch=0)=0
Get timestamp reference for batch.
Single configuration item within object.
ObjectCfgData_t data[]
Configuration data array (flexible, size from cfgid.s.size).
UObjectCfgId cfgid
Configuration ID header (type, class, id, size, rw, dtype).
@ DTYPE_UINT32
Unsigned 32-bit integer (0 to 4294967295).
ObjectCfgId v
Raw 32-bit ConfigID value (for storage, comparison).
uint32_t cls
Object class (bits 21-29, max 511).
uint32_t id
Configuration identifier (bits 0-4, max 31).
uint32_t size
Configuration data size in 32-bit words (bits 5-14, max 1023).
struct dawn::SObjectCfg::UObjectCfgId::@10 s
Bit-field structure for named member access.