Dawn Framework 1.0
Universal data acquisition framework for embedded systems
pot.hxx
1// dawn/include/dawn/io/pot.hxx
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5
6#pragma once
7
8#include "dawn/io/common.hxx"
9#include "dawn/porting/config.hxx"
10#include "dawn/porting/pot.hxx"
11
12namespace dawn
13{
22class CIOPot : public CIOCommon
23{
24public:
25 enum
26 {
27 IO_POT_CFG_FIRST = 0,
28 IO_POT_CFG_WIPER = 1,
29 IO_POT_CFG_LAST = 31
30 };
31
32 explicit CIOPot(CDescObject &desc)
33 : CIOCommon(desc)
34 , path()
35 , fd(-1)
36 , wiper(0)
37 {
38 }
39
40 ~CIOPot() override;
41
42#ifdef CONFIG_DAWN_OBJECT_HAS_NAME
43 const char *getClassNameStr() const override
44 {
45 return "pot";
46 }
47#endif
48
49 int configure() override;
50 int deinit() override;
51 int setDataImpl(IODataCmn &data) override;
52 int getDataImpl(IODataCmn &data, size_t len) override;
53 size_t getDataSize() const override;
54 size_t getDataDim() const override;
55
56 bool isRead() const override
57 {
58 return true;
59 };
60
61 bool isWrite() const override
62 {
63 return true;
64 };
65
66 bool isNotify() const override
67 {
68 return false;
69 };
70
71 bool isBatch() const override
72 {
73 return false;
74 };
75
77
78 constexpr static SObjectId::ObjectId objectId(bool ts, uint16_t inst)
79 {
80 return ObjectIdHelper::create(ts, inst);
81 }
82
83 constexpr static SObjectCfg::ObjectCfgId cfgId(bool rw, uint8_t dtype, uint8_t size, uint8_t id)
84 {
87 }
88
89 constexpr static SObjectCfg::ObjectCfgId cfgIdWiper()
90 {
91 return CIOPot::cfgId(false, SObjectId::DTYPE_UINT32, 1, IO_POT_CFG_WIPER);
92 }
93
94private:
95 char path[PATH_MAX];
96 int fd;
97 uint8_t wiper;
98
99 int configureDesc(const CDescObject &desc);
100};
101} // Namespace dawn
Descriptor wrapper for individual object configuration.
Template helper for creating ObjectIDs for I/O types.
Definition common.hxx:262
static SObjectId::ObjectId create(bool ts, uint16_t inst)
Create ObjectID with default data type.
Definition common.hxx:272
Base class for all I/O objects.
Definition common.hxx:27
@ IO_CLASS_POT
Digital potentiometer wiper.
Definition common.hxx:200
Digital potentiometer (POT) wiper I/O type.
Definition pot.hxx:23
size_t getDataDim() const
Get data vector dimension.
Definition pot.cxx:199
int getDataImpl(IODataCmn &data, size_t len)
Get data implementation (override in derived classes).
Definition pot.cxx:157
int setDataImpl(IODataCmn &data)
Set data implementation (override in derived classes).
Definition pot.cxx:127
int deinit()
De-initialize object.
Definition pot.cxx:120
bool isRead() const
Check if IO supports read operations.
Definition pot.hxx:56
bool isWrite() const
Check if IO supports write operations.
Definition pot.hxx:61
bool isNotify() const
Check if IO supports notifications.
Definition pot.hxx:66
size_t getDataSize() const
Get data size in bytes.
Definition pot.cxx:194
bool isBatch() const
Check if IO supports batch operations.
Definition pot.hxx:71
int configure()
Configure object from descriptor data.
Definition pot.cxx:61
static ObjectCfgId objectCfg(uint8_t type, uint16_t cls, uint8_t dtype, bool rw, uint16_t size, uint8_t id)
Construct 32-bit ConfigID from component fields.
uint32_t ObjectCfgId
ConfigID type - single 32-bit value.
Definition objectcfg.hxx:60
Out-of-tree user-extension hooks for Dawn.
Definition bindable.hxx:13
Base interface for I/O data buffers (static and dynamic).
Definition idata.hxx:21
@ OBJTYPE_IO
Input/Output object type.
Definition objectid.hxx:184
@ DTYPE_UINT32
Unsigned 32-bit integer (0 to 4294967295).
Definition objectid.hxx:96
uint32_t ObjectId
ObjectID type - single 32-bit value.
Definition objectid.hxx:44