New kernel drivers, filesystem API, and more (#513)

* **New Features**
  * BMI270 6-axis IMU driver added; new unified filesystem abstraction for mounted filesystems.
  * Public Wi‑Fi API surface (no implementation yet)
  * SDMMC driver added (kernel drive$)
  * expanded GPIO interrupt/callback support
* **Improvements**
  * M5Stack Tab5: revamped GPIO/power initialization and IMU integration.
  * LVGL updates including device fontSize configuration.
  * Updated all code related to SD card device/fs handling
  * Rename LilyGO T-HMI S3 to LilyGO T-HMI
* **Bug Fixes**
  * Simplified and consolidated SD card handling and mount discovery.
This commit is contained in:
Ken Van Hoeylandt
2026-03-07 16:13:39 +01:00
committed by GitHub
parent 2de35b2d2d
commit aa7530e515
88 changed files with 2792 additions and 846 deletions
@@ -7,10 +7,9 @@ extern "C" {
#endif
#include <tactility/device.h>
#include <stdbool.h>
#include <stdint.h>
#define GPIO_FLAGS_MASK 0x1f
#define GPIO_FLAGS_MASK 0xff
#define GPIO_PIN_NONE -1
@@ -27,6 +26,7 @@ extern "C" {
#define GPIO_FLAG_INTERRUPT_BITMASK (0b111 << 5) // 3 bits to hold the values [0, 5]
#define GPIO_FLAG_INTERRUPT_FROM_OPTIONS(options) (gpio_int_type_t)((options & GPIO_FLAG_INTERRUPT_BITMASK) >> 5)
#define GPIO_FLAG_INTERRUPT_TO_OPTIONS(options, interrupt) (options | (interrupt << 5))
#define GPIO_FLAG_HIGH_IMPEDANCE (1 << 8)
typedef enum {
GPIO_INTERRUPT_DISABLE = 0,
@@ -52,6 +52,36 @@ struct GpioControllerApi {
* @return ERROR_NONE if successful
*/
error_t (*get_native_pin_number)(struct GpioDescriptor* descriptor, void* pin_number);
/**
* @brief Adds a callback to be called when a GPIO interrupt occurs.
* @param[in] descriptor the pin descriptor
* @param[in] callback the callback function
* @param[in] arg the argument to pass to the callback
* @return ERROR_NONE if successful, ERROR_NOT_SUPPORTED if not implemented
*/
error_t (*add_callback)(struct GpioDescriptor* descriptor, void (*callback)(void*), void* arg);
/**
* @brief Removes a callback from a GPIO interrupt.
* @param[in] descriptor the pin descriptor
* @return ERROR_NONE if successful, ERROR_NOT_SUPPORTED if not implemented
*/
error_t (*remove_callback)(struct GpioDescriptor* descriptor);
/**
* @brief Enables the interrupt for a GPIO pin.
* @param[in] descriptor the pin descriptor
* @return ERROR_NONE if successful, ERROR_NOT_SUPPORTED if not implemented
*/
error_t (*enable_interrupt)(struct GpioDescriptor* descriptor);
/**
* @brief Disables the interrupt for a GPIO pin.
* @param[in] descriptor the pin descriptor
* @return ERROR_NONE if successful, ERROR_NOT_SUPPORTED if not implemented
*/
error_t (*disable_interrupt)(struct GpioDescriptor* descriptor);
};
struct GpioDescriptor* gpio_descriptor_acquire(
@@ -118,6 +148,36 @@ error_t gpio_descriptor_get_flags(struct GpioDescriptor* descriptor, gpio_flags_
*/
error_t gpio_descriptor_get_native_pin_number(struct GpioDescriptor* descriptor, void* pin_number);
/**
* @brief Adds a callback to be called when a GPIO interrupt occurs.
* @param[in] descriptor the pin descriptor
* @param[in] callback the callback function
* @param[in] arg the argument to pass to the callback
* @return ERROR_NONE if successful, ERROR_NOT_SUPPORTED if not implemented
*/
error_t gpio_descriptor_add_callback(struct GpioDescriptor* descriptor, void (*callback)(void*), void* arg);
/**
* @brief Removes a callback from a GPIO interrupt.
* @param[in] descriptor the pin descriptor
* @return ERROR_NONE if successful, ERROR_NOT_SUPPORTED if not implemented
*/
error_t gpio_descriptor_remove_callback(struct GpioDescriptor* descriptor);
/**
* @brief Enables the interrupt for a GPIO pin.
* @param[in] descriptor the pin descriptor
* @return ERROR_NONE if successful, ERROR_NOT_SUPPORTED if not implemented
*/
error_t gpio_descriptor_enable_interrupt(struct GpioDescriptor* descriptor);
/**
* @brief Disables the interrupt for a GPIO pin.
* @param[in] descriptor the pin descriptor
* @return ERROR_NONE if successful, ERROR_NOT_SUPPORTED if not implemented
*/
error_t gpio_descriptor_disable_interrupt(struct GpioDescriptor* descriptor);
/**
* @brief Gets the number of pins supported by the controller.
* @param[in] device the GPIO controller device
@@ -141,6 +201,15 @@ error_t gpio_controller_init_descriptors(struct Device* device, uint32_t pin_cou
*/
error_t gpio_controller_deinit_descriptors(struct Device* device);
/**
* Unlike other drivers, a GPIO controller's internal data is created and set by gpio_controller_init_descriptors()
* This means that the specific controller implementation cannot set the device's driver data, as it's already set by the GPIO controller base coded
* When calling init descriptors, the caller can pass a controller_context, which is an optional pointer that holds the implementation's internal data.
* @param device the GPIO controller device
* @return the context void pointer
*/
void* gpio_controller_get_controller_context(struct Device* device);
extern const struct DeviceType GPIO_CONTROLLER_TYPE;
#ifdef __cplusplus
@@ -11,6 +11,11 @@ struct GpioDescriptor {
gpio_pin_t pin;
/** @brief Current owner */
enum GpioOwnerType owner_type;
/** @brief Implementation-specific context (e.g. from esp32 controller internally) */
/**
* @brief Implementation-specific context (e.g. from esp32 controller internally)
* Unlike other drivers, a GPIO controller's internal data is created and set by gpio_controller_init_descriptors()
* This means that the specific controller implementation cannot set the device's driver data, as it's already set by the GPIO controller base coded.
* When calling init descriptors, the caller can pass a controller_context, which is an optional pointer that holds the implementation's internal data.
*/
void* controller_context;
};
@@ -0,0 +1,205 @@
#pragma once
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <tactility/error.h>
#ifdef __cplusplus
extern "C" {
#endif
struct Device;
enum WifiAuthenticationType {
WIFI_AUTHENTICATION_TYPE_OPEN = 0,
WIFI_AUTHENTICATION_TYPE_WEP,
WIFI_AUTHENTICATION_TYPE_WPA_PSK,
WIFI_AUTHENTICATION_TYPE_WPA2_PSK,
WIFI_AUTHENTICATION_TYPE_WPA_WPA2_PSK,
WIFI_AUTHENTICATION_TYPE_WPA2_ENTERPRISE,
WIFI_AUTHENTICATION_TYPE_WPA3_PSK,
WIFI_AUTHENTICATION_TYPE_WPA2_WPA3_PSK,
WIFI_AUTHENTICATION_TYPE_WAPI_PSK,
WIFI_AUTHENTICATION_TYPE_OWE,
WIFI_AUTHENTICATION_TYPE_WPA3_ENT_192,
WIFI_AUTHENTICATION_TYPE_WPA3_EXT_PSK,
WIFI_AUTHENTICATION_TYPE_WPA3_EXT_PSK_MIXED_MODE,
WIFI_AUTHENTICATION_TYPE_MAX
};
struct WifiApRecord {
char ssid[33]; // 32 bytes + null terminator
int8_t rssi;
int32_t channel;
enum WifiAuthenticationType authentication_type;
};
enum WifiRadioState {
WIFI_RADIO_STATE_OFF,
WIFI_RADIO_STATE_ON_PENDING,
WIFI_RADIO_STATE_ON,
WIFI_RADIO_STATE_OFF_PENDING,
};
enum WifiStationState {
WIFI_STATION_STATE_DISCONNECTED,
WIFI_STATION_STATE_CONNECTION_PENDING,
WIFI_STATION_STATE_CONNECTED
};
enum WifiAccessPointState {
WIFI_ACCESS_POINT_STATE_STARTED,
WIFI_ACCESS_POINT_STATE_STOPPED,
};
enum WifiEventType {
/** Radio state changed */
WIFI_EVENT_TYPE_RADIO_STATE_CHANGED,
/** WifiStationState changed */
WIFI_EVENT_TYPE_STATION_STATE_CHANGED,
/** WifiAccessPointState changed */
WIFI_EVENT_TYPE_STATION_CONNECTION_RESULT,
/** WifiAccessPointState changed */
WIFI_EVENT_TYPE_ACCESS_POINT_STATE_CHANGED,
/** Started scanning for access points */
WIFI_EVENT_TYPE_SCAN_STARTED,
/** Finished scanning for access points */
WIFI_EVENT_TYPE_SCAN_FINISHED,
};
enum WifiStationConnectionError {
WIFI_STATION_CONNECTION_ERROR_NONE,
/** Wrong password */
WIFI_STATION_CONNECTION_ERROR_WRONG_CREDENTIALS,
/** Failed to connect in a timely manner */
WIFI_STATION_CONNECTION_ERROR_TIMEOUT,
/** SSID not found */
WIFI_STATION_CONNECTION_ERROR_TARGET_NOT_FOUND,
};
struct WifiEvent {
enum WifiEventType type;
union {
enum WifiRadioState radio_state;
enum WifiStationState station_state;
enum WifiAccessPointState access_point_state;
enum WifiStationConnectionError connection_error;
};
};
typedef void (*WifiEventCallback)(struct Device* device, void* callback_context, struct WifiEvent event);
struct WifiApi {
/**
* Get the radio state of the device.
* @param[in] device the wifi device
* @param[out] state the radio state
* @return ERROR_NONE on success
*/
error_t (*get_radio_state)(struct Device* device, enum WifiRadioState* state);
/**
* Get the station state of the device.
* @param[in] device the wifi device
* @param[out] state the station state
* @return ERROR_NONE on success
*/
error_t (*get_station_state)(struct Device* device, enum WifiStationState* state);
/**
* Get the access point state of the device.
* @param[in] device the wifi device
* @param[out] state the access point state
* @return ERROR_NONE on success
*/
error_t (*get_access_point_state)(struct Device* device, enum WifiAccessPointState* state);
/**
* Check if the device is currently scanning for access points.
* @param[in] device the wifi device
* @return true when scanning
*/
bool (*is_scanning)(struct Device* device);
/**
* Start a scan for access points.
* @param[in] device the wifi device
* @return ERROR_NONE on success
*/
error_t (*scan)(struct Device* device);
/**
* Get the scan results of the device.
* @param[in] device the wifi device
* @param[out] results the buffer to store the scan results
* @param[in, out] num_results the number of scan results: it's first used as input to determine the size of the buffer, and then as output to get the actual number of results
* @return ERROR_NONE on success
*/
error_t (*get_scan_results)(struct Device* device, struct WifiApRecord* results, size_t* num_results);
/**
* Get the IPv4 address of the device.
* @param[in] device the device
* @param[out] ipv4 the buffer to store the IPv4 address (must be at least 16 bytes, will be null-terminated)
* @return ERROR_NONE on success
*/
error_t (*station_get_ipv4_address)(struct Device* device, char* ipv4);
/**
* Get the SSID of the access point the device is currently connected to.
* @param[in] device the wifi device
* @param[out] ssid the buffer to store the SSID (must be at least 33 bytes, will be null-terminated)
* @return ERROR_NONE on success
*/
error_t (*station_get_target_ssid)(struct Device* device, char* ssid);
/**
* Connect to an access point.
* @param[in] device the wifi device
* @param[in] ssid the SSID of the access point
* @param[in] password the password of the access point
* @param[in] channel the Wi-Fi channel to connect to (0 means "any" / no preference)
* @return ERROR_NONE on success
*/
error_t (*station_connect)(struct Device* device, const char* ssid, const char* password, int32_t channel);
/**
* Disconnect from the current access point.
* @param[in] device the wifi device
* @return ERROR_NONE on success
*/
error_t (*station_disconnect)(struct Device* device);
/**
* Get the RSSI of the current access point.
* @param[in] device the wifi device
* @param[out] rssi the buffer to store the RSSI
* @return ERROR_NONE on success
*/
error_t (*station_get_rssi)(struct Device* device, int32_t* rssi);
/**
* Add a WifiEvent callback.
* @param[in] device the wifi device
* @param[in] callback_context the context to pass to the callback
* @param[in] callback the callback function
* @return ERROR_NONE on success
*/
error_t (*add_event_callback)(struct Device* device, void* callback_context, WifiEventCallback callback);
/**
* Remove a WifiEvent callback.
* @param[in] device the wifi device
* @param[in] callback the callback function
* @return ERROR_NONE on success
*/
error_t (*remove_event_callback)(struct Device* device, WifiEventCallback callback);
};
extern const struct DeviceType WIFI_TYPE;
#ifdef __cplusplus
}
#endif
@@ -0,0 +1,106 @@
// SPDX-License-Identifier: Apache-2.0
#pragma once
#include <stdbool.h>
#include <stddef.h>
#include <tactility/error.h>
#ifdef __cplusplus
extern "C" {
#endif
struct FileSystem;
/**
* @brief File system API.
*
* Provides a set of function pointers to interact with a specific file system implementation.
*/
struct FileSystemApi {
/**
* @brief Mounts the file system.
* @param[in] data file system private data
* @return ERROR_NONE on success, or an error code
*/
error_t (*mount)(void* data);
/**
* @brief Unmounts the file system.
* @param[in] data file system private data
* @return ERROR_NONE on success, or an error code
*/
error_t (*unmount)(void* data);
/**
* @brief Checks if the file system is mounted.
* @param[in] data file system private data
* @return true if mounted, false otherwise
*/
bool (*is_mounted)(void* data);
/**
* @brief Gets the mount path.
* @param[in] data file system private data
* @param[out] out_path buffer to store the path
* @param[in] out_path_size size of the output buffer
* @return ERROR_NONE on success, or an error code
*/
error_t (*get_path)(void* data, char* out_path, size_t out_path_size);
};
/**
* @brief Registers a new file system.
* @param[in] fs_api the file system API implementation
* @param[in] data private data for the file system
* @return the registered FileSystem object
*/
struct FileSystem* file_system_add(const struct FileSystemApi* fs_api, void* data);
/**
* @brief Removes a registered file system.
* @note The file system must be unmounted before removal.
* @param[in] fs the FileSystem object to remove
*/
void file_system_remove(struct FileSystem* fs);
/**
* @brief Iterates over all registered file systems.
* @param[in] callback_context context passed to the callback
* @param[in] callback function called for each file system. Return true to continue, false to stop.
*/
void file_system_for_each(void* callback_context, bool (*callback)(struct FileSystem* fs, void* context));
/**
* @brief Mounts the file system.
* @param[in] fs the FileSystem object
* @return ERROR_NONE on success, or an error code
*/
error_t file_system_mount(struct FileSystem* fs);
/**
* @warning Unmounting can fail (e.g. when the device is busy), so you might need to retry it.
* @brief Unmounts the file system.
* @param[in] fs the FileSystem object
* @return ERROR_NONE on success, or an error code
*/
error_t file_system_unmount(struct FileSystem* fs);
/**
* @brief Checks if the file system is mounted.
* @param[in] fs the FileSystem object
* @return true if mounted, false otherwise
*/
bool file_system_is_mounted(struct FileSystem* fs);
/**
* @brief Gets the mount path.
* @param[in] fs the FileSystem object
* @param[out] out_path buffer to store the path
* @param[in] out_path_size size of the output buffer
* @return ERROR_NONE on success, or an error code
*/
error_t file_system_get_path(struct FileSystem* fs, char* out_path, size_t out_path_size);
#ifdef __cplusplus
}
#endif
@@ -118,6 +118,7 @@ error_t module_construct_add_start(struct Module* module);
/**
* @brief Check if the module is started.
* Can be used when module isn't constructed yet.
* @param module module to check
* @return true if the module is started, false otherwise
*/