Dawn Framework 1.0
Universal data acquisition framework for embedded systems
leds.hxx
1// dawn/include/dawn/io/leds.hxx
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5
6#pragma once
7
8#include <mutex>
9
10#include "dawn/io/common.hxx"
11#include "dawn/porting/config.hxx"
12
13namespace dawn
14{
21class CIOLeds : public CIOCommon
22{
23public:
24 enum
25 {
26 IO_LEDS_CFG_FIRST = 0,
27 IO_LEDS_CFG_INITVAL = 1,
28 IO_LEDS_CFG_LAST = 31
29 };
30
31 explicit CIOLeds(CDescObject &desc)
32 : CIOCommon(desc)
33 , fd(-1)
34 , initVal(0)
35 {
36 }
37
38 ~CIOLeds() override;
39
40#ifdef CONFIG_DAWN_OBJECT_HAS_NAME
41 const char *getClassNameStr() const override
42 {
43 return "led";
44 }
45#endif
46
47 int configure() override;
48 int init() override;
49 int deinit() override;
50 int getDataImpl(IODataCmn &data, size_t len) override;
51 int setDataImpl(IODataCmn &data) override;
52 size_t getDataSize() const override;
53 size_t getDataDim() const override;
54
55 bool isRead() const override
56 {
57 return true;
58 };
59
60 bool isWrite() const override
61 {
62 return true;
63 };
64
65 bool isNotify() const override
66 {
67 return false;
68 };
69
70 bool isBatch() const override
71 {
72 return false;
73 };
74
76
77 constexpr static SObjectId::ObjectId objectId(bool ts, uint16_t inst)
78 {
79 return ObjectIdHelper::create(ts, inst);
80 }
81
82 constexpr static SObjectCfg::ObjectCfgId cfgId(bool rw, uint8_t dtype, uint8_t size, uint8_t id)
83 {
86 }
87
88 constexpr static SObjectCfg::ObjectCfgId cfgIdInitVal(uint32_t val = 0)
89 {
90 return CIOLeds::cfgId(false, SObjectId::DTYPE_UINT32, 1, IO_LEDS_CFG_INITVAL);
91 }
92
93private:
94 char path[PATH_MAX] = {};
95 int fd;
96 uint32_t initVal;
97#ifdef CONFIG_DAWN_IO_TIMESTAMP
98 uint64_t ts;
99#endif
100
101 int configureDesc(const CDescObject &desc);
102};
103} // 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_LEDS
LED output.
Definition common.hxx:167
LED output I/O type for controlling LED indicators.
Definition leds.hxx:22
bool isBatch() const
Check if IO supports batch operations.
Definition leds.hxx:70
int init()
One-time initialize object after bindings are resolved.
Definition leds.cxx:91
int setDataImpl(IODataCmn &data)
Set data implementation (override in derived classes).
Definition leds.cxx:142
bool isNotify() const
Check if IO supports notifications.
Definition leds.hxx:65
int getDataImpl(IODataCmn &data, size_t len)
Get data implementation (override in derived classes).
Definition leds.cxx:114
bool isWrite() const
Check if IO supports write operations.
Definition leds.hxx:60
int deinit()
De-initialize object.
Definition leds.cxx:109
size_t getDataDim() const
Get data vector dimension.
Definition leds.cxx:171
int configure()
Configure object from descriptor data.
Definition leds.cxx:57
size_t getDataSize() const
Get data size in bytes.
Definition leds.cxx:166
bool isRead() const
Check if IO supports read operations.
Definition leds.hxx:55
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