Dawn Framework 1.0
Universal data acquisition framework for embedded systems
gpi.hxx
1// dawn/include/dawn/io/gpi.hxx
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5
6#pragma once
7
8#include "dawn/io/common.hxx"
9#include "dawn/porting/config.hxx"
10#include "dawn/porting/gpio.hxx"
11
12namespace dawn
13{
21class CIOGpi : public CIOCommon
22{
23public:
24 enum
25 {
26 IO_GPI_CFG_FIRST = 0,
27 IO_GPI_CFG_LAST = 31
28 };
29
30 explicit CIOGpi(CDescObject &desc)
31 : CIOCommon(desc)
32 , path()
33 , fd(-1)
34 {
35 }
36
37 ~CIOGpi() override;
38
39#ifdef CONFIG_DAWN_OBJECT_HAS_NAME
40 const char *getClassNameStr() const override
41 {
42 return "gpi";
43 }
44#endif
45
46 int configure() override;
47 int init() override;
48 int deinit() override;
49 int getDataImpl(IODataCmn &data, size_t len) override;
50
51#ifdef CONFIG_DAWN_IO_NOTIFY
52 int getFd() const override;
53#endif
54
55 size_t getDataSize() const override;
56 size_t getDataDim() const override;
57
58 bool isRead() const override
59 {
60 return true;
61 };
62
63 bool isWrite() const override
64 {
65 return false;
66 };
67
68 bool isNotify() const override
69 {
70#ifdef CONFIG_DAWN_IO_NOTIFY
71 // Determined at configure time: requires interrupt support from the
72 // underlying GPIO device (GPIOC_REGISTER).
73 return isNotifyIO;
74#else
75 return false;
76#endif
77 };
78
79 bool isBatch() const override
80 {
81 return false;
82 };
83
85
86 constexpr static SObjectId::ObjectId objectId(bool ts, uint16_t inst)
87 {
88 return ObjectIdHelper::create(ts, inst);
89 }
90
91private:
92 char path[PATH_MAX];
93 int fd;
94#ifdef CONFIG_DAWN_IO_NOTIFY
95 bool isNotifyIO;
96#endif
97
98 int configureDesc(const CDescObject &desc);
99};
100} // Namespace dawn
Descriptor wrapper for individual object configuration.
Template helper for creating ObjectIDs for I/O types.
Definition common.hxx:258
static SObjectId::ObjectId create(bool ts, uint16_t inst)
Create ObjectID with default data type.
Definition common.hxx:268
Base class for all I/O objects.
Definition common.hxx:27
virtual int getFd() const
Get file descriptor for notifications.
Definition common.hxx:447
GPIO Input (GPI) I/O type for reading digital input states.
Definition gpi.hxx:22
int configure()
Configure object from descriptor data.
Definition gpi.cxx:36
size_t getDataSize() const
Get data size in bytes.
Definition gpi.cxx:156
int getDataImpl(IODataCmn &data, size_t len)
Get data implementation (override in derived classes).
Definition gpi.cxx:106
size_t getDataDim() const
Get data vector dimension.
Definition gpi.cxx:161
bool isWrite() const
Check if IO supports write operations.
Definition gpi.hxx:63
int deinit()
De-initialize object.
Definition gpi.cxx:98
bool isBatch() const
Check if IO supports batch operations.
Definition gpi.hxx:79
bool isNotify() const
Check if IO supports notifications.
Definition gpi.hxx:68
int init()
One-time initialize object after bindings are resolved.
Definition gpi.cxx:87
bool isRead() const
Check if IO supports read operations.
Definition gpi.hxx:58
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
uint32_t ObjectId
ObjectID type - single 32-bit value.
Definition objectid.hxx:44