Dawn Framework 1.0
Universal data acquisition framework for embedded systems
adc_base.hxx
1// dawn/include/dawn/io/adc_base.hxx
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5
6#pragma once
7
8#include <limits.h>
9
10#include "dawn/io/common.hxx"
11#include "dawn/porting/adc.hxx"
12#include "dawn/porting/config.hxx"
13
14namespace dawn
15{
18class CIOAdcBase : public CIOCommon
19{
20public:
21 enum
22 {
23 IO_ADC_CFG_FIRST = 0,
24 IO_ADC_CFG_CHANLIST = 1,
25 IO_ADC_CFG_LAST = 31
26 };
27
28 explicit CIOAdcBase(CDescObject &desc)
29 : CIOCommon(desc)
30 , rdata(nullptr)
31 , fd(-1)
32 , tlen(getDtypeSize())
33 , chans(0)
34 , batch(0)
35 {
36 }
37
38 ~CIOAdcBase() override;
39
40 int configure() override;
41 int init() override;
42 int deinit() override;
43
44 int getFd() const override
45 {
46 return fd;
47 }
48
49 size_t getDataSize() const override;
50 size_t getDataDim() const override;
51
52protected:
53 int configureCommonDesc(const CDescObject &desc);
54 int configureDevice();
55 int ensureReadBuffer(size_t samples);
56 int readSamples(IODataCmn &data, size_t len);
57
58 int getFdInternal() const
59 {
60 return fd;
61 }
62
63 size_t getChans() const
64 {
65 return chans;
66 }
67
68 size_t getTlen() const
69 {
70 return tlen;
71 }
72
73 dawn::porting::adc_read_s *getRdata() const
74 {
75 return rdata;
76 }
77
78private:
80 char path[PATH_MAX] = {};
81 int fd;
82 size_t tlen;
83 uint8_t chans;
84 size_t batch;
85};
86
87} // Namespace dawn
Descriptor wrapper for individual object configuration.
Shared ADC base for fetch/sync/stream implementations.
Definition adc_base.hxx:19
int init()
One-time initialize object after bindings are resolved.
Definition adc_base.cxx:88
int deinit()
De-initialize object.
Definition adc_base.cxx:99
size_t getDataDim() const
Get data vector dimension.
Definition adc_base.cxx:117
int getFd() const
Get file descriptor for notifications.
Definition adc_base.hxx:44
int configure()
Configure object from descriptor data.
Definition adc_base.cxx:74
size_t getDataSize() const
Get data size in bytes.
Definition adc_base.cxx:112
Base class for all I/O objects.
Definition common.hxx:27
size_t getDtypeSize() const
Get size of this object's data type.
Definition object.cxx:195
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
ADC read data.
Definition adc.hxx:23