Dawn Framework 1.0
Universal data acquisition framework for embedded systems
adc_sync.hxx
1// dawn/include/dawn/io/adc_sync.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{
14class CIOAdcSync : public CIOAdcBase
15{
16public:
17 enum
18 {
19 IO_ADC_SYNC_CFG_FIRST = 0,
20 IO_ADC_SYNC_CFG_TRIGGER_FREQ = 1,
21 IO_ADC_SYNC_CFG_LAST = 31
22 };
23
24 explicit CIOAdcSync(CDescObject &desc)
25 : CIOAdcBase(desc)
26 , triggerFreqHz(0)
27 , hasTriggerFreq(false)
28 {
29 }
30
31#ifdef CONFIG_DAWN_OBJECT_HAS_NAME
32 const char *getClassNameStr() const override
33 {
34 return "adc_sync";
35 }
36#endif
37
38 int configure() override;
39 int getDataImpl(IODataCmn &data, size_t len) override;
40 int doStart() override;
41 int doStop() override;
42 int trigger(uint8_t cmd) override;
43
44 bool isRead() const override
45 {
46 return true;
47 }
48
49 bool isWrite() const override
50 {
51 return false;
52 }
53
54 bool isNotify() const override
55 {
56 return true;
57 }
58
59 bool isBatch() const override
60 {
61 return false;
62 }
63
65
66 constexpr static SObjectId::ObjectId objectId(bool ts, uint16_t inst)
67 {
68 return ObjectIdHelper::create(ts, inst);
69 }
70
71 constexpr static SObjectCfg::ObjectCfgId cfgId(bool rw, uint8_t dtype, uint8_t size, uint8_t id)
72 {
75 }
76
77 constexpr static SObjectCfg::ObjectCfgId cfgIdTriggerFreq(bool rw = false)
78 {
79 return CIOAdcSync::cfgId(rw, SObjectId::DTYPE_UINT32, 1, IO_ADC_SYNC_CFG_TRIGGER_FREQ);
80 }
81
82protected:
83 int onSetObjConfig(SObjectCfg::ObjectCfgId objcfg, uint32_t *data, size_t len) override;
84
85private:
86 uint32_t triggerFreqHz;
87 bool hasTriggerFreq;
88
89 int configureDesc(const CDescObject &desc);
90};
91
92} // Namespace dawn
Descriptor wrapper for individual object configuration.
Shared ADC base for fetch/sync/stream implementations.
Definition adc_base.hxx:19
Hardware-triggered single-sample ADC I/O.
Definition adc_sync.hxx:15
int getDataImpl(IODataCmn &data, size_t len)
Get data implementation (override in derived classes).
Definition adc_sync.cxx:103
int doStop()
Stop implementation hook.
Definition adc_sync.cxx:118
int trigger(uint8_t cmd)
Execute a trigger command.
Definition adc_sync.cxx:123
int configure()
Configure object from descriptor data.
Definition adc_sync.cxx:74
bool isNotify() const
Check if IO supports notifications.
Definition adc_sync.hxx:54
bool isBatch() const
Check if IO supports batch operations.
Definition adc_sync.hxx:59
bool isWrite() const
Check if IO supports write operations.
Definition adc_sync.hxx:49
int doStart()
Start implementation hook.
Definition adc_sync.cxx:113
int onSetObjConfig(SObjectCfg::ObjectCfgId objcfg, uint32_t *data, size_t len)
Pre-update hook for runtime configuration writes.
Definition adc_sync.cxx:129
bool isRead() const
Check if IO supports read operations.
Definition adc_sync.hxx:44
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_SYNC
ADC sync (HW-triggered control loop)
Definition common.hxx:178
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