MeshX 0.4
This repository provides an implementation for Bluetooth Low Energy (BLE) Mesh network nodes. The project allows you to create BLE mesh nodes that can communicate with each other, enabling the development of smart home solutions or other IoT-based applications.
Loading...
Searching...
No Matches
meshx_io_types.hpp
Go to the documentation of this file.
1/**
2 * @file meshx_io_types.hpp
3 * @brief MeshX IO Type Definitions
4 *
5 * This file defines data structures and types for IO configuration.
6 *
7 * @author MeshX Team
8 * @date 2024
9 */
10
11#ifndef __MESHX_IO_TYPES_HPP
12#define __MESHX_IO_TYPES_HPP
13
14#include <cstdint>
15#include <cstddef>
16
17namespace meshx {
18
19/**
20 * @brief GPIO Mode enumeration
21 */
22enum class GpioMode {
23 INPUT = 0, /**< Input only mode */
24 OUTPUT, /**< Output only mode */
25 INPUT_OUTPUT, /**< Input and output mode */
26 OPEN_DRAIN, /**< Open drain output mode */
27 OPEN_DRAIN_INPUT_OUTPUT, /**< Open drain input/output mode */
28 PWM_OUTPUT, /**< PWM output mode */
29 MODE_MAX /**< Maximum mode value */
30};
31
32/**
33 * @brief GPIO Pull Resistor enumeration
34 */
35enum class GpioPull {
36 NONE = 0, /**< No pull resistor */
37 PULL_UP, /**< Pull-up resistor */
38 PULL_DOWN, /**< Pull-down resistor */
39 PULL_UP_DOWN, /**< Both pull-up and pull-down */
40 PULL_MAX /**< Maximum pull value */
41};
42
43/**
44 * @brief GPIO Drive Strength enumeration
45 */
46enum class GpioDrive {
47 WEAK = 0, /**< Weak drive strength */
48 MEDIUM, /**< Medium drive strength */
49 STRONG, /**< Strong drive strength */
50 MAX_STRONG, /**< Maximum strong drive strength */
51 DRIVE_MAX /**< Maximum drive value */
52};
53
54/**
55 * @brief GPIO Interrupt Trigger enumeration
56 */
57enum class GpioIntrTrigger {
58 DISABLED = 0, /**< Interrupt disabled */
59 POSITIVE_EDGE, /**< Positive edge trigger */
60 NEGATIVE_EDGE, /**< Negative edge trigger */
61 ANY_EDGE, /**< Any edge trigger */
62 LOW_LEVEL, /**< Low level trigger */
63 HIGH_LEVEL, /**< High level trigger */
64 INTR_MAX /**< Maximum interrupt type */
65};
66
67/**
68 * @brief Hosted Mode enumeration
69 */
70enum class HostedMode {
71 NON_HOSTED = 0, /**< Non-hosted mode (direct IO access) */
72 HOSTED, /**< Hosted mode (UART transport) */
73 TRANSITIONING /**< Mode transition in progress */
74};
75
76/**
77 * @brief IO Error Codes
78 */
79enum class IoError {
80 SUCCESS = 0, /**< Success */
81 INVALID_PIN, /**< Invalid pin number */
82 INVALID_MODE, /**< Invalid mode for operation */
83 INVALID_LEVEL, /**< Invalid level value */
84 INVALID_ARG, /**< Invalid argument */
85 INTR_NOT_SUPPORTED, /**< Interrupt not supported */
86 INTR_ALREADY_REGISTERED, /**< Interrupt already registered */
87 PWM_NOT_SUPPORTED, /**< PWM not supported */
88 PWM_INVALID_PARAM, /**< Invalid PWM parameter */
89 NOT_SUPPORTED, /**< Operation not supported */
90 NOT_INITIALIZED, /**< IO subsystem not initialized */
91 CONFIG_INVALID, /**< Invalid configuration */
92 HOSTED_MODE, /**< Operation not allowed in hosted mode */
93 KV_STORAGE, /**< KV Engine storage error */
94 SERIALIZATION, /**< Configuration serialization error */
95 ERROR_MAX /**< Maximum error value */
96};
97
98/**
99 * @brief Convert IO error to string
100 *
101 * @param error IO error code
102 * @return const char* Error string
103 */
104const char* ioErrorToString(IoError error);
105
106/**
107 * @brief Convert GPIO mode to string
108 *
109 * @param mode GPIO mode
110 * @return const char* Mode string
111 */
112const char* gpioModeToString(GpioMode mode);
113
114/**
115 * @brief Convert string to GPIO mode
116 *
117 * @param str Mode string
118 * @return GpioMode GPIO mode
119 */
120GpioMode stringToGpioMode(const char* str);
121
122/**
123 * @brief Convert GPIO pull to string
124 *
125 * @param pull GPIO pull setting
126 * @return const char* Pull string
127 */
128const char* gpioPullToString(GpioPull pull);
129
130/**
131 * @brief Convert string to GPIO pull
132 *
133 * @param str Pull string
134 * @return GpioPull GPIO pull setting
135 */
136GpioPull stringToGpioPull(const char* str);
137
138/**
139 * @brief Convert GPIO drive to string
140 *
141 * @param drive GPIO drive strength
142 * @return const char* Drive string
143 */
144const char* gpioDriveToString(GpioDrive drive);
145
146/**
147 * @brief Convert string to GPIO drive
148 *
149 * @param str Drive string
150 * @return GpioDrive GPIO drive strength
151 */
153
154/**
155 * @brief Convert interrupt trigger to string
156 *
157 * @param trigger Interrupt trigger type
158 * @return const char* Trigger string
159 */
161
162/**
163 * @brief Convert string to interrupt trigger
164 *
165 * @param str Trigger string
166 * @return GpioIntrTrigger Interrupt trigger type
167 */
169
170} // namespace meshx
171
172#endif /* __MESHX_IO_TYPES_HPP */
Definition meshx_io_factory.hpp:19
const char * gpioDriveToString(GpioDrive drive)
Convert GPIO drive to string.
GpioIntrTrigger stringToIntrTrigger(const char *str)
Convert string to interrupt trigger.
const char * gpioPullToString(GpioPull pull)
Convert GPIO pull to string.
GpioPull
GPIO Pull Resistor enumeration.
Definition meshx_io_types.hpp:35
@ PULL_UP
Definition meshx_io_types.hpp:37
@ PULL_DOWN
Definition meshx_io_types.hpp:38
@ PULL_MAX
Definition meshx_io_types.hpp:40
@ NONE
Definition meshx_io_types.hpp:36
@ PULL_UP_DOWN
Definition meshx_io_types.hpp:39
const char * intrTriggerToString(GpioIntrTrigger trigger)
Convert interrupt trigger to string.
GpioPull stringToGpioPull(const char *str)
Convert string to GPIO pull.
IoError
IO Error Codes.
Definition meshx_io_types.hpp:79
@ NOT_INITIALIZED
Definition meshx_io_types.hpp:90
@ PWM_NOT_SUPPORTED
Definition meshx_io_types.hpp:87
@ SERIALIZATION
Definition meshx_io_types.hpp:94
@ INVALID_MODE
Definition meshx_io_types.hpp:82
@ CONFIG_INVALID
Definition meshx_io_types.hpp:91
@ NOT_SUPPORTED
Definition meshx_io_types.hpp:89
@ INTR_ALREADY_REGISTERED
Definition meshx_io_types.hpp:86
@ INTR_NOT_SUPPORTED
Definition meshx_io_types.hpp:85
@ ERROR_MAX
Definition meshx_io_types.hpp:95
@ INVALID_ARG
Definition meshx_io_types.hpp:84
@ INVALID_PIN
Definition meshx_io_types.hpp:81
@ KV_STORAGE
Definition meshx_io_types.hpp:93
@ HOSTED_MODE
Definition meshx_io_types.hpp:92
@ SUCCESS
Definition meshx_io_types.hpp:80
@ PWM_INVALID_PARAM
Definition meshx_io_types.hpp:88
@ INVALID_LEVEL
Definition meshx_io_types.hpp:83
GpioMode
GPIO Mode enumeration.
Definition meshx_io_types.hpp:22
@ MODE_MAX
Definition meshx_io_types.hpp:29
@ PWM_OUTPUT
Definition meshx_io_types.hpp:28
@ OUTPUT
Definition meshx_io_types.hpp:24
@ OPEN_DRAIN_INPUT_OUTPUT
Definition meshx_io_types.hpp:27
@ INPUT
Definition meshx_io_types.hpp:23
@ INPUT_OUTPUT
Definition meshx_io_types.hpp:25
@ OPEN_DRAIN
Definition meshx_io_types.hpp:26
HostedMode
Hosted Mode enumeration.
Definition meshx_io_types.hpp:70
@ HOSTED
Definition meshx_io_types.hpp:72
@ NON_HOSTED
Definition meshx_io_types.hpp:71
@ TRANSITIONING
Definition meshx_io_types.hpp:73
GpioDrive stringToGpioDrive(const char *str)
Convert string to GPIO drive.
GpioDrive
GPIO Drive Strength enumeration.
Definition meshx_io_types.hpp:46
@ WEAK
Definition meshx_io_types.hpp:47
@ STRONG
Definition meshx_io_types.hpp:49
@ DRIVE_MAX
Definition meshx_io_types.hpp:51
@ MAX_STRONG
Definition meshx_io_types.hpp:50
@ MEDIUM
Definition meshx_io_types.hpp:48
const char * gpioModeToString(GpioMode mode)
Convert GPIO mode to string.
const char * ioErrorToString(IoError error)
Convert IO error to string.
GpioIntrTrigger
GPIO Interrupt Trigger enumeration.
Definition meshx_io_types.hpp:57
@ DISABLED
Definition meshx_io_types.hpp:58
@ NEGATIVE_EDGE
Definition meshx_io_types.hpp:60
@ ANY_EDGE
Definition meshx_io_types.hpp:61
@ LOW_LEVEL
Definition meshx_io_types.hpp:62
@ HIGH_LEVEL
Definition meshx_io_types.hpp:63
@ POSITIVE_EDGE
Definition meshx_io_types.hpp:59
@ INTR_MAX
Definition meshx_io_types.hpp:64
GpioMode stringToGpioMode(const char *str)
Convert string to GPIO mode.