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_gpio_platform.h
Go to the documentation of this file.
1/**
2 * @file meshx_gpio_platform.h
3 * @brief MeshX GPIO Platform Interface
4 *
5 * This file defines the platform-specific interface for GPIO implementations.
6 * BSP implementations must provide these functions for GPIO operations.
7 *
8 * @author MeshX Team
9 * @date 2024
10 */
11
12#ifndef __MESHX_GPIO_PLATFORM_H
13#define __MESHX_GPIO_PLATFORM_H
14
15#include "meshx_gpio.h"
16#include "meshx_pwm.h"
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22/**
23 * @brief Platform-specific GPIO initialization
24 *
25 * This function initializes the platform-specific GPIO hardware.
26 *
27 * @return meshx_err_t MESHX_SUCCESS on success, error code on failure
28 */
30
31/**
32 * @brief Platform-specific GPIO deinitialization
33 *
34 * This function deinitializes the platform-specific GPIO hardware.
35 *
36 * @return meshx_err_t MESHX_SUCCESS on success, error code on failure
37 */
39
40/**
41 * @brief Platform-specific pin level set
42 *
43 * @param physical_pin Physical pin number (platform-specific)
44 * @param level Pin level (0 = low, 1 = high)
45 * @return meshx_err_t MESHX_SUCCESS on success, error code on failure
46 */
47meshx_err_t meshx_gpio_platform_set_level(uint8_t physical_pin, uint8_t level);
48
49/**
50 * @brief Platform-specific pin level get
51 *
52 * @param physical_pin Physical pin number (platform-specific)
53 * @param[out] level Pointer to store pin level
54 * @return meshx_err_t MESHX_SUCCESS on success, error code on failure
55 */
56meshx_err_t meshx_gpio_platform_get_level(uint8_t physical_pin, uint8_t *level);
57
58/**
59 * @brief Platform-specific pin mode configuration
60 *
61 * @param physical_pin Physical pin number (platform-specific)
62 * @param mode Pin mode (meshx_gpio_mode_t)
63 * @param pull Pull resistor setting (meshx_gpio_pull_t)
64 * @param drive Drive strength (meshx_gpio_drive_t)
65 * @return meshx_err_t MESHX_SUCCESS on success, error code on failure
66 */
70 meshx_gpio_drive_t drive);
71
72/**
73 * @brief Platform-specific interrupt registration
74 *
75 * @param physical_pin Physical pin number (platform-specific)
76 * @param intr_type Interrupt trigger type
77 * @param isr_handler Interrupt service routine handler
78 * @param arg Argument passed to ISR handler
79 * @return meshx_err_t MESHX_SUCCESS on success, error code on failure
80 */
82 meshx_gpio_intr_type_t intr_type,
83 void (*isr_handler)(void*),
84 void *arg);
85
86/**
87 * @brief Platform-specific interrupt unregistration
88 *
89 * @param physical_pin Physical pin number (platform-specific)
90 * @return meshx_err_t MESHX_SUCCESS on success, error code on failure
91 */
93
94/**
95 * @brief Platform-specific interrupt enable/disable
96 *
97 * @param physical_pin Physical pin number (platform-specific)
98 * @param enable true to enable, false to disable
99 * @return meshx_err_t MESHX_SUCCESS on success, error code on failure
100 */
101meshx_err_t meshx_gpio_platform_intr_enable(uint8_t physical_pin, bool enable);
102
103/**
104 * @brief Platform-specific PWM initialization
105 *
106 * @return meshx_err_t MESHX_SUCCESS on success, error code on failure
107 */
109
110/**
111 * @brief Platform-specific PWM deinitialization
112 *
113 * @return meshx_err_t MESHX_SUCCESS on success, error code on failure
114 */
116
117/**
118 * @brief Platform-specific PWM start
119 *
120 * @param physical_pin Physical pin number (platform-specific)
121 * @param frequency PWM frequency in Hz
122 * @param duty_cycle Duty cycle (0-100%)
123 * @param resolution PWM resolution in bits
124 * @return meshx_err_t MESHX_SUCCESS on success, error code on failure
125 */
127 uint32_t frequency,
128 uint8_t duty_cycle,
129 uint8_t resolution);
130
131/**
132 * @brief Platform-specific PWM stop
133 *
134 * @param physical_pin Physical pin number (platform-specific)
135 * @return meshx_err_t MESHX_SUCCESS on success, error code on failure
136 */
138
139/**
140 * @brief Platform-specific PWM duty cycle set
141 *
142 * @param physical_pin Physical pin number (platform-specific)
143 * @param duty_cycle Duty cycle (0-100%)
144 * @return meshx_err_t MESHX_SUCCESS on success, error code on failure
145 */
146meshx_err_t meshx_pwm_platform_set_duty_cycle(uint8_t physical_pin, uint8_t duty_cycle);
147
148/**
149 * @brief Platform-specific PWM frequency set
150 *
151 * @param physical_pin Physical pin number (platform-specific)
152 * @param frequency Frequency in Hz
153 * @return meshx_err_t MESHX_SUCCESS on success, error code on failure
154 */
155meshx_err_t meshx_pwm_platform_set_frequency(uint8_t physical_pin, uint32_t frequency);
156
157/**
158 * @brief Platform-specific IO function execution
159 *
160 * This is the function-based API for extensible IO operations.
161 * BSP implementations must support the standard IO functions and
162 * can optionally support custom functions.
163 *
164 * @param physical_pin Physical pin number (platform-specific)
165 * @param function IO function to execute (meshx_io_function_t)
166 * @param args Function arguments vector
167 * @param arg_count Number of arguments in the vector
168 * @return meshx_err_t MESHX_SUCCESS on success, error code on failure
169 */
171 meshx_io_function_t function,
172 const uint32_t *args,
173 uint8_t arg_count);
174
175/**
176 * @brief Platform-specific custom function registration
177 *
178 * BSP implementations can use this to register custom IO functions
179 * that are not part of the standard IO function set.
180 *
181 * @param function_id Custom function ID
182 * @param handler Function handler
183 * @param user_data User data for the handler
184 * @return meshx_err_t MESHX_SUCCESS on success, error code on failure
185 */
187 meshx_err_t (*handler)(uint8_t physical_pin,
188 const uint32_t *args,
189 uint8_t arg_count,
190 void *user_data),
191 void *user_data);
192
193#ifdef __cplusplus
194}
195#endif
196
197#endif /* __MESHX_GPIO_PLATFORM_H */
meshx_err_t
MeshX Error Codes.
Definition meshx_err.h:43
MeshX GPIO Interface.
meshx_gpio_pull_t
GPIO Pull Resistor Settings.
Definition meshx_gpio.h:41
meshx_gpio_mode_t
GPIO Pin Modes.
Definition meshx_gpio.h:28
meshx_io_function_t
IO Function Types for function-based API.
Definition meshx_gpio.h:63
meshx_gpio_drive_t
GPIO Drive Strength.
Definition meshx_gpio.h:52
meshx_err_t meshx_gpio_platform_deinit(void)
Platform-specific GPIO deinitialization.
meshx_err_t meshx_pwm_platform_deinit(void)
Platform-specific PWM deinitialization.
meshx_err_t meshx_pwm_platform_set_duty_cycle(uint8_t physical_pin, uint8_t duty_cycle)
Platform-specific PWM duty cycle set.
meshx_err_t meshx_gpio_platform_get_level(uint8_t physical_pin, uint8_t *level)
Platform-specific pin level get.
meshx_err_t meshx_pwm_platform_start(uint8_t physical_pin, uint32_t frequency, uint8_t duty_cycle, uint8_t resolution)
Platform-specific PWM start.
meshx_err_t meshx_gpio_platform_unregister_intr(uint8_t physical_pin)
Platform-specific interrupt unregistration.
meshx_err_t meshx_pwm_platform_stop(uint8_t physical_pin)
Platform-specific PWM stop.
meshx_err_t meshx_gpio_platform_init(void)
Platform-specific GPIO initialization.
meshx_err_t meshx_gpio_platform_set_level(uint8_t physical_pin, uint8_t level)
Platform-specific pin level set.
meshx_err_t meshx_pwm_platform_init(void)
Platform-specific PWM initialization.
meshx_err_t meshx_io_platform_execute_function(uint8_t physical_pin, meshx_io_function_t function, const uint32_t *args, uint8_t arg_count)
Platform-specific IO function execution.
meshx_err_t meshx_io_platform_register_custom_function(uint16_t function_id, meshx_err_t(*handler)(uint8_t physical_pin, const uint32_t *args, uint8_t arg_count, void *user_data), void *user_data)
Platform-specific custom function registration.
meshx_err_t meshx_gpio_platform_intr_enable(uint8_t physical_pin, bool enable)
Platform-specific interrupt enable/disable.
meshx_err_t meshx_gpio_platform_register_intr(uint8_t physical_pin, meshx_gpio_intr_type_t intr_type, void(*isr_handler)(void *), void *arg)
Platform-specific interrupt registration.
meshx_err_t meshx_gpio_platform_configure_pin(uint8_t physical_pin, meshx_gpio_mode_t mode, meshx_gpio_pull_t pull, meshx_gpio_drive_t drive)
Platform-specific pin mode configuration.
meshx_err_t meshx_pwm_platform_set_frequency(uint8_t physical_pin, uint32_t frequency)
Platform-specific PWM frequency set.
meshx_gpio_intr_type_t
GPIO Interrupt Trigger Types.
Definition meshx_gpio_types.h:28
MeshX PWM Interface.