Dawn Framework 1.0
Universal data acquisition framework for embedded systems
bitpack.hxx
1// dawn/include/dawn/prog/bitpack.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{
18// Forward declaration
19
20class CIOCommon;
21
36{
37public:
38 enum
39 {
40 PROG_BITPACK_CFG_FIRST = 0,
41 PROG_BITPACK_CFG_INPUTS = 1,
42 PROG_BITPACK_CFG_OUTPUT = 2,
43 PROG_BITPACK_CFG_LAST = 31
44 };
45
46 explicit CProgBitPack(CDescObject &desc);
47
48 ~CProgBitPack() override;
49
50#ifdef CONFIG_DAWN_OBJECT_HAS_NAME
51 const char *getClassNameStr() const override
52 {
53 return "bitpack";
54 }
55#endif
56
57 int configure() override;
58 int init() override;
59 int deinit() override;
60 int doStart() override;
61 int doStop() override;
62 bool hasThread() const override;
63
64 constexpr static SObjectId::ObjectId objectId(uint16_t inst)
65 {
67 SObjectId::OBJTYPE_PROG, CProgCommon::PROG_CLASS_BITPACK, SObjectId::DTYPE_ANY, 0, inst);
68 }
69
70 constexpr static SObjectCfg::ObjectCfgId cfgId(bool rw, uint8_t size, uint8_t id)
71 {
73 SObjectId::OBJTYPE_PROG, CProgCommon::PROG_CLASS_BITPACK, SObjectId::DTYPE_ANY, rw, size, id);
74 }
75
76 constexpr static SObjectCfg::ObjectCfgId cfgIdInputs(uint16_t size)
77 {
78 return CProgBitPack::cfgId(false, size, PROG_BITPACK_CFG_INPUTS);
79 }
80
81 constexpr static SObjectCfg::ObjectCfgId cfgIdOutput()
82 {
83 return CProgBitPack::cfgId(false, 1, PROG_BITPACK_CFG_OUTPUT);
84 }
85
86 constexpr static SObjectCfg::ObjectCfgId cfgIdIOBind(uint16_t = 0)
87 {
88 return CProgBitPack::cfgId(false, 0, 0);
89 }
90
91private:
92 struct SBitInput
93 {
94 CProgBitPack *owner;
95 CIOCommon *io;
97 uint32_t bit;
98 io_ddata_t *currentData;
99 };
100
101 CIOCommon *output;
102 SObjectId::ObjectId outputId;
103 std::vector<SBitInput> inputs;
104 io_ddata_t *outputData;
105 bool active;
106 bool registered;
107
108 static int ioNotifierCb(void *priv, io_ddata_t *data);
109
110 int configureDesc(const CDescObject &desc);
111 int allocInput(SObjectId::ObjectId ioId, uint32_t bit);
112 void updateOutput();
113};
114} // Namespace dawn
Descriptor wrapper for individual object configuration.
Base class for all I/O objects.
Definition common.hxx:27
Bit packer: combines multiple typed inputs into a single packed output bitstream.
Definition bitpack.hxx:36
int doStart()
Start implementation hook.
Definition bitpack.cxx:257
int configure()
Configure object from descriptor data.
Definition bitpack.cxx:133
int init()
One-time initialize object after bindings are resolved.
Definition bitpack.cxx:138
int doStop()
Stop implementation hook.
Definition bitpack.cxx:302
int deinit()
De-initialize object.
Definition bitpack.cxx:220
bool hasThread() const
Check if a background thread is active.
Definition bitpack.cxx:321
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