Dawn Framework 1.0
Universal data acquisition framework for embedded systems
rgbled.hxx
1// dawn/include/dawn/io/rgbled.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/rgbled.hxx"
11
12namespace dawn
13{
22class CIORgbLed : public CIOCommon
23{
24public:
25 enum
26 {
27 IO_RGBLED_CFG_FIRST = 0,
28 IO_RGBLED_CFG_INITVAL = 1,
29 IO_RGBLED_CFG_LAST = 31
30 };
31
32 explicit CIORgbLed(CDescObject &desc)
33 : CIOCommon(desc)
34 , path()
35 , fd(-1)
36 , initVal(0)
37 , currentVal(0)
38#ifdef CONFIG_DAWN_IO_TIMESTAMP
39 , ts(0)
40#endif
41 {
42 }
43
44 ~CIORgbLed() override;
45
46#ifdef CONFIG_DAWN_OBJECT_HAS_NAME
47 const char *getClassNameStr() const override
48 {
49 return "rgbled";
50 }
51#endif
52
53 int configure() override;
54 int init() override;
55 int deinit() override;
56 int getDataImpl(IODataCmn &data, size_t len) override;
57 int setDataImpl(IODataCmn &data) override;
58 size_t getDataSize() const override;
59 size_t getDataDim() const override;
60
61 bool isRead() const override
62 {
63 return true;
64 };
65
66 bool isWrite() const override
67 {
68 return true;
69 };
70
71 bool isNotify() const override
72 {
73 return false;
74 };
75
76 bool isBatch() const override
77 {
78 return false;
79 };
80
82
83 constexpr static SObjectId::ObjectId objectId(bool ts, uint16_t inst)
84 {
85 return ObjectIdHelper::create(ts, inst);
86 }
87
88 constexpr static SObjectCfg::ObjectCfgId cfgId(bool rw, uint8_t dtype, uint8_t size, uint8_t id)
89 {
92 }
93
94 constexpr static SObjectCfg::ObjectCfgId cfgIdInitVal(uint32_t val = 0)
95 {
96 return CIORgbLed::cfgId(false, SObjectId::DTYPE_UINT32, 1, IO_RGBLED_CFG_INITVAL);
97 }
98
99private:
100 char path[PATH_MAX];
101 int fd;
102 uint32_t initVal;
103 uint32_t currentVal;
104#ifdef CONFIG_DAWN_IO_TIMESTAMP
105 uint64_t ts;
106#endif
107
108 int configureDesc(const CDescObject &desc);
109 int writeRgb(uint32_t val);
110};
111} // Namespace dawn
Descriptor wrapper for individual object configuration.
Template helper for creating ObjectIDs for I/O types.
Definition common.hxx:236
static SObjectId::ObjectId create(bool ts, uint16_t inst)
Create ObjectID with default data type.
Definition common.hxx:246
Base class for all I/O objects.
Definition common.hxx:27
@ IO_CLASS_RGBLED
RGB LED output.
Definition common.hxx:168
RGB LED output I/O type.
Definition rgbled.hxx:23
int getDataImpl(IODataCmn &data, size_t len)
Get data implementation (override in derived classes).
Definition rgbled.cxx:147
size_t getDataDim() const
Get data vector dimension.
Definition rgbled.cxx:181
int setDataImpl(IODataCmn &data)
Set data implementation (override in derived classes).
Definition rgbled.cxx:169
bool isBatch() const
Check if IO supports batch operations.
Definition rgbled.hxx:76
int init()
One-time initialize object after bindings are resolved.
Definition rgbled.cxx:92
int deinit()
De-initialize object.
Definition rgbled.cxx:102
size_t getDataSize() const
Get data size in bytes.
Definition rgbled.cxx:176
int configure()
Configure object from descriptor data.
Definition rgbled.cxx:58
bool isNotify() const
Check if IO supports notifications.
Definition rgbled.hxx:71
bool isRead() const
Check if IO supports read operations.
Definition rgbled.hxx:61
bool isWrite() const
Check if IO supports write operations.
Definition rgbled.hxx:66
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