Dawn Framework 1.0
Universal data acquisition framework for embedded systems
bitsplit.hxx
1// dawn/include/dawn/prog/bitsplit.hxx
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5
6#pragma once
7
8#include <cstdint>
9#include <inttypes.h>
10#include <vector>
11
12#include "dawn/io/ddata.hxx"
13#include "dawn/porting/config.hxx"
14#include "dawn/prog/common.hxx"
15
16namespace dawn
17{
18class CIOCommon;
19
30{
31public:
32 enum
33 {
34 PROG_BITSPLIT_CFG_FIRST = 0,
35 PROG_BITSPLIT_CFG_IOBIND = 1,
36 PROG_BITSPLIT_CFG_BITS = 2,
37 PROG_BITSPLIT_CFG_LAST = 31
38 };
39
40 explicit CProgBitSplit(CDescObject &desc);
41 ~CProgBitSplit() override;
42
43#ifdef CONFIG_DAWN_OBJECT_HAS_NAME
44 const char *getClassNameStr() const override
45 {
46 return "bitsplit";
47 }
48#endif
49
50 int configure() override;
51 int init() override;
52 int deinit() override;
53 int doStart() override;
54 int doStop() override;
55 bool hasThread() const override;
56
57 constexpr static SObjectId::ObjectId objectId(uint16_t inst)
58 {
60 SObjectId::OBJTYPE_PROG, CProgCommon::PROG_CLASS_BITSPLIT, SObjectId::DTYPE_ANY, 0, inst);
61 }
62
63 constexpr static SObjectCfg::ObjectCfgId cfgId(bool rw, uint8_t size, uint8_t id)
64 {
66 CProgCommon::PROG_CLASS_BITSPLIT,
68 rw,
69 size,
70 id);
71 }
72
73 constexpr static SObjectCfg::ObjectCfgId cfgIdIOBind(uint16_t size = 2)
74 {
75 return CProgBitSplit::cfgId(false, size, PROG_BITSPLIT_CFG_IOBIND);
76 }
77
78 constexpr static SObjectCfg::ObjectCfgId cfgIdBits(uint16_t size = 2)
79 {
80 return CProgBitSplit::cfgId(false, size, PROG_BITSPLIT_CFG_BITS);
81 }
82
83private:
84 struct SBitSplitBind
85 {
86 CProgBitSplit *owner;
87 SObjectId::ObjectId sourceId;
88 SObjectId::ObjectId outputId;
89 CIOCommon *source;
90 CIOCommon *output;
91 io_ddata_t *sourceData;
92 io_ddata_t *outputData;
93 uint32_t bit;
94 };
95
96 std::vector<SBitSplitBind *> binds;
97 std::vector<uint32_t> bitPositions;
98 bool active;
99 bool registered;
100
101 static int ioNotifierCb(void *priv, io_ddata_t *data);
102
103 int configureDesc(const CDescObject &desc);
104 int allocBind(SObjectId::ObjectId sourceId, SObjectId::ObjectId outputId);
105 void refreshSource(SObjectId::ObjectId sourceId);
106 void updateBind(SBitSplitBind *bind, io_ddata_t *data);
107};
108} // Namespace dawn
Descriptor wrapper for individual object configuration.
Base class for all I/O objects.
Definition common.hxx:27
Bit demultiplexer: extracts configurable bit slices from the input into separate outputs.
Definition bitsplit.hxx:30
int configure()
Configure object from descriptor data.
Definition bitsplit.cxx:146
int doStart()
Start implementation hook.
Definition bitsplit.cxx:238
int doStop()
Stop implementation hook.
Definition bitsplit.cxx:273
int init()
One-time initialize object after bindings are resolved.
Definition bitsplit.cxx:151
int deinit()
De-initialize object.
Definition bitsplit.cxx:205
bool hasThread() const
Check if a background thread is active.
Definition bitsplit.cxx:292
Base class for all PROG (processing) objects.
Definition common.hxx:27
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_PROG
Program/algorithm object type.
Definition objectid.hxx:202
@ DTYPE_ANY
Wildcard data type (matches any actual type).
Definition objectid.hxx:68
uint32_t ObjectId
ObjectID type - single 32-bit value.
Definition objectid.hxx:44
static ObjectId objectId(uint8_t type, uint16_t cls, uint8_t dtype, uint8_t flags, uint16_t priv)
Construct 32-bit ObjectID from component fields.
Definition objectid.hxx:290
Heap-allocated dynamic I/O data buffer.
Definition ddata.hxx:21