Skip to content

Commit

Permalink
Merge branch 'master' into feature/BSP-276-add_io_expander_tca95xx_16…
Browse files Browse the repository at this point in the history
…_bit_fix_endianness
  • Loading branch information
espzav authored Aug 28, 2023
2 parents 3a348ee + a56fef2 commit 4a0a0bd
Show file tree
Hide file tree
Showing 33 changed files with 2,592 additions and 1,431 deletions.
2 changes: 1 addition & 1 deletion .build-test-rules.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
examples:
disable:
- if: IDF_VERSION_MAJOR < 5 and CONFIG_NAME not in ["esp-box", "esp-box-lite"]
- if: IDF_VERSION_MAJOR < 5 and CONFIG_NAME not in ["esp-box", "esp-box-lite", "esp32_s3_eye"]
reason: Example depends on BSP, which is supported only for IDF >= 5.0
8 changes: 4 additions & 4 deletions LCD.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ The list of available LCD displays and links to LCD driver component and touch d
| <img src="docu/pics/wrover.png" width="150"> | [ESP-WROVER-KIT](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/hw-reference/esp32/get-started-wrover-kit.html) | ILI9341 | [IDF](https://github.com/espressif/esp-idf/tree/master/components/esp_lcd) | -| - | |
| <img src="docu/pics/box.webp" width="150"> | ESP-BOX | ST7789 | [IDF](https://github.com/espressif/esp-idf/tree/master/components/esp_lcd) | TT21100 | [Component Manager](https://components.espressif.com/component/espressif/esp_lcd_touch_tt21100) | |
| <img src="docu/pics/kaluga.png" width="150"> | [ESP32-S2-Kaluga Kit](https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/hw-reference/esp32s2/user-guide-esp32-s2-kaluga-1-kit.html) | ST7789 | [IDF](https://github.com/espressif/esp-idf/tree/master/components/esp_lcd) | - | - | |
| <img src="docu/pics/esp32_s3_otg.png" width="150"> | [ESP32-S3-USB-OTG](https://docs.espressif.com/projects/espressif-esp-dev-kits/en/latest/esp32s3/esp32-s3-usb-otg/user_guide.html) | ST7789 | [IDF](https://github.com/espressif/esp-idf/tree/master/components/esp_lcd) | - | - | |
| <img src="docu/pics/esp32-s2-hmi-devkit-1-3d-v1.0.png" width="150"> | [ESP32-S2-HMI-DevKit-1](https://docs.espressif.com/projects/espressif-esp-dev-kits/en/latest/esp32s2/esp32-s2-hmi-devkit-1/user_guide.html#hardware-overview) | RM68120 | **IN PLAN** | FT5X06 | [Component Manager](https://components.espressif.com/component/espressif/esp_lcd_touch_ft5x06) | |
| <img src="docu/pics/esp32_s3_otg.png" width="150"> | [ESP32-S3-USB-OTG](https://docs.espressif.com/projects/esp-dev-kits/en/latest/esp32s3/esp32-s3-usb-otg/user_guide.html) | ST7789 | [IDF](https://github.com/espressif/esp-idf/tree/master/components/esp_lcd) | - | - | |
| <img src="docu/pics/esp32-s2-hmi-devkit-1-3d-v1.0.png" width="150"> | [ESP32-S2-HMI-DevKit-1](https://docs.espressif.com/projects/esp-dev-kits/en/latest/esp32s2/esp32-s2-hmi-devkit-1/user_guide.html#hardware-overview) | RM68120 | **IN PLAN** | FT5X06 | [Component Manager](https://components.espressif.com/component/espressif/esp_lcd_touch_ft5x06) | |
| <img src="docu/pics/1.28inch-LCD-Module-1.jpg" width="150"> | [Waveshare 1.28" round LCD](https://www.waveshare.com/product/1.28inch-lcd-module.htm) | GC9A01 | [Component Manager](https://components.espressif.com/component/espressif/esp_lcd_gc9a01) | - | - | |
| <img src="docu/pics/7inch-Capacitive-Touch-LCD-C_l.jpg" width="150"> | [Waveshare 7" LCD](https://www.waveshare.com/7inch-capacitive-touch-lcd-c.htm) | RA8875 | [Component Manager](https://components.espressif.com/component/espressif/esp_lcd_ra8875) | GT911 | [Component Manager](https://components.espressif.com/component/espressif/esp_lcd_touch_gt911) | |
| <img src="docu/pics/Adafruit-PiTFT.jpg" width="150"> | [Adafruit PiTFT - 2.8"](https://learn.adafruit.com/adafruit-pitft-28-inch-resistive-touchscreen-display-raspberry-pi) | ILI9341 | [Component Manager](https://components.espressif.com/component/espressif/esp_lcd_ili9341) | STMPE610 | [Component Manager](https://components.espressif.com/component/espressif/esp_lcd_touch_stmpe610) | |
Expand All @@ -18,5 +18,5 @@ The list of available LCD displays and links to LCD driver component and touch d
| <img src="docu/pics/ssd1306.jpg" width="150"> | 128x32 0,91" OLED | SSD1306 | [IDF](https://github.com/espressif/esp-idf/tree/master/components/esp_lcd) | - | - | |
| <img src="docu/pics/ssd1963.jpg" width="150"> | Parallel | SSD1963 | **N/A** | - | - | |
| <img src="docu/pics/st7796.jpg" width="150"> | Parallel/SPI | ST7796 | [Component Manager](https://components.espressif.com/component/espressif/esp_lcd_st7796) | - | - | |
| <img src="docu/pics/esp32-s3-lcd-ev-board_480x480.png" width="150"> | [ESP32-S3-LCD-EV-Board](https://docs.espressif.com/projects/espressif-esp-dev-kits/en/latest/esp32s3/esp32-s3-lcd-ev-board/user_guide.html) | GC9503 | [Component Manager](https://components.espressif.com/component/espressif/esp_lcd_gc9503) | FT5X06 | [Component Manager](https://components.espressif.com/component/espressif/esp_lcd_touch_ft5x06) | |
| <img src="docu/pics/esp32-s3-lcd-ev-board_800x480.png" width="150"> | [ESP32-S3-LCD-EV-Board-2](https://docs.espressif.com/projects/espressif-esp-dev-kits/en/latest/esp32s3/esp32-s3-lcd-ev-board/user_guide.html) | ST7262E43 | **N/A** | GT1151 | [Component Manager](https://components.espressif.com/component/espressif/esp_lcd_touch_gt1151) | |
| <img src="docu/pics/esp32-s3-lcd-ev-board_480x480.png" width="150"> | [ESP32-S3-LCD-EV-Board](https://docs.espressif.com/projects/esp-dev-kits/en/latest/esp32s3/esp32-s3-lcd-ev-board/user_guide.html) | GC9503 | [Component Manager](https://components.espressif.com/component/espressif/esp_lcd_gc9503) | FT5X06 | [Component Manager](https://components.espressif.com/component/espressif/esp_lcd_touch_ft5x06) | |
| <img src="docu/pics/esp32-s3-lcd-ev-board_800x480.png" width="150"> | [ESP32-S3-LCD-EV-Board-2](https://docs.espressif.com/projects/esp-dev-kits/en/latest/esp32s3/esp32-s3-lcd-ev-board/user_guide.html) | ST7262E43 | **N/A** | GT1151 | [Component Manager](https://components.espressif.com/component/espressif/esp_lcd_touch_gt1151) | |
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ Board support packages for development boards using Espressif's SoCs, written in
| [ESP32-S2-Kaluga Kit](esp32_s2_kaluga_kit) | ESP32-S2 | LCD display, audio codec + power amplifier,<br>smart LED and camera | <img src="docu/pics/kaluga.png" width="150"> |
| [ESP32-S3-USB-OTG](esp32_s3_usb_otg) | ESP32-S3 | LCD display, uSD card slot, USB-OTG | <img src="docu/pics/esp32_s3_otg.png" width="150"> |
| [ESP32-S3-EYE](esp32_s3_eye) | ESP32-S3 | LCD display, camera, uSD card slot, microphone and accelerometer | <img src="docu/pics/s3-eye.webp" width="150"> |
| [ESP32-S3-LCD-EV-BOARD](esp32_s3_lcd_ev_board) | ESP32-S3 | LCD display with touch, audio codec + power amplifier | <img src="docu/pics/esp32-s3-lcd-ev-board_800x480.png" width="150"> |
| [ESP32-S3-LCD-EV-Board](esp32_s3_lcd_ev_board) | ESP32-S3 | LCD display with touch, audio codec + power amplifier | <img src="docu/pics/esp32-s3-lcd-ev-board_480x480.png" width="150"> |
| [ESP32-S3-LCD-EV-Board-2](esp32_s3_lcd_ev_board) | ESP32-S3 | LCD display with touch, audio codec + power amplifier | <img src="docu/pics/esp32-s3-lcd-ev-board_800x480.png" width="150"> |
| [ESP32-S3-Korvo-2](esp32_s3_korvo_2) | ESP32-S3 | LCD display, camera, uSD card slot, microphone, audio codec + power amplifier | <img src="docu/pics/korvo-2.png" width="150"> |
| [ESP32-LyraT](esp32_lyrat) | ESP32 | uSD card slot, microphone, audio codec + power amplifier | <img src="docu/pics/lyrat.png" width="150"> |
| [ESP32-C3-LCDKit](esp32_c3_lcdkit) | ESP32-C3 | LCD display with encoder, IR, PDM audio| <img src="docu/pics/esp32_c3_lcdkit.png" width="150"> |
Expand Down Expand Up @@ -41,12 +42,12 @@ Best way to start with ESP-BSP is trying one of the [examples](examples) on your
| [display_camera](examples/display_camera) | Kaluga-kit |
| [display_audio_photo](examples/display_audio_photo) | ESP-BOX |
| [display_rotation](examples/display_rotation) | ESP-BOX |
| [display_lvgl_demos](examples/display_lvgl_demos) | ESP32-S3-LCD-EV-BOARD |
| [display_lvgl_demos](examples/display_lvgl_demos) | ESP32-S3-LCD-EV-Board |
| [mqtt_example](examples/mqtt_example) | Azure-IoT-kit |
| [sensors_example](examples/sensors_example) | Azure-IoT-kit |

### BSP headers
Each BSP provides its header file in 'bsp' subfolder, so it can be included as follows: `#include "bsp/name-of-the-bsp.h"`.
Each BSP provides its header file in 'bsp' subfolder, so it can be included as follows: `#include "bsp/name-of-the-bsp.h"`.
For you convenience, each BSP also provides a wrapper header, which has the same name for all BSPs: `#include "bsp/esp-bsp.h"`.

BSPs that contain LCD screen or touchscreen also provide `bsp/display.h` and `bsp/touch.h`. These files provide functions for LCD or touchscreen initialization without LVGL graphics library, which is used by default.
Expand Down
11 changes: 9 additions & 2 deletions esp32_s3_eye/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
#IDF version is less than IDF5.0
if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_LESS "5.0")
set(SRC_VER "esp32_s3_eye_idf4.c")
else()
set(SRC_VER "esp32_s3_eye_idf5.c")
endif()

idf_component_register(
SRCS "esp32_s3_eye.c"
SRCS "esp32_s3_eye.c" ${SRC_VER}
INCLUDE_DIRS "include"
PRIV_INCLUDE_DIRS "priv_include"
REQUIRES driver
REQUIRES driver spiffs
PRIV_REQUIRES fatfs esp_lcd
)
34 changes: 34 additions & 0 deletions esp32_s3_eye/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,33 @@ menu "Board Support Package"
default 400000 if BSP_I2C_FAST_MODE
default 100000
endmenu

menu "SPIFFS - Virtual File System"
config BSP_SPIFFS_FORMAT_ON_MOUNT_FAIL
bool "Format SPIFFS if mounting fails"
default n
help
Format SPIFFS if it fails to mount the filesystem.

config BSP_SPIFFS_MOUNT_POINT
string "SPIFFS mount point"
default "/spiffs"
help
Mount point of SPIFFS in the Virtual File System.

config BSP_SPIFFS_PARTITION_LABEL
string "Partition label of SPIFFS"
default "storage"
help
Partition label which stores SPIFFS.

config BSP_SPIFFS_MAX_FILES
int "Maximum files that could be open at the same time"
default 2
help
Supported max files for SPIFFS in the Virtual File System.
endmenu

menu "uSD card - Virtual File System"
config BSP_SD_FORMAT_ON_MOUNT_FAIL
bool "Format uSD card if mounting fails"
Expand Down Expand Up @@ -61,4 +88,11 @@ menu "Board Support Package"
LEDC channel is used to generate PWM signal that controls display brightness.
Set LEDC index that should be used.
endmenu

config BSP_I2S_NUM
int "I2S peripheral index"
default 1
range 0 1
help
ESP32S3 has two I2S peripherals, pick the one you want to use.
endmenu
149 changes: 124 additions & 25 deletions esp32_s3_eye/esp32_s3_eye.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand All @@ -11,6 +11,8 @@
#include "esp_lcd_panel_ops.h"
#include "esp_log.h"
#include "esp_check.h"
#include "esp_vfs_fat.h"
#include "esp_spiffs.h"

#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
Expand All @@ -27,31 +29,46 @@
static const char *TAG = "S3-EYE";

sdmmc_card_t *bsp_sdcard = NULL; // Global uSD card handler
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
static adc_oneshot_unit_handle_t bsp_adc_handle = NULL;
#endif

const button_config_t bsp_button_config[BSP_BUTTON_NUM] = {
static const button_config_t bsp_button_config[BSP_BUTTON_NUM] = {
{
.type = BUTTON_TYPE_ADC,
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
.adc_button_config.adc_handle = &bsp_adc_handle,
#endif
.adc_button_config.adc_channel = ADC_CHANNEL_0, // ADC1 channel 0 is GPIO1
.adc_button_config.button_index = BSP_BUTTON_MENU,
.adc_button_config.min = 2310, // middle is 2410mV
.adc_button_config.max = 2510
},
{
.type = BUTTON_TYPE_ADC,
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
.adc_button_config.adc_handle = &bsp_adc_handle,
#endif
.adc_button_config.adc_channel = ADC_CHANNEL_0, // ADC1 channel 0 is GPIO1
.adc_button_config.button_index = BSP_BUTTON_PLAY,
.adc_button_config.min = 1880, // middle is 1980mV
.adc_button_config.max = 2080
},
{
.type = BUTTON_TYPE_ADC,
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
.adc_button_config.adc_handle = &bsp_adc_handle,
#endif
.adc_button_config.adc_channel = ADC_CHANNEL_0, // ADC1 channel 0 is GPIO1
.adc_button_config.button_index = BSP_BUTTON_DOWN,
.adc_button_config.min = 720, // middle is 820mV
.adc_button_config.max = 920
},
{
.type = BUTTON_TYPE_ADC,
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
.adc_button_config.adc_handle = &bsp_adc_handle,
#endif
.adc_button_config.adc_channel = ADC_CHANNEL_0, // ADC1 channel 0 is GPIO1
.adc_button_config.button_index = BSP_BUTTON_UP,
.adc_button_config.min = 280, // middle is 380mV
Expand All @@ -61,6 +78,13 @@ const button_config_t bsp_button_config[BSP_BUTTON_NUM] = {

esp_err_t bsp_i2c_init(void)
{
static bool i2c_initialized = false;

/* I2C was initialized before */
if (i2c_initialized) {
return ESP_OK;
}

const i2c_config_t i2c_conf = {
.mode = I2C_MODE_MASTER,
.sda_io_num = BSP_I2C_SDA,
Expand All @@ -72,6 +96,8 @@ esp_err_t bsp_i2c_init(void)
BSP_ERROR_CHECK_RETURN_ERR(i2c_param_config(BSP_I2C_NUM, &i2c_conf));
BSP_ERROR_CHECK_RETURN_ERR(i2c_driver_install(BSP_I2C_NUM, i2c_conf.mode, 0, 0, 0));

i2c_initialized = true;

return ESP_OK;
}

Expand All @@ -81,6 +107,38 @@ esp_err_t bsp_i2c_deinit(void)
return ESP_OK;
}

esp_err_t bsp_spiffs_mount(void)
{
esp_vfs_spiffs_conf_t conf = {
.base_path = CONFIG_BSP_SPIFFS_MOUNT_POINT,
.partition_label = CONFIG_BSP_SPIFFS_PARTITION_LABEL,
.max_files = CONFIG_BSP_SPIFFS_MAX_FILES,
#ifdef CONFIG_BSP_SPIFFS_FORMAT_ON_MOUNT_FAIL
.format_if_mount_failed = true,
#else
.format_if_mount_failed = false,
#endif
};

esp_err_t ret_val = esp_vfs_spiffs_register(&conf);

BSP_ERROR_CHECK_RETURN_ERR(ret_val);

size_t total = 0, used = 0;
ret_val = esp_spiffs_info(conf.partition_label, &total, &used);
if (ret_val != ESP_OK) {
ESP_LOGE(TAG, "Failed to get SPIFFS partition information (%s)", esp_err_to_name(ret_val));
} else {
ESP_LOGI(TAG, "Partition size: total: %d, used: %d", total, used);
}

return ret_val;
}

esp_err_t bsp_spiffs_unmount(void)
{
return esp_vfs_spiffs_unregister(CONFIG_BSP_SPIFFS_PARTITION_LABEL);
}

esp_err_t bsp_sdcard_mount(void)
{
Expand Down Expand Up @@ -112,12 +170,16 @@ esp_err_t bsp_sdcard_mount(void)
.flags = 0,
};

return esp_vfs_fat_sdmmc_mount(BSP_MOUNT_POINT, &host, &slot_config, &mount_config, &bsp_sdcard);
#if !CONFIG_FATFS_LONG_FILENAMES
ESP_LOGW(TAG, "Warning: Long filenames on SD card are disabled in menuconfig!");
#endif

return esp_vfs_fat_sdmmc_mount(BSP_SD_MOUNT_POINT, &host, &slot_config, &mount_config, &bsp_sdcard);
}

esp_err_t bsp_sdcard_unmount(void)
{
return esp_vfs_fat_sdcard_unmount(BSP_MOUNT_POINT, bsp_sdcard);
return esp_vfs_fat_sdcard_unmount(BSP_SD_MOUNT_POINT, bsp_sdcard);
}

#define LCD_CMD_BITS (8)
Expand Down Expand Up @@ -275,16 +337,25 @@ static lv_disp_t *bsp_display_lcd_init(void)

lv_disp_t *bsp_display_start(void)
{
lv_disp_t *disp = NULL;
const lvgl_port_cfg_t lvgl_cfg = {
.task_priority = CONFIG_BSP_DISPLAY_LVGL_TASK_PRIORITY,
.task_stack = 4096,
.task_affinity = 1,
.timer_period_ms = LVGL_TICK_PERIOD_MS,
.task_max_sleep_ms = 1,
bsp_display_cfg_t cfg = {
.lvgl_port_cfg = {
.task_priority = CONFIG_BSP_DISPLAY_LVGL_TASK_PRIORITY,
.task_stack = 4096,
.task_affinity = 1,
.timer_period_ms = LVGL_TICK_PERIOD_MS,
.task_max_sleep_ms = 1,
}
};
BSP_ERROR_CHECK_RETURN_NULL(lvgl_port_init(&lvgl_cfg));
return bsp_display_start_with_config(&cfg);
}

lv_disp_t *bsp_display_start_with_config(const bsp_display_cfg_t *cfg)
{
lv_disp_t *disp;
assert(cfg != NULL);
BSP_ERROR_CHECK_RETURN_NULL(lvgl_port_init(&cfg->lvgl_port_cfg));
BSP_NULL_CHECK(disp = bsp_display_lcd_init(), NULL);

return disp;
}

Expand Down Expand Up @@ -327,23 +398,51 @@ esp_err_t bsp_led_set(const bsp_led_t led_io, const bool on)
return ESP_OK;
}

esp_err_t bsp_audio_init(const i2s_std_config_t *i2s_config, i2s_chan_handle_t *tx_channel, i2s_chan_handle_t *rx_channel)
esp_codec_dev_handle_t bsp_audio_codec_microphone_init(void)
{
/* Setup I2S peripheral */
const i2s_chan_config_t chan_cfg = I2S_CHANNEL_DEFAULT_CONFIG(I2S_NUM_AUTO, I2S_ROLE_MASTER);
BSP_ERROR_CHECK_RETURN_ERR(i2s_new_channel(&chan_cfg, NULL, rx_channel));
if (tx_channel) {
*tx_channel = NULL; // TX is not used in ESP32-S3-EYE board
const audio_codec_data_if_t *i2s_data_if = bsp_audio_get_codec_itf();
if (i2s_data_if == NULL) {
/* Initilize I2C */
BSP_ERROR_CHECK_RETURN_NULL(bsp_i2c_init());
/* Configure I2S peripheral and Power Amplifier */
BSP_ERROR_CHECK_RETURN_NULL(bsp_audio_init(NULL));
i2s_data_if = bsp_audio_get_codec_itf();
}
assert(i2s_data_if);

/* Setup I2S channel */
const i2s_std_config_t std_cfg_default = BSP_I2S_SIMPLEX_MONO_CFG(); // Default config
const i2s_std_config_t *p_i2s_cfg = i2s_config ? i2s_config : &std_cfg_default;
esp_codec_dev_cfg_t codec_dev_cfg = {
.dev_type = ESP_CODEC_DEV_TYPE_IN,
.codec_if = NULL,
.data_if = i2s_data_if,
};
return esp_codec_dev_new(&codec_dev_cfg);
}

if (rx_channel != NULL) {
BSP_ERROR_CHECK_RETURN_ERR(i2s_channel_init_std_mode(*rx_channel, p_i2s_cfg));
BSP_ERROR_CHECK_RETURN_ERR(i2s_channel_enable(*rx_channel));
esp_err_t bsp_iot_button_create(button_handle_t btn_array[], int *btn_cnt, int btn_array_size)
{
esp_err_t ret = ESP_OK;
if ((btn_array_size < BSP_BUTTON_NUM) ||
(btn_array == NULL)) {
return ESP_ERR_INVALID_ARG;
}
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
/* Initialize ADC and get ADC handle */
BSP_ERROR_CHECK_RETURN_NULL(bsp_adc_initialize());
bsp_adc_handle = bsp_adc_get_handle();
#endif

return ESP_OK;
if (btn_cnt) {
*btn_cnt = 0;
}
for (int i = 0; i < BSP_BUTTON_NUM; i++) {
btn_array[i] = iot_button_create(&bsp_button_config[i]);
if (btn_array[i] == NULL) {
ret = ESP_FAIL;
break;
}
if (btn_cnt) {
(*btn_cnt)++;
}
}
return ret;
}
Loading

0 comments on commit 4a0a0bd

Please sign in to comment.