Dawn Framework 1.0
Universal data acquisition framework for embedded systems
buttons.hxx
1// dawn/include/dawn/io/buttons.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
13namespace dawn
14{
22class CIOButtons : public CIOCommon
23{
24public:
25 enum
26 {
27 IO_BUTTONS_CFG_FIRST = 0,
28 IO_BUTTONS_CFG_LAST = 31
29 };
30
31 explicit CIOButtons(CDescObject &desc)
32 : CIOCommon(desc)
33 , fd(-1)
34 {
35 }
36
37 ~CIOButtons() override;
38
39#ifdef CONFIG_DAWN_OBJECT_HAS_NAME
40 const char *getClassNameStr() const override
41 {
42 return "button";
43 }
44#endif
45
46 int configure() override;
47 int deinit() override;
48 int getDataImpl(IODataCmn &data, size_t len) override;
49
50#ifdef CONFIG_DAWN_IO_NOTIFY
51 int getFd() const override;
52#endif
53
54 size_t getDataSize() const override;
55 size_t getDataDim() const override;
56
57 bool isRead() const override
58 {
59 return true;
60 };
61
62 bool isWrite() const override
63 {
64 return false;
65 };
66
67 bool isNotify() const override
68 {
69 return true;
70 };
71
72 bool isBatch() const override
73 {
74 return false;
75 };
76
78
79 constexpr static SObjectId::ObjectId objectId(bool ts, uint16_t inst)
80 {
81 return ObjectIdHelper::create(ts, inst);
82 }
83
84 constexpr static SObjectCfg::ObjectCfgId cfgId(bool rw, uint8_t dtype, uint8_t size, uint8_t id)
85 {
88 }
89
90private:
91 char path[PATH_MAX] = {};
92 int fd;
93
94 int configureDesc(const CDescObject &desc);
95};
96} // Namespace dawn
Descriptor wrapper for individual object configuration.
Button input I/O type for reading button/switch states.
Definition buttons.hxx:23
int deinit()
De-initialize object.
Definition buttons.cxx:72
int getDataImpl(IODataCmn &data, size_t len)
Get data implementation (override in derived classes).
Definition buttons.cxx:80
bool isWrite() const
Check if IO supports write operations.
Definition buttons.hxx:62
int configure()
Configure object from descriptor data.
Definition buttons.cxx:38
bool isRead() const
Check if IO supports read operations.
Definition buttons.hxx:57
bool isBatch() const
Check if IO supports batch operations.
Definition buttons.hxx:72
size_t getDataSize() const
Get data size in bytes.
Definition buttons.cxx:119
bool isNotify() const
Check if IO supports notifications.
Definition buttons.hxx:67
size_t getDataDim() const
Get data vector dimension.
Definition buttons.cxx:124
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
virtual int getFd() const
Get file descriptor for notifications.
Definition common.hxx:425
@ IO_CLASS_BUTTONS
Button input.
Definition common.hxx:166
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