New kernel drivers and device implementation updates (#561)
- Added modular device support and devicetree bindings for ILI9341, ILI9488, CST816S, XPT2046, and GPIO button input, updating several board configurations for display/touch/backlight/keyboard/battery. - Added a setting to control deprecated HAL usage (device property + Kconfig).
This commit is contained in:
committed by
GitHub
parent
50c0a14a93
commit
fa4a6e255c
@@ -1,7 +1,7 @@
|
||||
file(GLOB_RECURSE SOURCE_FILES Source/*.c*)
|
||||
file(GLOB_RECURSE SOURCE_FILES source/*.c*)
|
||||
|
||||
idf_component_register(
|
||||
SRCS ${SOURCE_FILES}
|
||||
INCLUDE_DIRS "Source"
|
||||
REQUIRES Tactility esp_lvgl_port esp_lcd ST7789 PwmBacklight ButtonControl
|
||||
INCLUDE_DIRS "source"
|
||||
REQUIRES TactilityKernel driver
|
||||
)
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
#include "devices/Display.h"
|
||||
|
||||
#include <Tactility/hal/Configuration.h>
|
||||
#include <ButtonControl.h>
|
||||
#include <PwmBacklight.h>
|
||||
|
||||
using namespace tt::hal;
|
||||
|
||||
bool initBoot() {
|
||||
// CH552 applies 4 V to GPIO 0, which reduces Wi-Fi sensitivity
|
||||
// Setting output to high adds a bias of 3.3 V and suppresses over-voltage:
|
||||
gpio::configure(0, gpio::Mode::Output, false, false);
|
||||
gpio::setLevel(0, true);
|
||||
|
||||
// "Hold power" pin: must be set to high to keep the device powered on:
|
||||
gpio::configure(4, gpio::Mode::Output, false, false);
|
||||
gpio::setLevel(4, true);
|
||||
return driver::pwmbacklight::init(GPIO_NUM_27, 512);
|
||||
}
|
||||
|
||||
static DeviceVector createDevices() {
|
||||
return {
|
||||
ButtonControl::createTwoButtonControl(37, 39),
|
||||
createDisplay()
|
||||
};
|
||||
}
|
||||
|
||||
extern const Configuration hardwareConfiguration = {
|
||||
.initBoot = initBoot,
|
||||
.createDevices = createDevices
|
||||
};
|
||||
@@ -1,32 +0,0 @@
|
||||
#include "Display.h"
|
||||
|
||||
#include <PwmBacklight.h>
|
||||
#include <St7789Display.h>
|
||||
|
||||
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
|
||||
St7789Display::Configuration panel_configuration = {
|
||||
.horizontalResolution = LCD_HORIZONTAL_RESOLUTION,
|
||||
.verticalResolution = LCD_VERTICAL_RESOLUTION,
|
||||
.gapX = 52,
|
||||
.gapY = 40,
|
||||
.swapXY = false,
|
||||
.mirrorX = false,
|
||||
.mirrorY = false,
|
||||
.invertColor = true,
|
||||
.bufferSize = LCD_BUFFER_SIZE,
|
||||
.touch = nullptr,
|
||||
.backlightDutyFunction = driver::pwmbacklight::setBacklightDuty,
|
||||
.resetPin = LCD_PIN_RESET,
|
||||
.lvglSwapBytes = false
|
||||
};
|
||||
|
||||
auto spi_configuration = std::make_shared<St7789Display::SpiConfiguration>(St7789Display::SpiConfiguration {
|
||||
.spiHostDevice = LCD_SPI_HOST,
|
||||
.csPin = LCD_PIN_CS,
|
||||
.dcPin = LCD_PIN_DC,
|
||||
.pixelClockFrequency = 40'000'000,
|
||||
.transactionQueueDepth = 10
|
||||
});
|
||||
|
||||
return std::make_shared<St7789Display>(panel_configuration, spi_configuration);
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Tactility/hal/display/DisplayDevice.h"
|
||||
#include <memory>
|
||||
#include <driver/gpio.h>
|
||||
#include <driver/spi_common.h>
|
||||
|
||||
constexpr auto LCD_SPI_HOST = SPI2_HOST;
|
||||
constexpr auto LCD_PIN_CS = GPIO_NUM_5;
|
||||
constexpr auto LCD_PIN_DC = GPIO_NUM_14;
|
||||
constexpr auto LCD_PIN_RESET = GPIO_NUM_12;
|
||||
constexpr auto LCD_HORIZONTAL_RESOLUTION = 135;
|
||||
constexpr auto LCD_VERTICAL_RESOLUTION = 240;
|
||||
constexpr auto LCD_BUFFER_HEIGHT = LCD_VERTICAL_RESOLUTION / 3;
|
||||
constexpr auto LCD_BUFFER_SIZE = LCD_HORIZONTAL_RESOLUTION * LCD_BUFFER_HEIGHT;
|
||||
constexpr auto LCD_SPI_TRANSFER_SIZE_LIMIT = LCD_BUFFER_SIZE * LV_COLOR_DEPTH / 8;
|
||||
|
||||
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();
|
||||
@@ -1,23 +0,0 @@
|
||||
#include <tactility/module.h>
|
||||
|
||||
extern "C" {
|
||||
|
||||
static error_t start() {
|
||||
// Empty for now
|
||||
return ERROR_NONE;
|
||||
}
|
||||
|
||||
static error_t stop() {
|
||||
// Empty for now
|
||||
return ERROR_NONE;
|
||||
}
|
||||
|
||||
struct Module m5stack_stickc_plus2_module = {
|
||||
.name = "m5stack-stickc-plus2",
|
||||
.start = start,
|
||||
.stop = stop,
|
||||
.symbols = nullptr,
|
||||
.internal = nullptr
|
||||
};
|
||||
|
||||
}
|
||||
@@ -10,6 +10,8 @@ hardware.spiRamMode=QUAD
|
||||
hardware.spiRamSpeed=80M
|
||||
hardware.esptoolFlashFreq=80M
|
||||
|
||||
dependencies.useDeprecatedHal=false
|
||||
|
||||
storage.userDataLocation=Internal
|
||||
|
||||
display.size=1.14"
|
||||
|
||||
@@ -2,4 +2,6 @@ dependencies:
|
||||
- Platforms/platform-esp32
|
||||
- Drivers/mpu6886-module
|
||||
- Drivers/bm8563-module
|
||||
- Drivers/st7789-module
|
||||
- Drivers/button-control-module
|
||||
dts: m5stack,stickc-plus2.dts
|
||||
|
||||
@@ -7,7 +7,10 @@
|
||||
#include <tactility/bindings/esp32_uart.h>
|
||||
#include <bindings/mpu6886.h>
|
||||
#include <bindings/bm8563.h>
|
||||
#include <tactility/bindings/display_placeholder.h>
|
||||
#include <tactility/bindings/esp32_ledc_backlight.h>
|
||||
|
||||
#include <bindings/st7789.h>
|
||||
#include <bindings/button_control.h>
|
||||
|
||||
/ {
|
||||
compatible = "root";
|
||||
@@ -49,18 +52,42 @@
|
||||
pin-scl = <&gpio0 33 GPIO_FLAG_NONE>;
|
||||
};
|
||||
|
||||
display_backlight {
|
||||
compatible = "espressif,esp32-ledc-backlight";
|
||||
// Off by default so display power-on won't show the screen from before the last power loss.
|
||||
// The display backlight is turned on during the boot process.
|
||||
status = "disabled";
|
||||
pin-backlight = <&gpio0 27 GPIO_FLAG_NONE>;
|
||||
frequency-hz = <512>;
|
||||
};
|
||||
|
||||
spi0 {
|
||||
compatible = "espressif,esp32-spi";
|
||||
host = <SPI2_HOST>;
|
||||
cs-gpios = <&gpio0 5 GPIO_FLAG_NONE>;
|
||||
pin-mosi = <&gpio0 15 GPIO_FLAG_NONE>;
|
||||
pin-sclk = <&gpio0 13 GPIO_FLAG_NONE>;
|
||||
|
||||
display {
|
||||
compatible = "display-placeholder";
|
||||
|
||||
display@0 {
|
||||
compatible = "sitronix,st7789";
|
||||
horizontal-resolution = <135>;
|
||||
vertical-resolution = <240>;
|
||||
gap-x = <52>;
|
||||
gap-y = <40>;
|
||||
invert-color;
|
||||
pixel-clock-hz = <40000000>;
|
||||
pin-dc = <&gpio0 14 GPIO_FLAG_NONE>;
|
||||
pin-reset = <&gpio0 12 GPIO_FLAG_NONE>;
|
||||
backlight = <&display_backlight>;
|
||||
};
|
||||
};
|
||||
|
||||
buttons {
|
||||
compatible = "tactility,button-control";
|
||||
pin-primary = <&gpio0 37 GPIO_FLAG_NONE>;
|
||||
pin-secondary = <&gpio0 39 GPIO_FLAG_NONE>;
|
||||
};
|
||||
|
||||
uart_grove: uart1 {
|
||||
compatible = "espressif,esp32-uart";
|
||||
status = "disabled";
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
#include <tactility/module.h>
|
||||
#include <tactility/error.h>
|
||||
|
||||
#include <driver/gpio.h>
|
||||
|
||||
constexpr auto* TAG = "StickCPlus2";
|
||||
|
||||
extern "C" {
|
||||
|
||||
static bool init_power() {
|
||||
// CH552 applies 4 V to GPIO 0, which reduces Wi-Fi sensitivity.
|
||||
// Setting output to high adds a bias of 3.3 V and suppresses over-voltage:
|
||||
gpio_set_direction(GPIO_NUM_0, GPIO_MODE_OUTPUT);
|
||||
gpio_set_level(GPIO_NUM_0, 1);
|
||||
|
||||
// "Hold power" pin: must be set to high to keep the device powered on:
|
||||
gpio_set_direction(GPIO_NUM_4, GPIO_MODE_OUTPUT);
|
||||
gpio_set_level(GPIO_NUM_4, 1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static error_t start() {
|
||||
init_power();
|
||||
return ERROR_NONE;
|
||||
}
|
||||
|
||||
static error_t stop() {
|
||||
// Empty for now
|
||||
return ERROR_NONE;
|
||||
}
|
||||
|
||||
Module m5stack_stickc_plus2_module = {
|
||||
.name = "m5stack-stickc-plus2",
|
||||
.start = start,
|
||||
.stop = stop,
|
||||
.symbols = nullptr,
|
||||
.internal = nullptr
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user