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
@@ -18,6 +18,7 @@ static const auto LOGGER = tt::Logger("JcSdCard");
|
||||
// ESP32-P4 Slot 0 uses IO MUX (fixed pins, not manually configurable)
|
||||
// CLK=43, CMD=44, D0=39, D1=40, D2=41, D3=42 (defined automatically by hardware)
|
||||
|
||||
// TODO: Migrate to "espressif,esp32-sdmmc" driver (needs LDO code porting)
|
||||
class SdCardDeviceImpl final : public SdCardDevice {
|
||||
|
||||
class NoLock final : public tt::Lock {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include "devices/Display.h"
|
||||
#include "devices/Sdcard.h"
|
||||
|
||||
#include <Tactility/hal/Configuration.h>
|
||||
|
||||
@@ -9,8 +8,7 @@ using namespace tt::hal;
|
||||
|
||||
static std::vector<std::shared_ptr<tt::hal::Device>> createDevices() {
|
||||
return {
|
||||
createDisplay(),
|
||||
createSdCard()
|
||||
createDisplay()
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
#include "Sdcard.h"
|
||||
|
||||
#include <Tactility/hal/sdcard/SdmmcDevice.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
|
||||
using tt::hal::sdcard::SdmmcDevice;
|
||||
|
||||
std::shared_ptr<SdCardDevice> createSdCard() {
|
||||
auto configuration = std::make_unique<SdmmcDevice::Config>(
|
||||
GPIO_NUM_12,
|
||||
GPIO_NUM_16,
|
||||
GPIO_NUM_14,
|
||||
GPIO_NUM_17,
|
||||
GPIO_NUM_21,
|
||||
GPIO_NUM_18,
|
||||
SdCardDevice::MountBehaviour::AtBoot
|
||||
);
|
||||
|
||||
return std::make_shared<SdmmcDevice>(
|
||||
std::move(configuration)
|
||||
);
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Tactility/hal/sdcard/SdCardDevice.h"
|
||||
|
||||
using tt::hal::sdcard::SdCardDevice;
|
||||
|
||||
std::shared_ptr<SdCardDevice> createSdCard();
|
||||
@@ -22,3 +22,4 @@ dpi=186
|
||||
[lvgl]
|
||||
colorDepth=16
|
||||
uiDensity=compact
|
||||
fontSize=10
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <tactility/bindings/root.h>
|
||||
#include <tactility/bindings/esp32_gpio.h>
|
||||
#include <tactility/bindings/esp32_i2c.h>
|
||||
#include <tactility/bindings/esp32_sdmmc.h>
|
||||
#include <tactility/bindings/esp32_spi.h>
|
||||
#include <tactility/bindings/esp32_uart.h>
|
||||
|
||||
@@ -30,6 +31,17 @@
|
||||
pin-sclk = <&gpio0 5 GPIO_FLAG_NONE>;
|
||||
};
|
||||
|
||||
sdmmc0 {
|
||||
compatible = "espressif,esp32-sdmmc";
|
||||
pin-clk = <&gpio0 12 GPIO_FLAG_NONE>;
|
||||
pin-cmd = <&gpio0 16 GPIO_FLAG_NONE>;
|
||||
pin-d0 = <&gpio0 14 GPIO_FLAG_NONE>;
|
||||
pin-d1 = <&gpio0 17 GPIO_FLAG_NONE>;
|
||||
pin-d2 = <&gpio0 21 GPIO_FLAG_NONE>;
|
||||
pin-d3 = <&gpio0 18 GPIO_FLAG_NONE>;
|
||||
bus-width = <4>;
|
||||
};
|
||||
|
||||
stemma_qt: uart1 {
|
||||
compatible = "espressif,esp32-uart";
|
||||
port = <UART_NUM_1>;
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
#include "SdCard.h"
|
||||
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Tactility/hal/sdcard/SdmmcDevice.h>
|
||||
|
||||
using tt::hal::sdcard::SdmmcDevice;
|
||||
|
||||
std::shared_ptr<SdCardDevice> createSdCard() {
|
||||
auto configuration = std::make_unique<SdmmcDevice::Config>(
|
||||
SD_DIO_SCLK, //CLK
|
||||
SD_DIO_CMD, //CMD
|
||||
SD_DIO_DATA0, //D0
|
||||
SD_DIO_NC, //D1
|
||||
SD_DIO_NC, //D2
|
||||
SD_DIO_NC, //D3
|
||||
SdCardDevice::MountBehaviour::AtBoot,
|
||||
SD_DIO_BUS_WIDTH
|
||||
);
|
||||
|
||||
return std::make_shared<SdmmcDevice>(
|
||||
std::move(configuration)
|
||||
);
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <driver/gpio.h>
|
||||
|
||||
#include "Tactility/hal/sdcard/SdCardDevice.h"
|
||||
|
||||
using tt::hal::sdcard::SdCardDevice;
|
||||
|
||||
constexpr auto SD_DIO_CMD = GPIO_NUM_11;
|
||||
constexpr auto SD_DIO_SCLK = GPIO_NUM_12;
|
||||
constexpr auto SD_DIO_DATA0 = GPIO_NUM_13;
|
||||
constexpr auto SD_DIO_NC = GPIO_NUM_NC;
|
||||
constexpr auto SD_DIO_BUS_WIDTH = 1;
|
||||
|
||||
std::shared_ptr<SdCardDevice> createSdCard();
|
||||
-2
@@ -1,5 +1,4 @@
|
||||
#include "devices/Power.h"
|
||||
#include "devices/SdCard.h"
|
||||
#include "devices/Display.h"
|
||||
|
||||
#include <ButtonControl.h>
|
||||
@@ -11,7 +10,6 @@ using namespace tt::hal;
|
||||
|
||||
static std::vector<std::shared_ptr<tt::hal::Device>> createDevices() {
|
||||
return {
|
||||
createSdCard(),
|
||||
createDisplay(),
|
||||
std::make_shared<Power>(),
|
||||
ButtonControl::createOneButtonControl(0)
|
||||
@@ -5,11 +5,11 @@
|
||||
#include "Tactility/kernel/SystemEvents.h"
|
||||
#include <Tactility/TactilityCore.h>
|
||||
|
||||
#define TAG "thmi-s3"
|
||||
#define TAG "thmi"
|
||||
|
||||
static bool powerOn() {
|
||||
gpio_config_t power_signal_config = {
|
||||
.pin_bit_mask = (1ULL << THMI_S3_POWERON_GPIO) | (1ULL << THMI_S3_POWEREN_GPIO),
|
||||
.pin_bit_mask = (1ULL << THMI_POWERON_GPIO) | (1ULL << THMI_POWEREN_GPIO),
|
||||
.mode = GPIO_MODE_OUTPUT,
|
||||
.pull_up_en = GPIO_PULLUP_DISABLE,
|
||||
.pull_down_en = GPIO_PULLDOWN_DISABLE,
|
||||
@@ -20,11 +20,11 @@ static bool powerOn() {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (gpio_set_level(THMI_S3_POWERON_GPIO, 1) != ESP_OK) {
|
||||
if (gpio_set_level(THMI_POWERON_GPIO, 1) != ESP_OK) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (gpio_set_level(THMI_S3_POWEREN_GPIO, 1) != ESP_OK) {
|
||||
if (gpio_set_level(THMI_POWEREN_GPIO, 1) != ESP_OK) {
|
||||
return false;
|
||||
}
|
||||
|
||||
+4
-4
@@ -6,16 +6,16 @@
|
||||
#include <ChargeFromVoltage.h>
|
||||
#include <Tactility/hal/power/PowerDevice.h>
|
||||
|
||||
constexpr auto THMI_S3_POWEREN_GPIO = GPIO_NUM_10;
|
||||
constexpr auto THMI_S3_POWERON_GPIO = GPIO_NUM_14;
|
||||
constexpr auto THMI_POWEREN_GPIO = GPIO_NUM_10;
|
||||
constexpr auto THMI_POWERON_GPIO = GPIO_NUM_14;
|
||||
|
||||
using tt::hal::power::PowerDevice;
|
||||
|
||||
class Power final : public PowerDevice {
|
||||
|
||||
ChargeFromVoltage chargeFromAdcVoltage = ChargeFromVoltage(3.3f, 4.2f);
|
||||
bool initialized = false;
|
||||
esp_adc_cal_characteristics_t adcCharacteristics;
|
||||
bool initialized = false;
|
||||
bool calibrated = false;
|
||||
|
||||
bool adcInitCalibration();
|
||||
@@ -25,7 +25,7 @@ class Power final : public PowerDevice {
|
||||
|
||||
public:
|
||||
|
||||
std::string getName() const override { return "T-hmi Power"; }
|
||||
std::string getName() const override { return "T-HMI Power"; }
|
||||
std::string getDescription() const override { return "Power measurement via ADC"; }
|
||||
|
||||
bool supportsMetric(MetricType type) const override;
|
||||
@@ -13,7 +13,7 @@ static error_t stop() {
|
||||
}
|
||||
|
||||
struct Module lilygo_thmi_s3_module = {
|
||||
.name = "lilygo-thmi-s3",
|
||||
.name = "lilygo-thmi",
|
||||
.start = start,
|
||||
.stop = stop,
|
||||
.symbols = nullptr,
|
||||
@@ -1,6 +1,6 @@
|
||||
[general]
|
||||
vendor=LilyGO
|
||||
name=T-HMI S3
|
||||
name=T-HMI
|
||||
|
||||
[apps]
|
||||
launcherAppId=Launcher
|
||||
@@ -1,3 +1,3 @@
|
||||
dependencies:
|
||||
- Platforms/platform-esp32
|
||||
dts: lilygo,thmi-s3.dts
|
||||
dts: lilygo,thmi.dts
|
||||
@@ -3,11 +3,12 @@
|
||||
#include <tactility/bindings/root.h>
|
||||
#include <tactility/bindings/esp32_gpio.h>
|
||||
#include <tactility/bindings/esp32_i2c.h>
|
||||
#include <tactility/bindings/esp32_sdmmc.h>
|
||||
#include <tactility/bindings/esp32_spi.h>
|
||||
|
||||
/ {
|
||||
compatible = "root";
|
||||
model = "LilyGO T-HMI S3";
|
||||
model = "LilyGO T-HMI";
|
||||
|
||||
gpio0 {
|
||||
compatible = "espressif,esp32-gpio";
|
||||
@@ -21,4 +22,12 @@
|
||||
pin-miso = <&gpio0 4 GPIO_FLAG_NONE>;
|
||||
pin-sclk = <&gpio0 1 GPIO_FLAG_NONE>;
|
||||
};
|
||||
|
||||
sdmmc0 {
|
||||
compatible = "espressif,esp32-sdmmc";
|
||||
pin-clk = <&gpio0 12 GPIO_FLAG_NONE>;
|
||||
pin-cmd = <&gpio0 11 GPIO_FLAG_NONE>;
|
||||
pin-d0 = <&gpio0 13 GPIO_FLAG_NONE>;
|
||||
bus-width = <1>;
|
||||
};
|
||||
};
|
||||
@@ -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 {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include "devices/Display.h"
|
||||
#include "devices/SdCard.h"
|
||||
|
||||
#include <Tactility/hal/Configuration.h>
|
||||
#include <PwmBacklight.h>
|
||||
@@ -10,7 +9,6 @@ using namespace tt::hal;
|
||||
static DeviceVector createDevices() {
|
||||
return {
|
||||
createDisplay(),
|
||||
createSdCard(),
|
||||
ButtonControl::createOneButtonControl(0)
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
#include "SdCard.h"
|
||||
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Tactility/hal/sdcard/SdmmcDevice.h>
|
||||
|
||||
using tt::hal::sdcard::SdmmcDevice;
|
||||
|
||||
std::shared_ptr<SdCardDevice> createSdCard() {
|
||||
auto configuration = std::make_unique<SdmmcDevice::Config>(
|
||||
GPIO_NUM_36, //CLK
|
||||
GPIO_NUM_35, //CMD
|
||||
GPIO_NUM_37, //D0
|
||||
GPIO_NUM_33, //D1
|
||||
GPIO_NUM_38, //D2
|
||||
GPIO_NUM_34, //D3
|
||||
SdCardDevice::MountBehaviour::AtBoot
|
||||
);
|
||||
|
||||
return std::make_shared<SdmmcDevice>(
|
||||
std::move(configuration)
|
||||
);
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Tactility/hal/sdcard/SdCardDevice.h"
|
||||
|
||||
using tt::hal::sdcard::SdCardDevice;
|
||||
|
||||
std::shared_ptr<SdCardDevice> createSdCard();
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <tactility/bindings/root.h>
|
||||
#include <tactility/bindings/esp32_gpio.h>
|
||||
#include <tactility/bindings/esp32_i2c.h>
|
||||
#include <tactility/bindings/esp32_sdmmc.h>
|
||||
#include <tactility/bindings/esp32_spi.h>
|
||||
#include <tactility/bindings/esp32_uart.h>
|
||||
|
||||
@@ -30,6 +31,17 @@
|
||||
pin-sclk = <&gpio0 12 GPIO_FLAG_NONE>;
|
||||
};
|
||||
|
||||
sdmmc0 {
|
||||
compatible = "espressif,esp32-sdmmc";
|
||||
pin-clk = <&gpio0 36 GPIO_FLAG_NONE>;
|
||||
pin-cmd = <&gpio0 35 GPIO_FLAG_NONE>;
|
||||
pin-d0 = <&gpio0 37 GPIO_FLAG_NONE>;
|
||||
pin-d1 = <&gpio0 33 GPIO_FLAG_NONE>;
|
||||
pin-d2 = <&gpio0 38 GPIO_FLAG_NONE>;
|
||||
pin-d3 = <&gpio0 34 GPIO_FLAG_NONE>;
|
||||
bus-width = <4>;
|
||||
};
|
||||
|
||||
uart0 {
|
||||
compatible = "espressif,esp32-uart";
|
||||
port = <UART_NUM_0>;
|
||||
|
||||
Reference in New Issue
Block a user