Files
imliuboandzhouli 4b060419f8 boards: add M5Stack StickS3 board support
Add a complete board package under
application/basic_demo/boards/m5stack_sticks3/ for the
ESP32-S3-PICO-1-N8R8 based M5Stack StickS3.

Hardware:
  - 8 MB QIO flash @80MHz, 8 MB Octal PSRAM @80MHz
  - I2C0: SDA=47, SCL=48 (M5PM1 PMIC, ES8311 codec, BMI270 IMU)
  - I2S0 full-duplex: MCK=18, BCK=17, WS=15, DOUT=14, DIN=16
  - SPI3 LCD: MOSI=39, SCLK=40, CS=41, DC=45, RST=21
  - 1.14" ST7789 135x240 with (52,40) panel offset
  - Backlight on GPIO38 (active-high), LEDC PWM

Highlights:
  - M5PM1 PMIC modelled as a custom device; init sequence ported
    from M5GFX (disable I2C idle sleep, then bring up PYG2=LCD_PWR
    and PYG3=SPK_PA in push-pull output mode).
  - ES8311 declared as two audio_codec devices (DAC + ADC) sharing
    one I2C control line and one I2S port via YAML anchors,
    following the esp32_s3_korvo2l pattern.
  - ST7789 factory uses the IDF built-in esp_lcd_new_panel_st7789()
    and applies esp_lcd_panel_set_gap(52, 40) for the visible window.
  - ledc_backlight defaults to full duty (1023) so the panel is
    visible at boot — display.set_backlight() only toggles the
    LCD disp_on_off command and does not change LEDC duty.

Signed-off-by: imliubo <imliubo@makingfun.xyz>
2026-04-27 11:02:25 +08:00

41 lines
1.4 KiB
C

/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*
* M5Stack StickS3 — board-specific device factories.
* Provides the ST7789 panel factory used by the generic display_lcd device.
*/
#include <string.h>
#include "esp_log.h"
#include "esp_check.h"
#include "esp_lcd_panel_vendor.h"
#include "esp_lcd_panel_ops.h"
static const char *TAG = "M5_STICKS3_SETUP";
/* Visible portion of the 1.14" 135x240 ST7789 panel starts at (52, 40). */
#define M5_STICKS3_LCD_OFFSET_X 52
#define M5_STICKS3_LCD_OFFSET_Y 40
esp_err_t lcd_panel_factory_entry_t(esp_lcd_panel_io_handle_t io,
const esp_lcd_panel_dev_config_t *panel_dev_config,
esp_lcd_panel_handle_t *ret_panel)
{
esp_lcd_panel_dev_config_t panel_dev_cfg = {0};
memcpy(&panel_dev_cfg, panel_dev_config, sizeof(esp_lcd_panel_dev_config_t));
esp_err_t ret = esp_lcd_new_panel_st7789(io, &panel_dev_cfg, ret_panel);
if (ret != ESP_OK) {
ESP_LOGE(TAG, "esp_lcd_new_panel_st7789 failed: %s", esp_err_to_name(ret));
return ret;
}
/* Apply panel offset for the visible window. */
ret = esp_lcd_panel_set_gap(*ret_panel, M5_STICKS3_LCD_OFFSET_X, M5_STICKS3_LCD_OFFSET_Y);
if (ret != ESP_OK) {
ESP_LOGW(TAG, "esp_lcd_panel_set_gap failed: %s", esp_err_to_name(ret));
}
return ESP_OK;
}