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:
committed by
GitHub
parent
2de35b2d2d
commit
aa7530e515
@@ -3,5 +3,5 @@ file(GLOB_RECURSE SOURCE_FILES Source/*.c*)
|
||||
idf_component_register(
|
||||
SRCS ${SOURCE_FILES}
|
||||
INCLUDE_DIRS "Source"
|
||||
REQUIRES Tactility esp_lvgl_port esp_lcd EspLcdCompat esp_lcd_ili9881c GT911 PwmBacklight driver vfs fatfs pi4ioe5v6408-module
|
||||
REQUIRES Tactility esp_lvgl_port esp_lcd EspLcdCompat esp_lcd_ili9881c GT911 PwmBacklight driver vfs fatfs
|
||||
)
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
#include "devices/Display.h"
|
||||
#include "devices/SdCard.h"
|
||||
#include <driver/gpio.h>
|
||||
|
||||
#include <tactility/drivers/gpio_controller.h>
|
||||
#include <tactility/drivers/i2c_controller.h>
|
||||
|
||||
#include <Tactility/hal/Configuration.h>
|
||||
#include <Tactility/hal/i2c/I2c.h>
|
||||
#include <drivers/pi4ioe5v6408.h>
|
||||
|
||||
using namespace tt::hal;
|
||||
|
||||
@@ -19,50 +18,115 @@ static DeviceVector createDevices() {
|
||||
};
|
||||
}
|
||||
|
||||
static error_t initPower(::Device* io_expander0, ::Device* io_expander1) {
|
||||
constexpr TickType_t i2c_timeout = pdMS_TO_TICKS(10);
|
||||
/*
|
||||
PI4IOE5V6408-0 (0x43)
|
||||
- Bit 0: RF internal/external switch
|
||||
- Bit 1: Speaker enable
|
||||
- Bit 2: External 5V bus enable
|
||||
- Bit 3: /
|
||||
- Bit 4: LCD reset
|
||||
- Bit 5: Touch reset
|
||||
- Bit 6: Camera reset
|
||||
- Bit 7: Headphone detect
|
||||
*/
|
||||
constexpr auto GPIO_EXP0_PIN_RF_INTERNAL_EXTERNAL = 0;
|
||||
constexpr auto GPIO_EXP0_PIN_SPEAKER_ENABLE = 1;
|
||||
constexpr auto GPIO_EXP0_PIN_EXTERNAL_5V_BUS_ENABLE = 2;
|
||||
constexpr auto GPIO_EXP0_PIN_LCD_RESET = 4;
|
||||
constexpr auto GPIO_EXP0_PIN_TOUCH_RESET = 5;
|
||||
constexpr auto GPIO_EXP0_PIN_CAMERA_RESET = 6;
|
||||
constexpr auto GPIO_EXP0_PIN_HEADPHONE_DETECT = 7;
|
||||
|
||||
/*
|
||||
PI4IOE5V6408-0 (0x43)
|
||||
- Bit 0: RF internal/external switch
|
||||
- Bit 1: Speaker enable
|
||||
- Bit 2: External 5V bus enable
|
||||
- Bit 3: /
|
||||
- Bit 4: LCD reset
|
||||
- Bit 5: Touch reset
|
||||
- Bit 6: Camera reset
|
||||
- Bit 7: Headphone detect
|
||||
*/
|
||||
/*
|
||||
PI4IOE5V6408-1 (0x44)
|
||||
- Bit 0: C6 WLAN enable
|
||||
- Bit 1: /
|
||||
- Bit 2: /
|
||||
- Bit 3: USB-A 5V enable
|
||||
- Bit 4: Device power: PWROFF_PLUSE
|
||||
- Bit 5: IP2326: nCHG_QC_EN
|
||||
- Bit 6: IP2326: CHG_STAT_LED
|
||||
- Bit 7: IP2326: CHG_EN
|
||||
*/
|
||||
constexpr auto GPIO_EXP1_PIN_C6_WLAN_ENABLE = 0;
|
||||
constexpr auto GPIO_EXP1_PIN_USB_A_5V_ENABLE = 3;
|
||||
constexpr auto GPIO_EXP1_PIN_DEVICE_POWER = 4;
|
||||
constexpr auto GPIO_EXP1_PIN_IP2326_NCHG_QC_EN = 5;
|
||||
constexpr auto GPIO_EXP1_PIN_IP2326_CHG_STAT_LED = 6;
|
||||
constexpr auto GPIO_EXP1_PIN_IP2326_CHG_EN = 7;
|
||||
|
||||
check(pi4ioe5v6408_set_direction(io_expander0, 0b01111111, i2c_timeout) == ERROR_NONE);
|
||||
check(pi4ioe5v6408_set_output_level(io_expander0, 0b01000110, i2c_timeout) == ERROR_NONE);
|
||||
check(pi4ioe5v6408_set_output_high_impedance(io_expander0, 0b00000000, i2c_timeout) == ERROR_NONE);
|
||||
check(pi4ioe5v6408_set_pull_select(io_expander0, 0b01111111, i2c_timeout) == ERROR_NONE);
|
||||
check(pi4ioe5v6408_set_pull_enable(io_expander0, 0b01111111, i2c_timeout) == ERROR_NONE);
|
||||
static void initExpander0(::Device* io_expander0) {
|
||||
auto* rf_pin = gpio_descriptor_acquire(io_expander0, GPIO_EXP0_PIN_RF_INTERNAL_EXTERNAL, GPIO_OWNER_GPIO);
|
||||
check(rf_pin);
|
||||
auto* speaker_enable_pin = gpio_descriptor_acquire(io_expander0, GPIO_EXP0_PIN_SPEAKER_ENABLE, GPIO_OWNER_GPIO);
|
||||
check(speaker_enable_pin);
|
||||
auto* external_5v_bus_enable_pin = gpio_descriptor_acquire(io_expander0, GPIO_EXP0_PIN_EXTERNAL_5V_BUS_ENABLE, GPIO_OWNER_GPIO);
|
||||
check(external_5v_bus_enable_pin);
|
||||
auto* lcd_reset_pin = gpio_descriptor_acquire(io_expander0, GPIO_EXP0_PIN_LCD_RESET, GPIO_OWNER_GPIO);
|
||||
check(lcd_reset_pin);
|
||||
auto* touch_reset_pin = gpio_descriptor_acquire(io_expander0, GPIO_EXP0_PIN_TOUCH_RESET, GPIO_OWNER_GPIO);
|
||||
check(touch_reset_pin);
|
||||
auto* camera_reset_pin = gpio_descriptor_acquire(io_expander0, GPIO_EXP0_PIN_CAMERA_RESET, GPIO_OWNER_GPIO);
|
||||
check(camera_reset_pin);
|
||||
auto* headphone_detect_pin = gpio_descriptor_acquire(io_expander0, GPIO_EXP0_PIN_HEADPHONE_DETECT, GPIO_OWNER_GPIO);
|
||||
check(headphone_detect_pin);
|
||||
|
||||
gpio_descriptor_set_flags(rf_pin, GPIO_FLAG_DIRECTION_OUTPUT);
|
||||
gpio_descriptor_set_flags(speaker_enable_pin, GPIO_FLAG_DIRECTION_OUTPUT);
|
||||
gpio_descriptor_set_flags(external_5v_bus_enable_pin, GPIO_FLAG_DIRECTION_OUTPUT);
|
||||
gpio_descriptor_set_flags(lcd_reset_pin, GPIO_FLAG_DIRECTION_OUTPUT);
|
||||
gpio_descriptor_set_flags(touch_reset_pin, GPIO_FLAG_DIRECTION_OUTPUT);
|
||||
gpio_descriptor_set_flags(camera_reset_pin, GPIO_FLAG_DIRECTION_OUTPUT);
|
||||
gpio_descriptor_set_flags(headphone_detect_pin, GPIO_FLAG_DIRECTION_INPUT);
|
||||
|
||||
gpio_descriptor_set_level(rf_pin, false);
|
||||
gpio_descriptor_set_level(speaker_enable_pin, false);
|
||||
gpio_descriptor_set_level(external_5v_bus_enable_pin, true);
|
||||
gpio_descriptor_set_level(lcd_reset_pin, false);
|
||||
gpio_descriptor_set_level(touch_reset_pin, false);
|
||||
gpio_descriptor_set_level(camera_reset_pin, true);
|
||||
vTaskDelay(pdMS_TO_TICKS(10));
|
||||
check(pi4ioe5v6408_set_output_level(io_expander0, 0b01110110, i2c_timeout) == ERROR_NONE);
|
||||
// Enable touch and lcd, but not the camera
|
||||
gpio_descriptor_set_level(lcd_reset_pin, true);
|
||||
gpio_descriptor_set_level(touch_reset_pin, true);
|
||||
|
||||
/*
|
||||
PI4IOE5V6408-1 (0x44)
|
||||
- Bit 0: C6 WLAN enable
|
||||
- Bit 1: /
|
||||
- Bit 2: /
|
||||
- Bit 3: USB-A 5V enable
|
||||
- Bit 4: Device power: PWROFF_PLUSE
|
||||
- Bit 5: IP2326: nCHG_QC_EN
|
||||
- Bit 6: IP2326: CHG_STAT_LED
|
||||
- Bit 7: IP2326: CHG_EN
|
||||
*/
|
||||
gpio_descriptor_release(rf_pin);
|
||||
gpio_descriptor_release(speaker_enable_pin);
|
||||
gpio_descriptor_release(external_5v_bus_enable_pin);
|
||||
gpio_descriptor_release(lcd_reset_pin);
|
||||
gpio_descriptor_release(touch_reset_pin);
|
||||
gpio_descriptor_release(camera_reset_pin);
|
||||
gpio_descriptor_release(headphone_detect_pin);
|
||||
}
|
||||
|
||||
check(pi4ioe5v6408_set_direction(io_expander1, 0b10111001, i2c_timeout) == ERROR_NONE);
|
||||
check(pi4ioe5v6408_set_output_high_impedance(io_expander1, 0b00000110, i2c_timeout) == ERROR_NONE);
|
||||
check(pi4ioe5v6408_set_pull_select(io_expander1, 0b10111001, i2c_timeout) == ERROR_NONE);
|
||||
check(pi4ioe5v6408_set_pull_enable(io_expander1, 0b11111001, i2c_timeout) == ERROR_NONE);
|
||||
check(pi4ioe5v6408_set_input_default_level(io_expander1, 0b01000000, i2c_timeout) == ERROR_NONE);
|
||||
check(pi4ioe5v6408_set_interrupt_mask(io_expander1, 0b10111111, i2c_timeout) == ERROR_NONE);
|
||||
check(pi4ioe5v6408_set_output_level(io_expander1, 0b10001001, i2c_timeout) == ERROR_NONE);
|
||||
static void initExpander1(::Device* io_expander1) {
|
||||
|
||||
return ERROR_NONE;
|
||||
auto* c6_wlan_enable_pin = gpio_descriptor_acquire(io_expander1, GPIO_EXP1_PIN_C6_WLAN_ENABLE, GPIO_OWNER_GPIO);
|
||||
auto* usb_a_5v_enable_pin = gpio_descriptor_acquire(io_expander1, GPIO_EXP1_PIN_USB_A_5V_ENABLE, GPIO_OWNER_GPIO);
|
||||
auto* device_power_pin = gpio_descriptor_acquire(io_expander1, GPIO_EXP1_PIN_DEVICE_POWER, GPIO_OWNER_GPIO);
|
||||
auto* ip2326_ncharge_qc_enable_pin = gpio_descriptor_acquire(io_expander1, GPIO_EXP1_PIN_IP2326_NCHG_QC_EN, GPIO_OWNER_GPIO);
|
||||
auto* ip2326_charge_state_led_pin = gpio_descriptor_acquire(io_expander1, GPIO_EXP1_PIN_IP2326_CHG_STAT_LED, GPIO_OWNER_GPIO);
|
||||
auto* ip2326_charge_enable_pin = gpio_descriptor_acquire(io_expander1, GPIO_EXP1_PIN_IP2326_CHG_EN, GPIO_OWNER_GPIO);
|
||||
|
||||
gpio_descriptor_set_flags(c6_wlan_enable_pin, GPIO_FLAG_DIRECTION_OUTPUT);
|
||||
gpio_descriptor_set_flags(usb_a_5v_enable_pin, GPIO_FLAG_DIRECTION_OUTPUT);
|
||||
gpio_descriptor_set_flags(device_power_pin, GPIO_FLAG_DIRECTION_OUTPUT);
|
||||
gpio_descriptor_set_flags(ip2326_ncharge_qc_enable_pin, GPIO_FLAG_DIRECTION_OUTPUT);
|
||||
gpio_descriptor_set_flags(ip2326_charge_state_led_pin, GPIO_FLAG_DIRECTION_OUTPUT);
|
||||
gpio_descriptor_set_flags(ip2326_charge_enable_pin, GPIO_FLAG_DIRECTION_INPUT | GPIO_FLAG_PULL_UP);
|
||||
|
||||
gpio_descriptor_set_level(c6_wlan_enable_pin, true);
|
||||
gpio_descriptor_set_level(usb_a_5v_enable_pin, true);
|
||||
gpio_descriptor_set_level(device_power_pin, false);
|
||||
gpio_descriptor_set_level(ip2326_ncharge_qc_enable_pin, false);
|
||||
gpio_descriptor_set_level(ip2326_charge_state_led_pin, false);
|
||||
|
||||
gpio_descriptor_release(c6_wlan_enable_pin);
|
||||
gpio_descriptor_release(usb_a_5v_enable_pin);
|
||||
gpio_descriptor_release(device_power_pin);
|
||||
gpio_descriptor_release(ip2326_ncharge_qc_enable_pin);
|
||||
gpio_descriptor_release(ip2326_charge_state_led_pin);
|
||||
gpio_descriptor_release(ip2326_charge_enable_pin);
|
||||
}
|
||||
|
||||
static error_t initSound(::Device* i2c_controller, ::Device* io_expander0 = nullptr) {
|
||||
@@ -113,13 +177,11 @@ static error_t initSound(::Device* i2c_controller, ::Device* io_expander0 = null
|
||||
return error;
|
||||
}
|
||||
|
||||
uint8_t output_level = 0;
|
||||
if (pi4ioe5v6408_get_output_level(io_expander0, &output_level, pdMS_TO_TICKS(100)) != ERROR_NONE) {
|
||||
LOG_E(TAG, "Failed to read power level: %s", error_to_string(error));
|
||||
return ERROR_RESOURCE;
|
||||
}
|
||||
|
||||
if (pi4ioe5v6408_set_output_level(io_expander0, output_level | 0b00000010, pdMS_TO_TICKS(100)) != ERROR_NONE) {
|
||||
auto* speaker_enable_pin = gpio_descriptor_acquire(io_expander0, GPIO_EXP0_PIN_SPEAKER_ENABLE, GPIO_OWNER_GPIO);
|
||||
check(speaker_enable_pin, "Failed to acquire speaker enable pin");
|
||||
error = gpio_descriptor_set_level(speaker_enable_pin, true);
|
||||
gpio_descriptor_release(speaker_enable_pin);
|
||||
if (error != ERROR_NONE) {
|
||||
LOG_E(TAG, "Failed to enable amplifier: %s", error_to_string(error));
|
||||
return ERROR_RESOURCE;
|
||||
}
|
||||
@@ -132,10 +194,12 @@ static bool initBoot() {
|
||||
check(i2c0, "i2c0 not found");
|
||||
|
||||
auto* io_expander0 = device_find_by_name("io_expander0");
|
||||
check(io_expander0, "io_expander0 not found");
|
||||
auto* io_expander1 = device_find_by_name("io_expander1");
|
||||
check(i2c0, "i2c0 not found");
|
||||
check(io_expander1, "io_expander1 not found");
|
||||
|
||||
initPower(io_expander0, io_expander1);
|
||||
initExpander0(io_expander0);
|
||||
initExpander1(io_expander1);
|
||||
|
||||
error_t error = initSound(i2c0, io_expander0);
|
||||
if (error != ERROR_NONE) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
dependencies:
|
||||
- Platforms/platform-esp32
|
||||
- Drivers/pi4ioe5v6408-module
|
||||
- Drivers/bmi270-module
|
||||
dts: m5stack,tab5.dts
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <tactility/bindings/esp32_i2c.h>
|
||||
#include <tactility/bindings/esp32_i2s.h>
|
||||
#include <tactility/bindings/esp32_spi.h>
|
||||
#include <bindings/bmi270.h>
|
||||
#include <bindings/pi4ioe5v6408.h>
|
||||
|
||||
/ {
|
||||
@@ -23,35 +24,20 @@
|
||||
pin-sda = <&gpio0 31 GPIO_FLAG_NONE>;
|
||||
pin-scl = <&gpio0 32 GPIO_FLAG_NONE>;
|
||||
|
||||
/*
|
||||
- Bit 0: RF internal/external switch
|
||||
- Bit 1: Speaker enable
|
||||
- Bit 2: External 5V bus enable
|
||||
- Bit 3: /
|
||||
- Bit 4: LCD reset
|
||||
- Bit 5: Touch reset
|
||||
- Bit 6: Camera reset
|
||||
- Bit 7: Headphone detect
|
||||
*/
|
||||
io_expander0 {
|
||||
compatible = "diodes,pi4ioe5v6408";
|
||||
reg = <0x43>;
|
||||
};
|
||||
|
||||
/*
|
||||
- Bit 0: C6 WLAN enable
|
||||
- Bit 1: /
|
||||
- Bit 2: /
|
||||
- Bit 3: USB-A 5V enable
|
||||
- Bit 4: Device power: PWROFF_PLUSE
|
||||
- Bit 5: IP2326: nCHG_QC_EN
|
||||
- Bit 6: IP2326: CHG_STAT_LED
|
||||
- Bit 7: IP2326: CHG_EN
|
||||
*/
|
||||
io_expander1 {
|
||||
compatible = "diodes,pi4ioe5v6408";
|
||||
reg = <0x44>;
|
||||
};
|
||||
|
||||
bmi270 {
|
||||
compatible = "bosch,bmi270";
|
||||
reg = <0x68>;
|
||||
};
|
||||
};
|
||||
|
||||
i2c_port_a: i2c1 {
|
||||
|
||||
Reference in New Issue
Block a user