Dawn Framework 1.0
Universal data acquisition framework for embedded systems
trigger.hxx
1// dawn/include/dawn/io/trigger.hxx
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5
6#pragma once
7
8#include <vector>
9
10#include "dawn/common/object.hxx"
11#include "dawn/io/common.hxx"
12#include "dawn/porting/config.hxx"
13
14namespace dawn
15{
18class CIOTrigger : public CIOCommon
19{
20public:
21 enum
22 {
23 IO_TRIGGER_CFG_FIRST = 0,
26 IO_TRIGGER_CFG_LAST = 31
27 };
28
29 enum
30 {
31 TRIG_ALLOW_RESET = (1 << 0),
34 TRIG_ALLOW_TRIGGER3 = (1 << 3)
35 };
36
37 explicit CIOTrigger(CDescObject &desc)
38 : CIOCommon(desc)
39 , allowed(0)
40 {
41 }
42
43 ~CIOTrigger() override;
44
45#ifdef CONFIG_DAWN_OBJECT_HAS_NAME
46 const char *getClassNameStr() const override
47 {
48 return "trigger";
49 }
50#endif
51
52 int configure() override;
53 int deinit() override;
54 int getDataImpl(IODataCmn &data, size_t len) override;
55 int setDataImpl(IODataCmn &data) override;
56 size_t getDataSize() const override;
57 size_t getDataDim() const override;
58
59 bool isRead() const override
60 {
61 return false;
62 }
63
64 bool isWrite() const override
65 {
66 return true;
67 }
68
69 bool isNotify() const override
70 {
71 return false;
72 }
73
74 bool isBatch() const override
75 {
76 return false;
77 }
78
79 int bind(CObject *obj);
80
81 std::vector<SObjectId::ObjectId> ids;
82
84
85 constexpr static SObjectId::ObjectId objectId(uint16_t inst)
86 {
87 return ObjectIdHelper::create(inst);
88 }
89
90 constexpr static SObjectCfg::ObjectCfgId cfgIdAllocObj(size_t n = 1)
91 {
92 return CIOTrigger::cfgId(false, static_cast<uint8_t>(n), IO_TRIGGER_CFG_ALLOCOBJ);
93 }
94
95 constexpr static SObjectCfg::ObjectCfgId cfgIdAllowed()
96 {
97 return CIOTrigger::cfgId(false, 1, IO_TRIGGER_CFG_ALLOWED);
98 }
99
100 constexpr static SObjectCfg::ObjectCfgId cfgId(bool rw, uint8_t size, uint8_t id)
101 {
104 }
105
106private:
107 uint32_t allowed;
108 std::vector<CObject *> targets;
109
110 int configureDesc(const CDescObject &desc);
111};
112
113} // namespace dawn
Descriptor wrapper for individual object configuration.
Template helper for creating ObjectIDs for I/O types without timestamp support.
Definition common.hxx:303
static SObjectId::ObjectId create(uint16_t inst)
Create ObjectID with fixed data type and no timestamp.
Definition common.hxx:312
Base class for all I/O objects.
Definition common.hxx:27
@ IO_CLASS_TRIGGER
Trigger I/O.
Definition common.hxx:91
Trigger I/O for dispatching commands to bound objects.
Definition trigger.hxx:19
int configure()
Configure object from descriptor data.
Definition trigger.cxx:74
size_t getDataDim() const
Get data vector dimension.
Definition trigger.cxx:171
bool isBatch() const
Check if IO supports batch operations.
Definition trigger.hxx:74
@ IO_TRIGGER_CFG_ALLOCOBJ
Bound object ID list.
Definition trigger.hxx:24
@ IO_TRIGGER_CFG_ALLOWED
Allowed commands bitmask.
Definition trigger.hxx:25
int setDataImpl(IODataCmn &data)
Set data implementation (override in derived classes).
Definition trigger.cxx:101
std::vector< SObjectId::ObjectId > ids
Object IDs to resolve; populated during configure().
Definition trigger.hxx:81
bool isNotify() const
Check if IO supports notifications.
Definition trigger.hxx:69
int getDataImpl(IODataCmn &data, size_t len)
Get data implementation (override in derived classes).
Definition trigger.cxx:94
bool isRead() const
Check if IO supports read operations.
Definition trigger.hxx:59
int deinit()
De-initialize object.
Definition trigger.cxx:89
@ TRIG_ALLOW_TRIGGER3
Allow CMD_TRIGGER3 command.
Definition trigger.hxx:34
@ TRIG_ALLOW_TRIGGER1
Allow CMD_TRIGGER1 command.
Definition trigger.hxx:32
@ TRIG_ALLOW_RESET
Allow CMD_RESET command.
Definition trigger.hxx:31
@ TRIG_ALLOW_TRIGGER2
Allow CMD_TRIGGER2 command.
Definition trigger.hxx:33
size_t getDataSize() const
Get data size in bytes.
Definition trigger.cxx:166
bool isWrite() const
Check if IO supports write operations.
Definition trigger.hxx:64
Base class for all Dawn objects (IOs, Programs, Protocols).
Definition object.hxx:28
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
@ OBJTYPE_IO
Input/Output object type.
Definition objectid.hxx:184
@ DTYPE_UINT8
Unsigned 8-bit integer (0 to 255).
Definition objectid.hxx:80
uint32_t ObjectId
ObjectID type - single 32-bit value.
Definition objectid.hxx:44