6#include "dawn/io/pot.hxx"
17 for (
size_t i = 0; i < desc.
getSize(); i++)
24 DAWNERR(
"Unsupported POT config 0x%08" PRIx32
"\n", item->
cfgid.
v);
36 case IO_POT_CFG_WIPER:
39 DAWNERR(
"invalid POT wiper config size %d\n", item->
cfgid.
s.
size);
43 wiper =
static_cast<uint8_t
>(*
reinterpret_cast<const uint32_t *
>(&item->
data[0]));
48 DAWNERR(
"unsupported POT cfg id %u\n", item->
cfgid.
s.
id);
68 DAWNERR(
"POT requires DTYPE_INT32\n");
77 DAWNERR(
"POT configure failed (error %d)\n", ret);
85 DAWNERR(
"POT device number not configured\n");
89 snprintf(path,
sizeof(path), POT_PATH_FMT,
getCmnDevno());
96 DAWNERR(
"failed to open file %d\n", -errno);
102 ret = pot_get_nwipers(fd, &nwipers);
105 DAWNERR(
"pot_get_nwipers failed %d\n", ret);
110 if (wiper >= nwipers)
112 DAWNERR(
"POT wiper %u out of range (%u wipers)\n", wiper, nwipers);
129 int32_t *tmp =
static_cast<int32_t *
>(data.
getDataPtr());
143 info.val =
static_cast<uint32_t
>(*tmp);
147 ret = pot_set_wiper(fd, &info);
150 DAWNERR(
"pot_set_wiper failed %d\n", ret);
159 int32_t *tmp =
static_cast<int32_t *
>(data.
getDataPtr());
175 ret = pot_get_wiper(fd, &info);
178 DAWNERR(
"pot_get_wiper failed %d\n", ret);
182 *tmp =
static_cast<int32_t
>(info.val);
184#ifdef CONFIG_DAWN_IO_TIMESTAMP
196 return sizeof(int32_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_POT
Digital potentiometer wiper.
size_t getDataDim() const
Get data vector dimension.
int getDataImpl(IODataCmn &data, size_t len)
Get data implementation (override in derived classes).
int setDataImpl(IODataCmn &data)
Set data implementation (override in derived classes).
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 size_t getItems()=0
Get number of items per batch.
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_INT32
Signed 32-bit integer (-2147483648 to 2147483647).
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.