Dawn Framework 1.0
Universal data acquisition framework for embedded systems
dac.hxx
1// dawn/include/dawn/io/dac.hxx
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5
6#pragma once
7
8#include <mutex>
9
10#include "dawn/io/common.hxx"
11#include "dawn/porting/config.hxx"
12#include "dawn/porting/dac.hxx"
13
14namespace dawn
15{
22class CIODac : public CIOCommon
23{
24public:
25 enum
26 {
27 IO_DAC_CFG_FIRST = 0,
28 IO_DAC_CFG_LAST = 31
29 };
30
31 explicit CIODac(CDescObject &desc)
32 : CIOCommon(desc)
33 , path()
34 , fd(-1)
35 , channels(1)
36 {
37 }
38
39 ~CIODac() override;
40
41#ifdef CONFIG_DAWN_OBJECT_HAS_NAME
42 const char *getClassNameStr() const override
43 {
44 return "dac";
45 }
46#endif
47
48 int configure() override;
49 int deinit() override;
50 int setDataImpl(IODataCmn &data) override;
51 size_t getDataSize() const override;
52 size_t getDataDim() const override;
53
54 bool isRead() const override
55 {
56 return false;
57 };
58
59 bool isWrite() const override
60 {
61 return true;
62 };
63
64 bool isNotify() const override
65 {
66 return false;
67 };
68
69 bool isBatch() const override
70 {
71 return false;
72 };
73
75
76 constexpr static SObjectId::ObjectId objectId(bool ts, uint16_t inst)
77 {
78 return ObjectIdHelper::create(ts, inst);
79 }
80
81 constexpr static SObjectCfg::ObjectCfgId cfgId(bool rw, uint8_t dtype, uint8_t size, uint8_t id)
82 {
85 }
86
87private:
88 char path[PATH_MAX];
89 int fd;
90 uint8_t channels;
91#ifdef CONFIG_DAWN_IO_TIMESTAMP
92 uint64_t ts;
93#endif
94
95 int configureDesc(const CDescObject &desc);
96};
97} // Namespace dawn
Descriptor wrapper for individual object configuration.
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
Base class for all I/O objects.
Definition common.hxx:27
@ IO_CLASS_DAC
Digital-to-analog converter.
Definition common.hxx:176
Digital-to-Analog Converter (DAC) output I/O type.
Definition dac.hxx:23
size_t getDataSize() const
Get data size in bytes.
Definition dac.cxx:123
int configure()
Configure object from descriptor data.
Definition dac.cxx:36
bool isWrite() const
Check if IO supports write operations.
Definition dac.hxx:59
bool isNotify() const
Check if IO supports notifications.
Definition dac.hxx:64
bool isBatch() const
Check if IO supports batch operations.
Definition dac.hxx:69
int deinit()
De-initialize object.
Definition dac.cxx:81
bool isRead() const
Check if IO supports read operations.
Definition dac.hxx:54
size_t getDataDim() const
Get data vector dimension.
Definition dac.cxx:128
int setDataImpl(IODataCmn &data)
Set data implementation (override in derived classes).
Definition dac.cxx:87
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
uint32_t ObjectId
ObjectID type - single 32-bit value.
Definition objectid.hxx:44