|
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.
|
MeshX GPIO Interface. More...
#include <stdint.h>#include <stdbool.h>#include <stddef.h>#include "../../inc/meshx_err.h"#include "meshx_gpio_types.h"Go to the source code of this file.
Typedefs | |
| typedef void(* | meshx_gpio_intr_cb_t) (uint8_t logical_pin, void *user_data) |
| GPIO Interrupt Callback Function. | |
| typedef void(* | meshx_gpio_hosted_event_cb_t) (const meshx_gpio_hosted_event_t *event) |
| Register callback for GPIO hosted mode events. | |
Enumerations | |
| enum | meshx_gpio_mode_t { MESHX_GPIO_MODE_INPUT = 0 , MESHX_GPIO_MODE_OUTPUT , MESHX_GPIO_MODE_INPUT_OUTPUT , MESHX_GPIO_MODE_OPEN_DRAIN , MESHX_GPIO_MODE_OPEN_DRAIN_INPUT_OUTPUT , MESHX_GPIO_MODE_PWM_OUTPUT , MESHX_GPIO_MODE_MAX } |
| GPIO Pin Modes. More... | |
| enum | meshx_gpio_pull_t { MESHX_GPIO_PULL_NONE = 0 , MESHX_GPIO_PULL_UP , MESHX_GPIO_PULL_DOWN , MESHX_GPIO_PULL_UP_DOWN , MESHX_GPIO_PULL_MAX } |
| GPIO Pull Resistor Settings. More... | |
| enum | meshx_gpio_drive_t { MESHX_GPIO_DRIVE_WEAK = 0 , MESHX_GPIO_DRIVE_MEDIUM , MESHX_GPIO_DRIVE_STRONG , MESHX_GPIO_DRIVE_MAX_STRONG , MESHX_GPIO_DRIVE_MAX } |
| GPIO Drive Strength. More... | |
| enum | meshx_io_function_t { MESHX_IO_FUNCTION_SET_LEVEL = 0 , MESHX_IO_FUNCTION_GET_LEVEL , MESHX_IO_FUNCTION_TOGGLE , MESHX_IO_FUNCTION_SET_PWM_DUTY , MESHX_IO_FUNCTION_SET_PWM_FREQUENCY , MESHX_IO_FUNCTION_REGISTER_INTERRUPT , MESHX_IO_FUNCTION_CUSTOM , MESHX_IO_FUNCTION_MAX } |
| IO Function Types for function-based API. More... | |
Functions | |
| meshx_err_t | meshx_gpio_init (void) |
| Initialize GPIO subsystem. | |
| meshx_err_t | meshx_gpio_deinit (void) |
| Deinitialize GPIO subsystem. | |
| meshx_err_t | meshx_gpio_set_level (uint8_t logical_pin, uint8_t level) |
| Set GPIO pin level. | |
| meshx_err_t | meshx_gpio_get_level (uint8_t logical_pin, uint8_t *level) |
| Get GPIO pin level. | |
| meshx_err_t | meshx_gpio_toggle (uint8_t logical_pin) |
| Toggle GPIO pin level. | |
| meshx_err_t | meshx_gpio_execute_function (uint8_t logical_pin, meshx_io_function_t function, const uint32_t *args, uint8_t arg_count) |
| Execute IO function on GPIO pin. | |
| meshx_err_t | meshx_gpio_register_intr (uint8_t logical_pin, meshx_gpio_intr_type_t intr_type, meshx_gpio_intr_cb_t callback, void *user_data) |
| Register GPIO interrupt handler. | |
| meshx_err_t | meshx_gpio_unregister_intr (uint8_t logical_pin) |
| Unregister GPIO interrupt handler. | |
| meshx_err_t | meshx_gpio_intr_enable (uint8_t logical_pin, bool enable) |
| Enable/disable GPIO interrupt. | |
| meshx_err_t | meshx_gpio_set_hosted_mode (meshx_gpio_hosted_mode_t mode) |
| Set hosted mode for GPIO subsystem. | |
| meshx_gpio_hosted_mode_t | meshx_gpio_get_hosted_mode (void) |
| Get current hosted mode. | |
| bool | meshx_gpio_is_hosted_mode (void) |
| Check if GPIO subsystem is in hosted mode. | |
| meshx_err_t | meshx_gpio_register_hosted_event_cb (meshx_gpio_hosted_event_cb_t callback) |
| Register callback function for hosted mode events. | |
| meshx_err_t | meshx_gpio_process_hosted_interrupt (uint8_t logical_pin, uint8_t value) |
| Process GPIO interrupt event from host (hosted mode). | |
| bool | meshx_gpio_is_initialized (void) |
| Check if GPIO subsystem is initialized. | |
| uint8_t | meshx_gpio_get_pin_count (void) |
| Get number of configured GPIO pins. | |
| meshx_err_t | meshx_gpio_get_pin_config (uint8_t logical_pin, meshx_gpio_pin_config_t *config) |
| Get pin configuration. | |
| meshx_err_t | meshx_gpio_get_pin_state (uint8_t logical_pin, meshx_gpio_pin_state_t *state) |
| Get pin runtime state. | |
MeshX GPIO Interface.
This file defines the MeshX GPIO interface for platform-abstracted GPIO operations. The interface supports digital I/O, interrupts, and function-based API for extensibility.
| typedef void(* meshx_gpio_hosted_event_cb_t) (const meshx_gpio_hosted_event_t *event) |
Register callback for GPIO hosted mode events.
This callback is invoked when GPIO events need to be sent to the host MCU in hosted mode.
| event | GPIO hosted mode event |
| typedef void(* meshx_gpio_intr_cb_t) (uint8_t logical_pin, void *user_data) |
GPIO Interrupt Callback Function.
| logical_pin | Logical pin number (0-255) |
| user_data | User data passed during registration |
| enum meshx_gpio_drive_t |
GPIO Drive Strength.
| enum meshx_gpio_mode_t |
GPIO Pin Modes.
| enum meshx_gpio_pull_t |
GPIO Pull Resistor Settings.
| enum meshx_io_function_t |
IO Function Types for function-based API.
| meshx_err_t meshx_gpio_deinit | ( | void | ) |
Deinitialize GPIO subsystem.
This function deinitializes the GPIO subsystem and releases all resources.
| meshx_err_t meshx_gpio_execute_function | ( | uint8_t | logical_pin, |
| meshx_io_function_t | function, | ||
| const uint32_t * | args, | ||
| uint8_t | arg_count ) |
Execute IO function on GPIO pin.
This is the function-based API for extensible GPIO operations.
| logical_pin | Logical pin number (0-255) |
| function | IO function to execute |
| args | Function arguments vector |
| arg_count | Number of arguments in the vector |
Execute IO function on GPIO pin.
| meshx_gpio_hosted_mode_t meshx_gpio_get_hosted_mode | ( | void | ) |
Get current hosted mode.
| meshx_err_t meshx_gpio_get_level | ( | uint8_t | logical_pin, |
| uint8_t * | level ) |
Get GPIO pin level.
| logical_pin | Logical pin number (0-255) | |
| [out] | level | Pointer to store pin level |
| meshx_err_t meshx_gpio_get_pin_config | ( | uint8_t | logical_pin, |
| meshx_gpio_pin_config_t * | config ) |
Get pin configuration.
| logical_pin | Logical pin number | |
| [out] | config | Pointer to store pin configuration |
| uint8_t meshx_gpio_get_pin_count | ( | void | ) |
Get number of configured GPIO pins.
| meshx_err_t meshx_gpio_get_pin_state | ( | uint8_t | logical_pin, |
| meshx_gpio_pin_state_t * | state ) |
Get pin runtime state.
| logical_pin | Logical pin number | |
| [out] | state | Pointer to store pin state |
| meshx_err_t meshx_gpio_init | ( | void | ) |
Initialize GPIO subsystem.
This function initializes the GPIO subsystem and configures all pins according to the compiled configuration.
| meshx_err_t meshx_gpio_intr_enable | ( | uint8_t | logical_pin, |
| bool | enable ) |
Enable/disable GPIO interrupt.
| logical_pin | Logical pin number (0-255) |
| enable | true to enable, false to disable |
| bool meshx_gpio_is_hosted_mode | ( | void | ) |
Check if GPIO subsystem is in hosted mode.
| bool meshx_gpio_is_initialized | ( | void | ) |
Check if GPIO subsystem is initialized.
| meshx_err_t meshx_gpio_process_hosted_interrupt | ( | uint8_t | logical_pin, |
| uint8_t | value ) |
Process GPIO interrupt event from host (hosted mode).
This function is called when the host sends an interrupt notification for a GPIO pin that was registered for interrupts.
| logical_pin | Logical pin number |
| value | Interrupt value (trigger type or pin state) |
| meshx_err_t meshx_gpio_register_hosted_event_cb | ( | meshx_gpio_hosted_event_cb_t | callback | ) |
Register callback function for hosted mode events.
| callback | Callback function for hosted mode events |
Register callback function for hosted mode events.
| meshx_err_t meshx_gpio_register_intr | ( | uint8_t | logical_pin, |
| meshx_gpio_intr_type_t | intr_type, | ||
| meshx_gpio_intr_cb_t | callback, | ||
| void * | user_data ) |
Register GPIO interrupt handler.
| logical_pin | Logical pin number (0-255) |
| intr_type | Interrupt trigger type |
| callback | Interrupt callback function |
| user_data | User data passed to callback |
| meshx_err_t meshx_gpio_set_hosted_mode | ( | meshx_gpio_hosted_mode_t | mode | ) |
Set hosted mode for GPIO subsystem.
This function switches the GPIO subsystem between hosted and non-hosted modes. In hosted mode, GPIO events are serialized and sent via UART transport. In non-hosted mode, GPIO operations directly control hardware.
| mode | Hosted mode setting (MESHX_GPIO_MODE_HOSTED or MESHX_GPIO_MODE_NON_HOSTED) |
| meshx_err_t meshx_gpio_set_level | ( | uint8_t | logical_pin, |
| uint8_t | level ) |
Set GPIO pin level.
| logical_pin | Logical pin number (0-255) |
| level | Pin level (0 = low, 1 = high) |
| meshx_err_t meshx_gpio_toggle | ( | uint8_t | logical_pin | ) |
Toggle GPIO pin level.
| logical_pin | Logical pin number (0-255) |
| meshx_err_t meshx_gpio_unregister_intr | ( | uint8_t | logical_pin | ) |
Unregister GPIO interrupt handler.
| logical_pin | Logical pin number (0-255) |