chore: checkpoint 第一版
ci / verify (push) Canceled after 0s

This commit is contained in:
Codex Local
2026-09-06 17:04:11 +08:00
parent a8cdec98d1
commit 0c2151ace9
659 changed files with 185855 additions and 554 deletions
@@ -0,0 +1,110 @@
/*
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @file
* @brief BSP LCD
*
* This file offers API for basic LCD control.
* It is useful for users who want to use the LCD without the default Graphical Library LVGL.
*
* For standard LCD initialization with LVGL graphical library, you can call all-in-one function bsp_display_start().
*/
#pragma once
#include "esp_lcd_types.h"
/* LCD color formats */
#define ESP_LCD_COLOR_FORMAT_RGB565 (1)
#define ESP_LCD_COLOR_FORMAT_RGB888 (2)
/* LCD display color format */
#define BSP_LCD_COLOR_FORMAT (ESP_LCD_COLOR_FORMAT_RGB565)
/* LCD display color bytes endianness */
#define BSP_LCD_BIGENDIAN (1)
/* LCD display color bits */
#define BSP_LCD_BITS_PER_PIXEL (16)
/* LCD display color space */
#define BSP_LCD_COLOR_SPACE (ESP_LCD_COLOR_SPACE_RGB)
/* LCD definition */
#define BSP_LCD_H_RES (360)
#define BSP_LCD_V_RES (360)
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief BSP display configuration structure
*
*/
typedef struct {
int max_transfer_sz; /*!< Maximum transfer size, in bytes. */
} bsp_display_config_t;
/**
* @brief Create new display panel
*
* For maximum flexibility, this function performs only reset and initialization of the display.
* You must turn on the display explicitly by calling esp_lcd_panel_disp_on_off().
* The display's backlight is not turned on either. You can use bsp_display_backlight_on/off(),
* bsp_display_brightness_set() (on supported boards) or implement your own backlight control.
*
* If you want to free resources allocated by this function, you can use esp_lcd API, ie.:
*
* \code{.c}
* esp_lcd_panel_del(panel);
* esp_lcd_panel_io_del(io);
* spi_bus_free(spi_num_from_configuration);
* \endcode
*
* @param[in] config display configuration
* @param[out] ret_panel esp_lcd panel handle
* @param[out] ret_io esp_lcd IO handle
* @return
* - ESP_OK On success
* - Else esp_lcd failure
*/
esp_err_t bsp_display_new(const bsp_display_config_t *config, esp_lcd_panel_handle_t *ret_panel, esp_lcd_panel_io_handle_t *ret_io);
/**
* @brief Set display's brightness
*
* Brightness is controlled with PWM signal to a pin controlling backlight.
* Display must be already initialized by calling bsp_display_new()
*
* @param[in] brightness_percent Brightness in [%]
* @return
* - ESP_OK On success
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t bsp_display_brightness_set(int brightness_percent);
/**
* @brief Turn on display backlight
*
* Display must be already initialized by calling bsp_display_new()
*
* @return
* - ESP_OK On success
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t bsp_display_backlight_on(void);
/**
* @brief Turn off display backlight
*
* Display must be already initialized by calling bsp_display_new()
*
* @return
* - ESP_OK On success
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t bsp_display_backlight_off(void);
#ifdef __cplusplus
}
#endif
@@ -0,0 +1,345 @@
/*
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include "sdkconfig.h"
#include "soc/usb_pins.h"
#include "driver/gpio.h"
#include "driver/i2c_master.h"
#include "driver/sdmmc_host.h"
#include "driver/sdspi_host.h"
#include "esp_vfs_fat.h"
#include "lvgl.h"
#include "esp_lvgl_port.h"
#include "bsp/display.h"
/**************************************************************************************************
* BSP Capabilities
**************************************************************************************************/
#define BSP_CAPS_DISPLAY 1
#define BSP_CAPS_TOUCH 1
#define BSP_CAPS_BUTTONS 0
#define BSP_CAPS_AUDIO 0
#define BSP_CAPS_AUDIO_SPEAKER 0
#define BSP_CAPS_AUDIO_MIC 0
#define BSP_CAPS_SDCARD 1
#define BSP_CAPS_IMU 0
/* I2C */
#define BSP_I2C_SCL (GPIO_NUM_1)
#define BSP_I2C_SDA (GPIO_NUM_2)
#define BSP_IMU_INT (GPIO_NUM_21)
/* Audio */
#define BSP_I2S_SCLK (GPIO_NUM_40) // BCLK
#define BSP_I2S_MCLK (GPIO_NUM_42)
#define BSP_I2S_LCLK (GPIO_NUM_39) // WS
#define BSP_I2S_DOUT (GPIO_NUM_41) // To Codec ES8311
#define BSP_I2S_DSIN (GPIO_NUM_3)
#define BSP_POWER_AMP_IO (GPIO_NUM_15)
#define BSP_POWER_CODEC_EN (GPIO_NUM_48)
/* Display */
#define BSP_LCD_DATA3 (GPIO_NUM_12)
#define BSP_LCD_DATA2 (GPIO_NUM_11)
#define BSP_LCD_DATA1 (GPIO_NUM_13)
#define BSP_LCD_DATA0 (GPIO_NUM_46)
#define BSP_LCD_PCLK (GPIO_NUM_18)
#define BSP_LCD_CS (GPIO_NUM_14)
#define BSP_LCD_DC (GPIO_NUM_45)
#define BSP_LCD_RST (GPIO_NUM_47)
#define BSP_LCD_BACKLIGHT (GPIO_NUM_44)
#define BSP_LCD_TOUCH_INT (GPIO_NUM_10)
/* Power */
#define BSP_POWER_OFF (GPIO_NUM_9)
/* SD card */
#define BSP_SD_D0 (GPIO_NUM_17)
#define BSP_SD_CMD (GPIO_NUM_38)
#define BSP_SD_CLK (GPIO_NUM_16)
/* USB */
#define BSP_USB_DM (GPIO_NUM_19)
#define BSP_USB_DP (GPIO_NUM_20)
/* Others */
#define BSP_UART1_TX (GPIO_NUM_5)
#define BSP_UART1_RX (GPIO_NUM_4)
#define BSP_TOUCH_PAD1 (GPIO_NUM_7)
#define BSP_TOUCH_PAD2 (GPIO_NUM_6)
#define BSP_HEAD_LED (GPIO_NUM_43) // GREEN LED
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/**
* @brief BSP display configuration structure
*
*/
typedef struct {
lvgl_port_cfg_t lvgl_port_cfg; /*!< LVGL port configuration */
uint32_t buffer_size; /*!< Size of the buffer for the screen in pixels */
bool double_buffer; /*!< True, if should be allocated two buffers */
struct {
unsigned int buff_dma : 1; /*!< Allocated LVGL buffer will be DMA capable */
unsigned int buff_spiram : 1; /*!< Allocated LVGL buffer will be in PSRAM */
unsigned int default_dummy_draw : 1; /* Use dummy draw to bypass the display driver */
} flags;
} bsp_display_cfg_t;
/**************************************************************************************************
*
* I2C interface
*
* There are multiple devices connected to I2C peripheral:
* - Codec ES8311 (configuration only)
* - ADC ES7210 (configuration only)
* - Encryption chip ATECC608A (NOT populated on most boards)
* - LCD Touch controller
* - Inertial Measurement Unit ICM-42607-P
*
* After initialization of I2C, use BSP_I2C_NUM macro when creating I2C devices drivers ie.:
* \code{.c}
* icm42670_handle_t imu = icm42670_create(BSP_I2C_NUM, ICM42670_I2C_ADDRESS);
* \endcode
**************************************************************************************************/
#define BSP_I2C_NUM CONFIG_BSP_I2C_NUM
/**
* @brief Init I2C driver
*
* @return
* - ESP_OK On success
* - ESP_ERR_INVALID_ARG I2C parameter error
* - ESP_FAIL I2C driver installation error
*
*/
esp_err_t bsp_i2c_init(void);
/**
* @brief Deinit I2C driver and free its resources
*
* @return
* - ESP_OK On success
* - ESP_ERR_INVALID_ARG I2C parameter error
*
*/
esp_err_t bsp_i2c_deinit(void);
/**
* @brief Set I2C driver handle
*
* @param handle I2C handle
*/
void bsp_i2c_set_handle(i2c_master_bus_handle_t handle);
/**
* @brief Get I2C driver handle
*
* @return
* - I2C handle
*/
i2c_master_bus_handle_t bsp_i2c_get_handle(void);
/**************************************************************************************************
*
* LCD interface
*
* ESP-BOX is shipped with 2.4inch ST7789 display controller.
* It features 16-bit colors, 320x240 resolution and capacitive touch controller.
*
* LVGL is used as graphics library. LVGL is NOT thread safe, therefore the user must take LVGL mutex
* by calling bsp_display_lock() before calling and LVGL API (lv_...) and then give the mutex with
* bsp_display_unlock().
*
* Display's backlight must be enabled explicitly by calling bsp_display_backlight_on()
**************************************************************************************************/
#define BSP_LCD_PIXEL_CLOCK_HZ (40 * 1000 * 1000)
#define BSP_LCD_SPI_NUM (SPI2_HOST)
/**
* @brief Initialize display
*
* This function initializes SPI, display controller and starts LVGL handling task.
* LCD backlight must be enabled separately by calling bsp_display_brightness_set()
*
* @return
*/
lv_disp_t *bsp_display_start(void);
/**
* @brief Initialize display
*
* This function initializes SPI, display controller and starts LVGL handling task.
* LCD backlight must be enabled separately by calling bsp_display_brightness_set()
*
* @param cfg display configuration
*
* @return
*/
lv_disp_t *bsp_display_start_with_config(const bsp_display_cfg_t *cfg);
/**
* @brief Get pointer to input device (touch, buttons, ...)
*
* @note The LVGL input device is initialized in bsp_display_start() function.
*
* @return
*/
lv_indev_t *bsp_display_get_input_dev(void);
/**
* @brief Take LVGL mutex
*
* @param timeout_ms Timeout in [ms]. 0 will block indefinitely.
* @return
* @return
*/
bool bsp_display_lock(uint32_t timeout_ms);
/**
* @brief Give LVGL mutex
*
*/
void bsp_display_unlock(void);
/**
* @brief Initialize display brightness
*
* @return
* - ESP_OK On success
* - ESP_ERR_INVALID_ARG I2C parameter error
* - ESP_FAIL I2C driver installation error
*
*/
esp_err_t bsp_display_brightness_init(void);
/**
* @brief Initialize power
*
* @param power_en power enable
*
* @return
* - ESP_OK On success
* - ESP_ERR_INVALID_ARG I2C parameter error
* - ESP_FAIL I2C driver installation error
*
*/
esp_err_t bsp_power_init(bool power_en);
/**************************************************************************************************
*
* SD card
*
* After mounting the SD card, it can be accessed with stdio functions ie.:
* \code{.c}
* FILE* f = fopen(BSP_SD_MOUNT_POINT"/hello.txt", "w");
* fprintf(f, "Hello %s!\n", bsp_sdcard->cid.name);
* fclose(f);
* \endcode
*
* @attention IO2 is also routed to RGB LED and push button
**************************************************************************************************/
#define BSP_SD_MOUNT_POINT CONFIG_BSP_SD_MOUNT_POINT
/**
* @brief BSP SD card configuration structure
*/
typedef struct {
const esp_vfs_fat_sdmmc_mount_config_t *mount;
sdmmc_host_t *host;
union {
const sdmmc_slot_config_t *sdmmc;
} slot;
} bsp_sdcard_cfg_t;
/**
* @brief Mount microSD card to virtual file system
*
* @return
* - ESP_OK on success
* - ESP_ERR_INVALID_STATE if esp_vfs_fat_sdmmc_mount was already called
* - ESP_ERR_NO_MEM if memory can not be allocated
* - ESP_FAIL if partition can not be mounted
* - other error codes from SDMMC or SPI drivers, SDMMC protocol, or FATFS drivers
*/
esp_err_t bsp_sdcard_mount(void);
/**
* @brief Unmount micorSD card from virtual file system
*
* @return
* - ESP_OK on success
* - ESP_ERR_NOT_FOUND if the partition table does not contain FATFS partition with given label
* - ESP_ERR_INVALID_STATE if esp_vfs_fat_spiflash_mount was already called
* - ESP_ERR_NO_MEM if memory can not be allocated
* - ESP_FAIL if partition can not be mounted
* - other error codes from wear levelling library, SPI flash driver, or FATFS drivers
*/
esp_err_t bsp_sdcard_unmount(void);
/**
* @brief Get SD card handle
*
* @return
*/
sdmmc_card_t *bsp_sdcard_get_handle(void);
/**
* @brief Get SD card MMC host config
*
* @param slot SD card slot
* @param config Structure which will be filled
*/
void bsp_sdcard_get_sdmmc_host(const int slot, sdmmc_host_t *config);
/**
* @brief Get SD card MMC slot config
*
* @param slot SD card slot
* @param config Structure which will be filled
*/
void bsp_sdcard_sdmmc_get_slot(const int slot, sdmmc_slot_config_t *config);
/**
* @brief Mount microSD card to virtual file system (MMC mode)
*
* @param cfg SD card configuration
*
* @return
* - ESP_OK on success
* - ESP_ERR_INVALID_STATE if esp_vfs_fat_sdmmc_mount was already called
* - ESP_ERR_NO_MEM if memory cannot be allocated
* - ESP_FAIL if partition cannot be mounted
* - other error codes from SDMMC or SPI drivers, SDMMC protocol, or FATFS drivers
*/
esp_err_t bsp_sdcard_sdmmc_mount(bsp_sdcard_cfg_t *cfg);
/**
* @brief Get SD card handle
*
* @return
*/
sdmmc_card_t *bsp_sdcard_get_handle(void);
/**
* @brief Set peripheral power
*
* @param on true to turn on, false to turn off
*
* @return
* - ESP_OK on success
* - ESP_ERR_INVALID_ARG if the parameter is invalid
*/
esp_err_t bsp_set_peripheral_power(bool on);
#ifdef __cplusplus
}
#endif /* __cplusplus */
@@ -0,0 +1,8 @@
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include "bsp/echoear.h"
@@ -0,0 +1,51 @@
/*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @file
* @brief BSP Touchscreen
*
* This file offers API for basic touchscreen initialization.
* It is useful for users who want to use the touchscreen without the default Graphical Library LVGL.
*
* For standard LCD initialization with LVGL graphical library, you can call all-in-one function bsp_display_start().
*/
#pragma once
#include "esp_lcd_touch.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief BSP touch configuration structure
*
*/
typedef struct {
void *dummy; /*!< Prepared for future use. */
} bsp_touch_config_t;
/**
* @brief Create new touchscreen
*
* If you want to free resources allocated by this function, you can use esp_lcd_touch API, ie.:
*
* \code{.c}
* esp_lcd_touch_del(tp);
* \endcode
*
* @param[in] config touch configuration
* @param[out] ret_touch esp_lcd_touch touchscreen handle
* @return
* - ESP_OK On success
* - Else esp_lcd_touch failure
*/
esp_err_t bsp_touch_new(const bsp_touch_config_t *config, esp_lcd_touch_handle_t *ret_touch);
#ifdef __cplusplus
}
#endif