|
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 Runtime Implementation. More...
#include <string.h>#include <stdbool.h>#include <stdlib.h>#include "meshx_config.h"#include "interface/gpio/meshx_gpio.h"#include "interface/gpio/meshx_gpio_types.h"#include "interface/gpio/meshx_gpio_platform.h"#include "../../inc/meshx_err.h"#include "../../interface/logging/meshx_log.h"#include "../../inc/module_id.h"Data Structures | |
| struct | meshx_gpio_runtime_t |
| GPIO runtime state structure. More... | |
Functions | |
| static meshx_err_t | meshx_gpio_send_hosted_event (uint8_t event_type, uint8_t logical_pin, uint8_t value) |
| Send GPIO event in hosted mode. | |
| static void | intr_wrapper (void *arg) |
| Internal interrupt wrapper for platform GPIO interrupts. | |
| meshx_err_t | meshx_gpio_test_set_pin_count (uint8_t count) |
| meshx_err_t | meshx_gpio_test_set_pin_mode (uint8_t logical_pin, uint8_t mode) |
| meshx_err_t | meshx_gpio_init (void) |
| Initialize GPIO subsystem. | |
| meshx_err_t | meshx_gpio_deinit (void) |
| Deinitialize GPIO subsystem. | |
| static meshx_err_t | validate_logical_pin (uint8_t logical_pin) |
| Validate logical pin number. | |
| static meshx_err_t | get_physical_pin (uint8_t logical_pin, uint8_t *physical_pin) |
| Get physical pin from logical pin. | |
| static meshx_err_t | validate_pin_mode (uint8_t logical_pin, meshx_gpio_mode_t required_mode) |
| Validate pin mode for operation. | |
| 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_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_execute_function (uint8_t logical_pin, meshx_io_function_t function, const uint32_t *args, uint8_t arg_count) |
| Execute IO function on pin. | |
| 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_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 for GPIO 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). | |
Variables | |
| static meshx_gpio_runtime_t | gpio_runtime |
MeshX GPIO Runtime Implementation.
This file implements the core GPIO runtime subsystem for MeshX. It provides the runtime API for GPIO operations with validation, pin state tracking, and logical to physical pin mapping.
|
static |
Get physical pin from logical pin.
| logical_pin | Logical pin number | |
| [out] | physical_pin | Pointer to store physical pin number |
|
static |
Internal interrupt wrapper for platform GPIO interrupts.
This wrapper is called by the platform-specific interrupt handler and dispatches to the user-registered callback with the logical pin context.
| arg | Logical pin number passed as uintptr_t |
| 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 pin.
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 for GPIO 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 |
|
static |
Send GPIO event in hosted mode.
Internal function to send GPIO events to host via registered callback.
| event_type | Event type (0 = level change, 1 = interrupt) |
| logical_pin | Logical pin number |
| value | Event value |
| 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_test_set_pin_count | ( | uint8_t | count | ) |
| meshx_err_t meshx_gpio_test_set_pin_mode | ( | uint8_t | logical_pin, |
| uint8_t | mode ) |
| 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) |
|
static |
Validate logical pin number.
| logical_pin | Logical pin number to validate |
|
static |
Validate pin mode for operation.
| logical_pin | Logical pin number |
| required_mode | Required mode for the operation |
|
static |