Dawn Framework 1.0
Universal data acquisition framework for embedded systems
adc_stream.hxx
1// dawn/include/dawn/io/adc_stream.hxx
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5
6#pragma once
7
8#include "dawn/io/adc_base.hxx"
9
10namespace dawn
11{
15{
16public:
17 enum
18 {
19 IO_ADC_STREAM_CFG_FIRST = 0,
20 IO_ADC_STREAM_CFG_BATCH_SIZE = 1,
21 IO_ADC_STREAM_CFG_LAST = 31
22 };
23
24 explicit CIOAdcStream(CDescObject &desc)
25 : CIOAdcBase(desc)
26 , batchSize(1)
27 {
28 }
29
30#ifdef CONFIG_DAWN_OBJECT_HAS_NAME
31 const char *getClassNameStr() const override
32 {
33 return "adc_stream";
34 }
35#endif
36
37 int configure() override;
38 int getDataImpl(IODataCmn &data, size_t len) override;
39 int doStart() override;
40 int doStop() override;
41 int trigger(uint8_t cmd) override;
42
43 bool isRead() const override
44 {
45 return true;
46 }
47
48 bool isWrite() const override
49 {
50 return false;
51 }
52
53 bool isNotify() const override
54 {
55 return true;
56 }
57
58 bool isBatch() const override
59 {
60 return true;
61 }
62
64
65 constexpr static SObjectId::ObjectId objectId(bool ts, uint16_t inst)
66 {
67 return ObjectIdHelper::create(ts, inst);
68 }
69
70 constexpr static SObjectCfg::ObjectCfgId cfgId(bool rw, uint8_t dtype, uint8_t size, uint8_t id)
71 {
74 }
75
76 constexpr static SObjectCfg::ObjectCfgId cfgIdBatchSize(bool rw = false)
77 {
78 return CIOAdcStream::cfgId(rw, SObjectId::DTYPE_UINT32, 1, IO_ADC_STREAM_CFG_BATCH_SIZE);
79 }
80
81protected:
82 int onSetObjConfig(SObjectCfg::ObjectCfgId objcfg, uint32_t *data, size_t len) override;
83
84private:
85 size_t batchSize;
86
87 int configureDesc(const CDescObject &desc);
88};
89
90} // Namespace dawn
Descriptor wrapper for individual object configuration.
Shared ADC base for fetch/sync/stream implementations.
Definition adc_base.hxx:19
High-throughput batched ADC stream I/O.
bool isBatch() const
Check if IO supports batch operations.
int onSetObjConfig(SObjectCfg::ObjectCfgId objcfg, uint32_t *data, size_t len)
Pre-update hook for runtime configuration writes.
bool isWrite() const
Check if IO supports write operations.
bool isNotify() const
Check if IO supports notifications.
int doStart()
Start implementation hook.
int getDataImpl(IODataCmn &data, size_t len)
Get data implementation (override in derived classes).
int configure()
Configure object from descriptor data.
int trigger(uint8_t cmd)
Execute a trigger command.
int doStop()
Stop implementation hook.
bool isRead() const
Check if IO supports read operations.
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
@ IO_CLASS_ADC_STREAM
ADC stream (batch/high-throughput)
Definition common.hxx:179
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