Commit a1502865 authored by Yu Zhe's avatar Yu Zhe

feature(demo):add ESP32-S3-Cube factory demo codes

parents
.config
*.o
*.pyc
# gtags
GTAGS
GRTAGS
GPATH
# emacs
.dir-locals.el
# emacs temp file suffixes
*~
.#*
\#*#
# eclipse setting
.settings
# MacOS directory files
.DS_Store
# Example project files
**/examples/**/sdkconfig
**/examples/**/sdkconfig.old
**/examples/**/build
**/sdkconfig
**/sdkconfig.old
**/build
**/.idea
# Doc build artifacts
**/docs/_build/
**/docs/doxygen_sqlite3.db
# Downloaded font files
**/docs/_static/DejaVuSans.ttf
**/docs/_static/NotoSansSC-Regular.otf
# Unit test app files
tools/unit-test-app/sdkconfig
tools/unit-test-app/sdkconfig.old
tools/unit-test-app/build
tools/unit-test-app/builds
tools/unit-test-app/output
# IDF monitor test
tools/test_idf_monitor/outputs
TEST_LOGS
# gcov coverage reports
*.gcda
*.gcno
coverage.info
coverage_report/
test_multi_heap_host
# VS Code Settings
.vscode/
# VIM files
*.swp
*.swo
# Clion IDE CMake build & config
.idea/
cmake-build-*/
# Results for the checking of the Python coding style and static analysis
.mypy_cache
flake8_output.txt
# ESP-IDF default build directory name
build
# lock files for examples and components
dependencies.lock
stages:
- build
- deploy
variables:
ESP_HMI_PATH: "$CI_PROJECT_DIR"
before_script:
# add gitlab ssh key
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo -n $GITLAB_KEY > ~/.ssh/id_rsa_base64
- base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- echo -e "Host gitlab.espressif.cn\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
- git --version
- git submodule update --init --recursive --force
.build_template: &build_template
stage: build
image: espressif/idf:master
tags:
- build
script:
-
push_to_github:
stage: deploy
only:
- master
- /^release\/v/
# when: on_success
image: $CI_DOCKER_REGISTRY/esp32-ci-env
variables:
GIT_STRATEGY: clone
before_script:
- echo "skip default before_script"
script:
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo -n $GH_PUSH_KEY > ~/.ssh/id_rsa_base64
- base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
- git remote remove github &>/dev/null || true
- git remote add github git@github.com:espressif/esp-hmi.git
- ${ESP_HMI_PATH}/tools/ci/push_to_github.sh
[submodule "componets/lvgl/lvgl"]
path = componets/lvgl/lvgl
url = https://github.com/lvgl/lvgl.git
[submodule "componets/lvgl/lv_demos"]
path = componets/lvgl/lv_demos
url = https://github.com/lvgl/lv_demos.git
[submodule "components/lvgl/lv_demos"]
path = components/lvgl/lv_demos
url = https://github.com/lvgl/lv_demos.git
[submodule "components/lvgl/lvgl"]
path = components/lvgl/lvgl
url = https://github.com/lvgl/lvgl.git
[submodule "components/esp32-camera"]
path = components/esp32-camera
url = https://github.com/espressif/esp32-camera.git
[submodule "components/lvgl/lv_lib/lv_lib_png"]
path = components/lvgl/lv_lib/lv_lib_png
url = https://github.com/lvgl/lv_lib_png.git
[submodule "components/lvgl/lv_lib/lv_lib_bmp"]
path = components/lvgl/lv_lib/lv_lib_bmp
url = https://github.com/lvgl/lv_lib_bmp.git
[submodule "components/lvgl/lv_lib/lv_lib_split_jpg"]
path = components/lvgl/lv_lib/lv_lib_split_jpg
url = https://github.com/lvgl/lv_lib_split_jpg.git
[submodule "components/lvgl/lv_lib/lv_lib_gif"]
path = components/lvgl/lv_lib/lv_lib_gif
url = https://github.com/lvgl/lv_lib_gif.git
[submodule "components/lvgl/lv_lib/lv_lib_freetype"]
path = components/lvgl/lv_lib/lv_lib_freetype
url = https://github.com/lvgl/lv_lib_freetype.git
[submodule "examples/lvgl/freetype/main/lib/freetype"]
path = examples/lvgl/freetype/main/lib/freetype
url = https://gitlab.freedesktop.org/freetype/freetype.git
[submodule "components/esp-sr"]
path = components/esp-sr
url = https://github.com/espressif/esp-sr.git
# CMakeLists.txt
#
# Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
This diff is collapsed.
# Espressif HMI Development Framework
* [中文版](./docs/README_cn.md)
Espressif Systems HMI Development Framework (ESP-HMI) is the official HMI development framework for the [ESP32](https://espressif.com/en/products/hardware/esp32/overview), [ESP32-S2](https://www.espressif.com/en/products/socs/esp32-s2), [ESP32-S3](https://www.espressif.com/en/products/socs/esp32-s3) and [ESP32-C3](https://www.espressif.com/en/products/socs/esp32-c3) SoCs.
## Overview
ESP-HMI supports development of HMI applications for the Espressif Systems SoCs in the most comprehensive way. With ESP-HMI, you can easily add features, develop HMI applications from simple to complex:
- Light up LCD and change pixels of it.
- Display image on LCD from Flash RO-data, SPIFFS, SD card, host via JTAG or network.
- Using TTF/OTF fonts to display CJK fonts or change it's size as you wish.
- Develop fancy GUI demo.
## Framework
ESP-HMI contains
## Development with ESP-HMI
### Setting Up ESP-IDF
See https://idf.espressif.com/ for links to detailed instructions on how to set up the ESP-IDF depending on chip you use.
**Note:** Each SoC series and each ESP-IDF release has its own documentation. Please see Section [Versions](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/versions.html) on how to find documentation and how to checkout specific release of ESP-IDF.
> **Non-GitHub forks**
>
> ESP-IDF uses relative locations as its submodules URLs ([.gitmodules](https://github.com/espressif/esp-idf/blob/master/.gitmodules)). So they link to GitHub. If ESP-IDF is forked to a Git repository which is not on GitHub, you will need to run the script [tools/set-submodules-to-github.sh](https://github.com/espressif/esp-idf/blob/master/tools/set-submodules-to-github.sh) after git clone. The script sets absolute URLs for all submodules, allowing `git submodule update --init --recursive` to complete. If cloning ESP-IDF from GitHub, this step is not needed.
### Get ESP-HMI
### Update Sub-modules
It is not necessary for you to update sub-modules if you used recursive clone.
You can run `git submodule update --init --recursive` to checkout all sub-modules.
## Examples
- Get-Started
- Basic LCD operation and input
- Image display with raw LCD APIs
- An camera receiver
- LVGL Examples
- Demos provided by LVGL
- Project template
- Display image using official image display repos
- Vector font render with FreeType
- A GUI provision demo
- Audio Examples
- A simple music player
- A simple recorder
if(CONFIG_ESP32_WROVER_KIT_BOARD)
list(APPEND BSP_BOARD_SRC "./boards/esp32_wrover_kit.c")
endif()
if(CONFIG_ESP32_S2_KALUGA_BOARD)
list(APPEND BSP_BOARD_SRC "./boards/esp32_s2_kaluga.c")
endif()
if(CONFIG_ESP32_S2_HMI_DEVKIT_BOARD)
list(APPEND BSP_BOARD_SRC "./boards/esp32_s2_hmi_devkit.c")
endif()
if(CONFIG_ESP32_S3_HMI_DEVKIT_BOARD)
list(APPEND BSP_BOARD_SRC "./boards/esp32_s3_hmi_devkit.c")
endif()
if(CONFIG_ESP32_S3_LCD_CAM_BOARD)
list(APPEND BSP_BOARD_SRC "./boards/esp32_s3_lcd_cam.c")
endif()
if(CONFIG_ESP32_S3_CUBE_BOARD)
list(APPEND BSP_BOARD_SRC "./boards/esp32_s3_cube.c")
endif()
if(CONFIG_ESP32_C3_DEVKIT_BOARD)
list(APPEND BSP_BOARD_SRC "./boards/esp32_c3_devkit.c")
endif()
file(GLOB_RECURSE BSP_SRCS
"src/lcd/bsp_lcd.c"
"src/lcd/bsp_lcd_spi.c"
"src/lcd/bsp_lcd_i80.c"
"src/bsp_codec.c"
"src/bsp_i2c.c"
"src/bsp_i2s.c"
"src/bsp_storage.c"
"src/bsp_tp.c")
if (NOT CONFIG_IDF_TARGET_ESP32C3 AND NOT CONFIG_IDF_TARGET_ESP32H2)
# list(APPEND BSP_SRCS "./src/bsp_camera.c")
endif()
if(CONFIG_ESP_CUSTOM_BOARD)
list(APPEND BSP_BOARD_SRC "./boards/esp_custom_board.c")
endif()
idf_component_register(
SRCS
${BSP_SRCS}
${BSP_BOARD_SRC}
INCLUDE_DIRS
"boards"
"include"
REQUIRES
esp_lcd
i2c_bus
i2c_devices
lvgl)
menu "HMI Board Config"
choice HMI_BOARD
prompt "HMI board"
default ESP32_S2_HMI_DEVKIT_BOARD
help
Select an HMI board to use with the HMI project
config ESP32_WROVER_KIT_BOARD
bool "ESP32-WROVER-KIT"
depends on IDF_TARGET_ESP32
config ESP32_S2_KALUGA_BOARD
bool "ESP32-S2-Kaluga-1"
depends on IDF_TARGET_ESP32S2
config ESP32_S2_HMI_DEVKIT_BOARD
bool "ESP32-S2-HMI-DevKit-1"
depends on IDF_TARGET_ESP32S2
config ESP32_S3_HMI_DEVKIT_BOARD
bool "ESP32-S3-HMI-DevKit"
depends on IDF_TARGET_ESP32S3
config ESP32_S3_LCD_CAM_BOARD
bool "ESP32-S3 LCD_CAM Board"
depends on IDF_TARGET_ESP32S3
config ESP32_S3_CUBE_BOARD
bool "ESP32-S3 Cube Dev Board"
depends on IDF_TARGET_ESP32S3
config ESP32_C3_DEVKIT_BOARD
bool "ESP32-C3 DevKit Board"
depends on IDF_TARGET_ESP32C3
config ESP_CUSTOM_BOARD
bool "Custom HMI board"
endchoice
choice LCD_INTERFACE
prompt "Select LCD interface"
depends on ESP_CUSTOM_BOARD
default LCD_INTERFACE_I80
help
Select LCD interface of custom board
config LCD_INTERFACE_I2C
bool "LCD_INTERFACE_I2C"
config LCD_INTERFACE_I80
bool "LCD_INTERFACE_I80"
config LCD_INTERFACE_SPI
bool "LCD_INTERFACE_SPI"
endchoice
menu "I80 LCD GPIO configuration"
depends on LCD_INTERFACE_I80
choice LCD_BIT_WIDTH
prompt "LCD Data Line Width"
default LCD_BIT_WIDTH_8_BIT
help
Lines of LCD data bus.
config LCD_BIT_WIDTH_8_BIT
bool "8 Bit"
config LCD_BIT_WIDTH_16_BIT
bool "16 Bit"
endchoice
config LCD_WR_GPIO
int "LCD WR GPIO"
range 0 48
default 34
config LCD_RS_GPIO
int "LCD RS GPIO"
range 0 48
default 33
config LCD_D00_GPIO
int "LCD D00 GPIO"
range 0 48
default 16
config LCD_D01_GPIO
int "LCD D01 GPIO"
range 0 48
default 15
config LCD_D02_GPIO
int "LCD D02 GPIO"
range 0 48
default 14
config LCD_D03_GPIO
int "LCD D03 GPIO"
range 0 48
default 13
config LCD_D04_GPIO
int "LCD D04 GPIO"
range 0 48
default 12
config LCD_D05_GPIO
int "LCD D05 GPIO"
range 0 48
default 11
config LCD_D06_GPIO
int "LCD D06 GPIO"
range 0 48
default 10
config LCD_D07_GPIO
int "LCD D07 GPIO"
range 0 48
default 9
config LCD_D08_GPIO
int "LCD D08 GPIO"
range 0 48
default 8
depends on LCD_BIT_WIDTH_16_BIT
config LCD_D09_GPIO
int "LCD D09 GPIO"
range 0 48
default 7
depends on LCD_BIT_WIDTH_16_BIT
config LCD_D10_GPIO
int "LCD D10 GPIO"
range 0 48
default 6
depends on LCD_BIT_WIDTH_16_BIT
config LCD_D11_GPIO
int "LCD D11 GPIO"
range 0 48
default 5
depends on LCD_BIT_WIDTH_16_BIT
config LCD_D12_GPIO
int "LCD D12 GPIO"
range 0 48
default 4
depends on LCD_BIT_WIDTH_16_BIT
config LCD_D13_GPIO
int "LCD D13 GPIO"
range 0 48
default 3
depends on LCD_BIT_WIDTH_16_BIT
config LCD_D14_GPIO
int "LCD D14 GPIO"
range 0 48
default 2
depends on LCD_BIT_WIDTH_16_BIT
config LCD_D15_GPIO
int "LCD D15 GPIO"
range 0 48
default 1
depends on LCD_BIT_WIDTH_16_BIT
endmenu
menu "I2C GPIO configuration"
depends on ESP_CUSTOM_BOARD
config I2C_SCL_GPIO
int "I2C SCL GPIO"
range 0 48
default 36
config I2C_SDA_GPIO
int "I2C SDA GPIO"
range 0 48
default 35
endmenu
menu "SPI GPIO configuration"
depends on ESP_CUSTOM_BOARD
config SPI_CS_GPIO
int "SPI CS GPIO"
range 0 48
default 37
config SPI_MISO_GPIO
int "SPI MISO GPIO"
range 0 48
default 40
config SPI_MOSI_GPIO
int "SPI MOSI GPIO"
range 0 48
default 38
config SPI_SCLK_GPIO
int "SPI SCLK GPIO"
range 0 48
default 39
endmenu
menu "TWAI GPIO configuration"
depends on ESP_CUSTOM_BOARD
config TWAI_TX_GPIO
int "TWAI TX GPIO"
range 0 48
default 41
config TWAI_RX_GPIO
int "TWAI RX GPIO"
range 0 48
default 42
endmenu
menu "Touch Panel Drivers"
depends on ESP_CUSTOM_BOARD
menu "Config Input Value"
config TOUCH_PANEL_INVERSE_X
bool "Reverse X Axis"
default n
config TOUCH_PANEL_INVERSE_Y
bool "Reverse Y Axis"
default n
config TOUCH_PANEL_SWAP_XY
bool "Swap X and Y Axis"
default n
endmenu
endmenu
endmenu
\ No newline at end of file
/**
* @file bsp_board_esp32_c3_devkit.h
* @version 0.1
* @date 2021-06-25
*
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include "driver/gpio.h"
/**
* @brief ESP32-S2-HMI-DevKit LCD GPIO defination and config
*
*/
#define FUNC_LCD_EN (1)
#define LCD_BUS_WIDTH (1)
#define LCD_WIDTH (320)
#define LCD_HEIGHT (240)
#define LCD_HOST (SPI2_HOST)
#define LCD_DISP_IC_ST (1)
#define LCD_FREQ (20 * 1000 * 1000)
#define LCD_HOST (SPI2_HOST)
#define LCD_SWAP_XY (true)
#define LCD_MIRROR_X (false)
#define LCD_MIRROR_Y (true)
#define LCD_COLOR_INV (true)
#define GPIO_LCD_BL (GPIO_NUM_8)
#define GPIO_LCD_BL_ON (1)
#define GPIO_LCD_CS (GPIO_NUM_5)
#define GPIO_LCD_RST (GPIO_NUM_9)
#define GPIO_LCD_DC (GPIO_NUM_4)
#define GPIO_LCD_WR (GPIO_NUM_6)
#define GPIO_LCD_CLK (GPIO_LCD_WR)
#define GPIO_LCD_DIN (GPIO_NUM_7)
#define GPIO_LCD_DOUT (GPIO_NUM_2)
/**
* @brief ESP32-S2-HMI-DevKit I2C GPIO defineation
*
*/
#define FUNC_I2C_EN (1)
#define GPIO_I2C_SCL (GPIO_NUM_0)
#define GPIO_I2C_SDA (GPIO_NUM_1)
/**
* @brief ESP32-S2-HMI-DevKit SDMMC GPIO defination
*
*/
#define FUNC_SDMMC_EN (0)
/**
* @brief ESP32-S2-HMI-DevKit SDSPI GPIO definationv
*
*/
#define FUNC_SDCARD_EN (1)
#define FUNC_SDSPI_EN (1)
#define GPIO_SDSPI_CS (GPIO_NUM_4)
#define GPIO_SDSPI_SCLK (GPIO_NUM_6)
#define GPIO_SDSPI_MISO (GPIO_NUM_2)
#define GPIO_SDSPI_MOSI (GPIO_NUM_7)
/**
* @brief ESP32-S2-HMI-DevKit SPI GPIO defination
*
*/
#define FUNC_SPI_EN (1)
#define GPIO_SPI_CS (GPIO_NUM_4)
#define GPIO_SPI_MISO (GPIO_NUM_2)
#define GPIO_SPI_MOSI (GPIO_NUM_7)
#define GPIO_SPI_SCLK (GPIO_NUM_6)
/**
* @brief ESP32-S2-HMI-DevKit RMT GPIO defination
*
*/
#define FUNC_RMT_EN (1)
#define GPIO_RMT_IR (GPIO_NUM_NC)
#define GPIO_RMT_LED (GPIO_NUM_10)
/**
* @brief ESP32-S2-HMI-DevKit I2S GPIO defination
*
*/
#define FUNC_I2S_EN (0)
#define GPIO_I2S_LRCK (GPIO_NUM_NC)
#define GPIO_I2S_MCLK (GPIO_NUM_NC)
#define GPIO_I2S_SCLK (GPIO_NUM_NC)
#define GPIO_I2S_SDIN (GPIO_NUM_NC)
#define GPIO_I2S_DOUT (GPIO_NUM_NC)
/**
* @brief ESP32-S3-HMI-DevKit power control IO
*
*/
#define FUNC_PWR_CTRL (0)
/**
* @brief ESP32-S3-HMI-DevKit camrea control IO
*
*/
#define FUNC_CAM_EN (0)
/**
* @file bsp_board_esp32_s3_cube.h
* @version 0.1
* @date 2021-06-25
*
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include "driver/gpio.h"
/**
* @brief ESP32-S2-HMI-DevKit LCD GPIO defination and config
*
*/
#define FUNC_LCD_EN (1)
#define LCD_BUS_WIDTH (1)
#define LCD_IFACE_SPI (1)
#define LCD_DISP_IC_ST (1)
#define LCD_WIDTH (320)
#define LCD_HEIGHT (240)
#define LCD_FREQ (40 * 1000 * 1000)
#define LCD_HOST (SPI2_HOST)
#define LCD_SWAP_XY (0)
#define LCD_MIRROR_X (false)
#define LCD_MIRROR_Y (false)
#define LCD_COLOR_INV (false)
#define GPIO_LCD_BL (GPIO_NUM_7)
#define GPIO_LCD_BL_ON (1)
#define GPIO_LCD_CS (GPIO_NUM_5)
#define GPIO_LCD_RST (GPIO_NUM_13)
#define GPIO_LCD_DC (GPIO_NUM_4)
#define GPIO_LCD_WR (GPIO_NUM_15)
#define GPIO_LCD_CLK (GPIO_LCD_WR)
#define GPIO_LCD_DIN (GPIO_NUM_6)
#define GPIO_LCD_DOUT (GPIO_NUM_NC)
#define GPIO_LCD_D00 (GPIO_NUM_NC)
#define GPIO_LCD_D01 (GPIO_NUM_NC)
#define GPIO_LCD_D02 (GPIO_NUM_NC)
#define GPIO_LCD_D03 (GPIO_NUM_NC)
#define GPIO_LCD_D04 (GPIO_NUM_NC)
#define GPIO_LCD_D05 (GPIO_NUM_NC)
#define GPIO_LCD_D06 (GPIO_NUM_NC)
#define GPIO_LCD_D07 (GPIO_NUM_NC)
#define GPIO_LCD_D08 (GPIO_NUM_NC)
#define GPIO_LCD_D09 (GPIO_NUM_NC)
#define GPIO_LCD_D10 (GPIO_NUM_NC)
#define GPIO_LCD_D11 (GPIO_NUM_NC)
#define GPIO_LCD_D12 (GPIO_NUM_NC)
#define GPIO_LCD_D13 (GPIO_NUM_NC)
#define GPIO_LCD_D14 (GPIO_NUM_NC)
#define GPIO_LCD_D15 (GPIO_NUM_NC)
/**
* @brief ESP32-S2-HMI-DevKit I2C GPIO defineation
*
*/
#define FUNC_I2C_EN (1)
#define GPIO_I2C_SCL (GPIO_NUM_18)
#define GPIO_I2C_SDA (GPIO_NUM_8)
/**
* @brief ESP32-S2-HMI-DevKit SDMMC GPIO defination
*
*/
#define FUNC_SDMMC_EN (1)
#define SDMMC_BUS_WIDTH (1)
#define GPIO_SDMMC_CLK (GPIO_NUM_10)
#define GPIO_SDMMC_CMD (GPIO_NUM_9)
#define GPIO_SDMMC_D0 (GPIO_NUM_11)
#define GPIO_SDMMC_D1 (GPIO_NUM_NC)
#define GPIO_SDMMC_D2 (GPIO_NUM_NC)
#define GPIO_SDMMC_D3 (GPIO_NUM_NC)
#define GPIO_SDMMC_DET (GPIO_NUM_NC) // GPIO_NUM_21 if R167 not removed
/**
* @brief ESP32-S2-HMI-DevKit SDSPI GPIO definationv
*
*/
#define FUNC_SDSPI_EN (1)
#define GPIO_SDSPI_CS (GPIO_NUM_4)
#define GPIO_SDSPI_SCLK (GPIO_NUM_6)
#define GPIO_SDSPI_MISO (GPIO_NUM_2)
#define GPIO_SDSPI_MOSI (GPIO_NUM_7)
/**
* @brief ESP32-S2-HMI-DevKit SPI GPIO defination
*
*/
#define FUNC_SPI_EN (1)
#define GPIO_SPI_CS (GPIO_NUM_4)
#define GPIO_SPI_MISO (GPIO_NUM_2)
#define GPIO_SPI_MOSI (GPIO_NUM_7)
#define GPIO_SPI_SCLK (GPIO_NUM_6)
/**
* @brief ESP32-S2-HMI-DevKit RMT GPIO defination
*
*/
#define FUNC_RMT_EN (1)
#define GPIO_RMT_IR (GPIO_NUM_NC)
#define GPIO_RMT_LED (GPIO_NUM_10)
/**
* @brief ESP32-S2-HMI-DevKit I2S GPIO defination
*
*/
#define FUNC_I2S_EN (1)
#define GPIO_I2S_LRCK (GPIO_NUM_47)
#define GPIO_I2S_MCLK (GPIO_NUM_14)
#define GPIO_I2S_SCLK (GPIO_NUM_21)
#define GPIO_I2S_SDIN (GPIO_NUM_12)
#define GPIO_I2S_DOUT (GPIO_NUM_48)
/**
* @brief ESP32-S3-HMI-DevKit PA power control IO
*
*/
#define FUNC_PWR_CTRL (1)
#define GPIO_PWR_CTRL (GPIO_NUM_16)
#define GPIO_PWR_ON_LEVEL (1)
/**
* @brief ESP32-S3-HMI-DevKit camrea control IO
*
*/
#define FUNC_CAM_EN (0)
#define GPIO_CAM_SCL (GPIO_NUM_NC)
#define GPIO_CAM_SDA (GPIO_NUM_NC)
#define GPIO_CAM_PCLK (GPIO_NUM_NC)
#define GPIO_CAM_XCLK (GPIO_NUM_NC)
#define GPIO_CAM_HSYNC (GPIO_NUM_NC)
#define GPIO_CAM_VSYNC (GPIO_NUM_NC)
#define GPIO_CAM_RST (GPIO_NUM_NC)
#define GPIO_CAM_PWDN (GPIO_NUM_NC)
#define GPIO_CAM_Y2 (GPIO_NUM_NC)
#define GPIO_CAM_Y3 (GPIO_NUM_NC)
#define GPIO_CAM_Y4 (GPIO_NUM_NC)
#define GPIO_CAM_Y5 (GPIO_NUM_NC)
#define GPIO_CAM_Y6 (GPIO_NUM_NC)
#define GPIO_CAM_Y7 (GPIO_NUM_NC)
#define GPIO_CAM_Y8 (GPIO_NUM_NC)
#define GPIO_CAM_Y9 (GPIO_NUM_NC)
/**
* @file bsp_board_esp32_wrover_kit.h
* @version 0.1
* @date 2021-06-25
*
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include "driver/gpio.h"
/**
* @brief ESP32-S2-HMI-DevKit LCD GPIO defination and config
*
*/
#define FUNC_LCD_EN (1)
#define LCD_BUS_WIDTH (1)
#define LCD_IFACE_SPI (1)
#define LCD_DISP_IC_ST (1)
#define LCD_WIDTH (320)
#define LCD_HEIGHT (240)
#define LCD_FREQ (20 * 1000 * 1000)
#define LCD_HOST (SPI2_HOST)
#define LCD_SWAP_XY (1)
#define LCD_MIRROR_X (0)
#define LCD_MIRROR_Y (0)
#define LCD_COLOR_INV (false)
#define GPIO_LCD_BL (GPIO_NUM_5)
#define GPIO_LCD_BL_ON (0)
#define GPIO_LCD_CS (GPIO_NUM_22)
#define GPIO_LCD_RST (GPIO_NUM_18)
#define GPIO_LCD_DC (GPIO_NUM_21)
#define GPIO_LCD_CLK (GPIO_NUM_19)
#define GPIO_LCD_DIN (GPIO_NUM_23)
#define GPIO_LCD_DOUT (GPIO_NUM_25)
/**
* @brief ESP32-S2-HMI-DevKit I2C GPIO defineation
*
*/
#define FUNC_I2C_EN (1)
#define GPIO_I2C_SCL (GPIO_NUM_27)
#define GPIO_I2C_SDA (GPIO_NUM_26)
/**
* @brief ESP32-S2-HMI-DevKit SDMMC GPIO defination
*
*/
#define FUNC_SDMMC_EN (1)
#define SDMMC_BUS_WIDTH (1)
#define GPIO_SDMMC_CLK (GPIO_NUM_14)
#define GPIO_SDMMC_CMD (GPIO_NUM_15)
#define GPIO_SDMMC_D0 (GPIO_NUM_2)
#define GPIO_SDMMC_D1 (GPIO_NUM_4)
#define GPIO_SDMMC_D2 (GPIO_NUM_12)
#define GPIO_SDMMC_D3 (GPIO_NUM_13)
#define GPIO_SDMMC_DET (GPIO_NUM_NC) // GPIO_NUM_21 if R167 not removed
/**
* @brief ESP32-S2-HMI-DevKit SDSPI GPIO definationv
*
*/
#define FUNC_SDSPI_EN (0)
#define GPIO_SDSPI_CS (GPIO_NUM_NC)
#define GPIO_SDSPI_SCLK (GPIO_NUM_NC)
#define GPIO_SDSPI_MISO (GPIO_NUM_NC)
#define GPIO_SDSPI_MOSI (GPIO_NUM_NC)
/**
* @brief ESP32-S2-HMI-DevKit SPI GPIO defination
*
*/
#define FUNC_SPI_EN (0)
#define GPIO_SPI_CS (GPIO_NUM_34)
#define GPIO_SPI_MISO (GPIO_NUM_37)
#define GPIO_SPI_MOSI (GPIO_NUM_35)
#define GPIO_SPI_SCLK (GPIO_NUM_36)
/**
* @brief ESP32-S2-HMI-DevKit RMT GPIO defination
*
*/
#define FUNC_RMT_EN (0)
#define GPIO_RMT_IR (GPIO_NUM_NC)
#define GPIO_RMT_LED (GPIO_NUM_0)
/**
* @brief ESP32-S2-HMI-DevKit I2S GPIO defination
*
*/
#define FUNC_I2S_EN (0)
#define GPIO_I2S_LRCK (GPIO_NUM_NC)
#define GPIO_I2S_MCLK (GPIO_NUM_NC)
#define GPIO_I2S_SCLK (GPIO_NUM_NC)
#define GPIO_I2S_SDIN (GPIO_NUM_NC)
#define GPIO_I2S_DOUT (GPIO_NUM_NC)
/**
* @brief ESP32-S3-HMI-DevKit power control IO
*
*/
#define FUNC_PWR_CTRL (0)
#define GPIO_PWR_CTRL (GPIO_NUM_NC)
#define GPIO_PWR_ON_LEVEL (0)
/**
* @brief ESP32-S3-HMI-DevKit camrea control IO
*
*/
#define FUNC_CAM_EN (1)
#define GPIO_CAM_SCL (GPIO_I2C_SCL)
#define GPIO_CAM_SDA (GPIO_I2C_SDA)
#define GPIO_CAM_PCLK (GPIO_NUM_22)
#define GPIO_CAM_XCLK (GPIO_NUM_21)
#define GPIO_CAM_HSYNC (GPIO_NUM_23)
#define GPIO_CAM_VSYNC (GPIO_NUM_25)
#define GPIO_CAM_RST (GPIO_NUM_0)
#define GPIO_CAM_PWDN (GPIO_NUM_NC)
#define GPIO_CAM_Y2 (GPIO_NUM_4)
#define GPIO_CAM_Y3 (GPIO_NUM_5)
#define GPIO_CAM_Y4 (GPIO_NUM_18)
#define GPIO_CAM_Y5 (GPIO_NUM_19)
#define GPIO_CAM_Y6 (GPIO_NUM_36)
#define GPIO_CAM_Y7 (GPIO_NUM_39)
#define GPIO_CAM_Y8 (GPIO_NUM_34)
#define GPIO_CAM_Y9 (GPIO_NUM_35)
/**
* @file bsp_board_esp32s2_hmi_devkit_1.h
* @brief
* @version 0.1
* @date 2021-06-25
*
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include "driver/gpio.h"
/**
* @brief ESP32-S2-HMI-DevKit LCD GPIO defination and config
*
*/
#define FUNC_LCD_EN (1)
#define LCD_IFACE_I80 (1)
#define LCD_DISP_IC_NT (1)
#define LCD_BUS_WIDTH (16)
#define LCD_WIDTH (800)
#define LCD_HEIGHT (480)
#define LCD_FREQ (20 * 1000 * 1000)
#define LCD_SWAP_XY (true)
#define LCD_MIRROR_X (true)
#define LCD_MIRROR_Y (false)
#define LCD_COLOR_INV (false)
#define TOUCH_PANEL_SWAP_XY (1)
#define TOUCH_PANEL_INVERSE_Y (1)
#define GPIO_LCD_BL (GPIO_NUM_NC)
#define GPIO_LCD_BL_ON (0)
#define GPIO_LCD_CS (GPIO_NUM_NC)
#define GPIO_LCD_RST (GPIO_NUM_NC)
#define GPIO_LCD_DC (GPIO_NUM_38)
#define GPIO_LCD_WR (GPIO_NUM_33)
#define GPIO_LCD_CLK (GPIO_LCD_WR)
#define GPIO_LCD_D00 (GPIO_NUM_1)
#define GPIO_LCD_D01 (GPIO_NUM_10)
#define GPIO_LCD_D02 (GPIO_NUM_2)
#define GPIO_LCD_D03 (GPIO_NUM_11)
#define GPIO_LCD_D04 (GPIO_NUM_3)
#define GPIO_LCD_D05 (GPIO_NUM_12)
#define GPIO_LCD_D06 (GPIO_NUM_4)
#define GPIO_LCD_D07 (GPIO_NUM_13)
#define GPIO_LCD_D08 (GPIO_NUM_5)
#define GPIO_LCD_D09 (GPIO_NUM_14)
#define GPIO_LCD_D10 (GPIO_NUM_6)
#define GPIO_LCD_D11 (GPIO_NUM_15)
#define GPIO_LCD_D12 (GPIO_NUM_7)
#define GPIO_LCD_D13 (GPIO_NUM_16)
#define GPIO_LCD_D14 (GPIO_NUM_8)
#define GPIO_LCD_D15 (GPIO_NUM_17)
/**
* @brief ESP32-S2-HMI-DevKit I2C GPIO defineation
*
*/
#define FUNC_I2C_EN (1)
#define GPIO_I2C_SCL (GPIO_NUM_39)
#define GPIO_I2C_SDA (GPIO_NUM_40)
/**
* @brief ESP32-S2-HMI-DevKit SDMMC GPIO defination
*
*/
#define FUNC_SDMMC_EN (0)
#define SDMMC_BUS_WIDTH (0)
#define GPIO_SDMMC_CLK (GPIO_NUM_NC)
#define GPIO_SDMMC_CMD (GPIO_NUM_NC)
#define GPIO_SDMMC_D0 (GPIO_NUM_NC)
#define GPIO_SDMMC_D1 (GPIO_NUM_NC)
#define GPIO_SDMMC_D2 (GPIO_NUM_NC)
#define GPIO_SDMMC_D3 (GPIO_NUM_NC)
#define GPIO_SDMMC_DET (GPIO_NUM_NC)
/**
* @brief ESP32-S2-HMI-DevKit SDSPI GPIO definationv
*
*/
#define FUNC_SDSPI_EN (1)
#define GPIO_SDSPI_CS (GPIO_NUM_34)
#define GPIO_SDSPI_SCLK (GPIO_NUM_36)
#define GPIO_SDSPI_MISO (GPIO_NUM_37)
#define GPIO_SDSPI_MOSI (GPIO_NUM_35)
/**
* @brief ESP32-S2-HMI-DevKit RMT GPIO defination
*
*/
#define FUNC_RMT_EN (1)
#define GPIO_RMT_IR (GPIO_NUM_21)
#define GPIO_RMT_LED (GPIO_NUM_21)
/**
* @brief ESP32-S2-HMI-DevKit I2S GPIO defination
*
*/
#define FUNC_I2S_EN (0)
#define GPIO_I2S_LRCK (GPIO_NUM_NC)
#define GPIO_I2S_MCLK (GPIO_NUM_NC)
#define GPIO_I2S_SCLK (GPIO_NUM_NC)
#define GPIO_I2S_SDIN (GPIO_NUM_NC)
#define GPIO_I2S_DOUT (GPIO_NUM_NC)
#define FUNC_CAM_EN (0)
#define GPIO_CAM_SCL (GPIO_I2C_SCL)
#define GPIO_CAM_SDA (GPIO_I2C_SDA)
#define GPIO_CAM_PCLK (GPIO_NUM_NC)
#define GPIO_CAM_XCLK (GPIO_NUM_NC)
#define GPIO_CAM_HSYNC (GPIO_NUM_NC)
#define GPIO_CAM_VSYNC (GPIO_NUM_NC)
#define GPIO_CAM_RST (GPIO_NUM_NC)
#define GPIO_CAM_PWDN (GPIO_NUM_NC)
#define GPIO_CAM_Y2 (GPIO_NUM_NC)
#define GPIO_CAM_Y3 (GPIO_NUM_NC)
#define GPIO_CAM_Y4 (GPIO_NUM_NC)
#define GPIO_CAM_Y5 (GPIO_NUM_NC)
#define GPIO_CAM_Y6 (GPIO_NUM_NC)
#define GPIO_CAM_Y7 (GPIO_NUM_NC)
#define GPIO_CAM_Y8 (GPIO_NUM_NC)
#define GPIO_CAM_Y9 (GPIO_NUM_NC)
/**
* @file bsp_board_esp32s2_kaluga_1.h
* @brief
* @version 0.1
* @date 2021-06-25
*
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include "driver/gpio.h"
/**
* @brief ESP32-S2-HMI-DevKit LCD GPIO defination and config
*
*/
#define FUNC_LCD_EN (1)
#define LCD_IFACE_SPI (1)
#define LCD_DISP_IC_ST (1)
#define LCD_BUS_WIDTH (1)
#define LCD_WIDTH (320)
#define LCD_HEIGHT (240)
#define LCD_FREQ (40 * 1000 * 1000)
#define LCD_HOST (SPI2_HOST)
#define LCD_SWAP_XY (true)
#define LCD_MIRROR_X (true)
#define LCD_MIRROR_Y (false)
#define LCD_COLOR_INV (false)
#define GPIO_LCD_BL (GPIO_NUM_6)
#define GPIO_LCD_BL_ON (0)
#define GPIO_LCD_CS (GPIO_NUM_11)
#define GPIO_LCD_RST (GPIO_NUM_16)
#define GPIO_LCD_DC (GPIO_NUM_13)
#define GPIO_LCD_CLK (GPIO_NUM_15)
#define GPIO_LCD_DIN (GPIO_NUM_9)
#define GPIO_LCD_DOUT (GPIO_NUM_NC)
/**
* @brief ESP32-S2-HMI-DevKit I2C GPIO defineation
*
*/
#define FUNC_I2C_EN (1)
#define GPIO_I2C_SCL (GPIO_NUM_7)
#define GPIO_I2C_SDA (GPIO_NUM_8)
/**
* @brief ESP32-S2-HMI-DevKit SDMMC GPIO defination
*
*/
#define FUNC_SDMMC_EN (0)
#define SDMMC_BUS_WIDTH (0)
#define GPIO_SDMMC_CLK (GPIO_NUM_NC)
#define GPIO_SDMMC_CMD (GPIO_NUM_NC)
#define GPIO_SDMMC_D0 (GPIO_NUM_NC)
#define GPIO_SDMMC_D1 (GPIO_NUM_NC)
#define GPIO_SDMMC_D2 (GPIO_NUM_NC)
#define GPIO_SDMMC_D3 (GPIO_NUM_NC)
#define GPIO_SDMMC_DET (GPIO_NUM_NC)
/**
* @brief ESP32-S2-HMI-DevKit SDSPI GPIO definationv
*
*/
#define FUNC_SDSPI_EN (0)
#define GPIO_SDSPI_CS (GPIO_NUM_34)
#define GPIO_SDSPI_SCLK (GPIO_NUM_36)
#define GPIO_SDSPI_MISO (GPIO_NUM_37)
#define GPIO_SDSPI_MOSI (GPIO_NUM_35)
/**
* @brief ESP32-S2-HMI-DevKit RMT GPIO defination
*
*/
#define FUNC_RMT_EN (1)
#define GPIO_RMT_IR (GPIO_NUM_45)
#define GPIO_RMT_LED (GPIO_NUM_45)
/**
* @brief ESP32-S3-HMI-DevKit PA power control IO
*
*/
#define FUNC_PWR_CTRL (1)
#define GPIO_PWR_CTRL (GPIO_NUM_10)
#define GPIO_PWR_ON_LEVEL (1)
/**
* @brief ESP32-S2-HMI-DevKit I2S GPIO defination
*
*/
#define FUNC_I2S_EN (0)
#define GPIO_I2S_LRCK (GPIO_NUM_17)
#define GPIO_I2S_MCLK (GPIO_NUM_35)
#define GPIO_I2S_SCLK (GPIO_NUM_18)
#define GPIO_I2S_SDIN (GPIO_NUM_34)
#define GPIO_I2S_DOUT (GPIO_NUM_12)
#define FUNC_CAM_EN (1)
#define GPIO_CAM_SCL (GPIO_NUM_7)
#define GPIO_CAM_SDA (GPIO_NUM_8)
#define GPIO_CAM_PCLK (GPIO_NUM_33)
#define GPIO_CAM_XCLK (GPIO_NUM_1)
#define GPIO_CAM_HSYNC (GPIO_NUM_3)
#define GPIO_CAM_VSYNC (GPIO_NUM_2)
#define GPIO_CAM_RST (GPIO_NUM_NC)
#define GPIO_CAM_PWDN (GPIO_NUM_NC)
#define GPIO_CAM_Y2 (GPIO_NUM_36)
#define GPIO_CAM_Y3 (GPIO_NUM_37)
#define GPIO_CAM_Y4 (GPIO_NUM_41)
#define GPIO_CAM_Y5 (GPIO_NUM_42)
#define GPIO_CAM_Y6 (GPIO_NUM_39)
#define GPIO_CAM_Y7 (GPIO_NUM_40)
#define GPIO_CAM_Y8 (GPIO_NUM_21)
#define GPIO_CAM_Y9 (GPIO_NUM_38)
/**
* @file bsp_board_esp32s3_hmi_devkit_1.h
* @brief
* @version 0.1
* @date 2021-06-25
*
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include "driver/gpio.h"
/**
* @brief ESP32-S2-HMI-DevKit LCD GPIO defination and config
*
*/
#define FUNC_LCD_EN (1)
#define LCD_BIT_WIDTH (8)
#define LCD_WIDTH (800)
#define LCD_HEIGHT (480)
#define LCD_FREQ (40 * 1000 * 1000)
#define LCD_SWAP_XY (true)
#define LCD_MIRROR_X (true)
#define LCD_MIRROR_Y (false)
#define LCD_COLOR_INV (false)
#define TOUCH_PANEL_SWAP_XY (1)
#define TOUCH_PANEL_INVERSE_Y (1)
#define GPIO_LCD_BL (GPIO_NUM_45)
#define GPIO_LCD_BL_ON (1)
#define GPIO_LCD_CS (GPIO_NUM_NC)
#define GPIO_LCD_RST (GPIO_NUM_1)
#define GPIO_LCD_DC (GPIO_NUM_15)
#define GPIO_LCD_WR (GPIO_NUM_7)
#define GPIO_LCD_D00 (GPIO_NUM_16)
#define GPIO_LCD_D01 (GPIO_NUM_17)
#define GPIO_LCD_D02 (GPIO_NUM_18)
#define GPIO_LCD_D03 (GPIO_NUM_8)
#define GPIO_LCD_D04 (GPIO_NUM_9)
#define GPIO_LCD_D05 (GPIO_NUM_10)
#define GPIO_LCD_D06 (GPIO_NUM_11)
#define GPIO_LCD_D07 (GPIO_NUM_12)
#define GPIO_LCD_D08 (GPIO_NUM_NC)
#define GPIO_LCD_D09 (GPIO_NUM_NC)
#define GPIO_LCD_D10 (GPIO_NUM_NC)
#define GPIO_LCD_D11 (GPIO_NUM_NC)
#define GPIO_LCD_D12 (GPIO_NUM_NC)
#define GPIO_LCD_D13 (GPIO_NUM_NC)
#define GPIO_LCD_D14 (GPIO_NUM_NC)
#define GPIO_LCD_D15 (GPIO_NUM_NC)
/**
* @brief ESP32-S2-HMI-DevKit I2C GPIO defineation
*
*/
#define FUNC_I2C_EN (1)
#define GPIO_I2C_SCL (GPIO_NUM_4)
#define GPIO_I2C_SDA (GPIO_NUM_5)
/**
* @brief ESP32-S2-HMI-DevKit SDMMC GPIO defination
*
*/
#define FUNC_SDMMC_EN (1)
#define SDMMC_BUS_WIDTH (4)
#define GPIO_SDMMC_CLK (GPIO_NUM_39)
#define GPIO_SDMMC_CMD (GPIO_NUM_40)
#define GPIO_SDMMC_D0 (GPIO_NUM_41)
#define GPIO_SDMMC_D1 (GPIO_NUM_42)
#define GPIO_SDMMC_D2 (GPIO_NUM_36)
#define GPIO_SDMMC_D3 (GPIO_NUM_37)
#define GPIO_SDMMC_DET (GPIO_NUM_35)
/**
* @brief ESP32-S2-HMI-DevKit SDSPI GPIO definationv
*
*/
#define FUNC_SDSPI_EN (0)
#define GPIO_SDSPI_CS (GPIO_NUM_NC)
#define GPIO_SDSPI_SCLK (GPIO_NUM_NC)
#define GPIO_SDSPI_MISO (GPIO_NUM_NC)
#define GPIO_SDSPI_MOSI (GPIO_NUM_NC)
/**
* @brief ESP32-S2-HMI-DevKit SPI GPIO defination
*
*/
#define FUNC_SPI_EN (1)
#define GPIO_SPI_CS (GPIO_NUM_34)
#define GPIO_SPI_MISO (GPIO_NUM_37)
#define GPIO_SPI_MOSI (GPIO_NUM_35)
#define GPIO_SPI_SCLK (GPIO_NUM_36)
/**
* @brief ESP32-S2-HMI-DevKit RMT GPIO defination
*
*/
#define FUNC_RMT_EN (1)
#define GPIO_RMT_IR (GPIO_NUM_13)
#define GPIO_RMT_LED (GPIO_NUM_0)
/**
* @brief ESP32-S2-HMI-DevKit I2S GPIO defination
*
*/
#define FUNC_I2S_EN (1)
#define GPIO_I2S_LRCK (GPIO_NUM_47)
#define GPIO_I2S_MCLK (GPIO_NUM_14)
#define GPIO_I2S_SCLK (GPIO_NUM_21)
#define GPIO_I2S_SDIN (GPIO_NUM_38)
#define GPIO_I2S_DOUT (GPIO_NUM_48)
/**
* @brief ESP32-S3-HMI-DevKit power control IO
*
*/
#define GPIO_PWR_CTRL (GPIO_NUM_2)
#define GPIO_PWR_ON_LEVEL (0)
#define FUNC_CAM_EN (1)
#define GPIO_CAM_SCL (GPIO_I2C_SCL)
#define GPIO_CAM_SDA (GPIO_I2C_SDA)
#define GPIO_CAM_PCLK (GPIO_NUM_11)
#define GPIO_CAM_XCLK (GPIO_NUM_40)
#define GPIO_CAM_HSYNC (GPIO_NUM_38)
#define GPIO_CAM_VSYNC (GPIO_NUM_21)
#define GPIO_CAM_RST (GPIO_NUM_NC)
#define GPIO_CAM_PWDN (GPIO_NUM_NC)
#define GPIO_CAM_Y2 (GPIO_NUM_13)
#define GPIO_CAM_Y3 (GPIO_NUM_47)
#define GPIO_CAM_Y4 (GPIO_NUM_14)
#define GPIO_CAM_Y5 (GPIO_NUM_3)
#define GPIO_CAM_Y6 (GPIO_NUM_12)
#define GPIO_CAM_Y7 (GPIO_NUM_42)
#define GPIO_CAM_Y8 (GPIO_NUM_41)
#define GPIO_CAM_Y9 (GPIO_NUM_39)
/**
* @file bsp_board_esp32s3_lcd_cam.h
* @brief
* @version 0.1
* @date 2021-06-25
*
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include "driver/gpio.h"
/**
* @brief ESP32-S2-HMI-DevKit LCD GPIO defination and config
*
*/
#define FUNC_LCD_EN (1)
#define LCD_IFACE_SPI (1)
#define LCD_HOST (SPI2_HOST)
#define LCD_BUS_WIDTH (8)
#define LCD_DISP_IC_ST (1)
#define LCD_WIDTH (480)
#define LCD_HEIGHT (320)
#define LCD_FREQ (40 * 1000 * 1000)
#define LCD_SWAP_XY (true)
#define LCD_MIRROR_X (false)
#define LCD_MIRROR_Y (false)
#define LCD_COLOR_INV (false)
#define TOUCH_PANEL_SWAP_XY (1)
#define TOUCH_PANEL_INVERSE_Y (1)
#define GPIO_LCD_BL (GPIO_NUM_NC)
#define GPIO_LCD_BL_ON (0)
#define GPIO_LCD_CS (GPIO_NUM_NC)
#define GPIO_LCD_RST (GPIO_NUM_NC)
#define GPIO_LCD_DC (GPIO_NUM_2)
#define GPIO_LCD_CLK (GPIO_NUM_4)
#define GPIO_LCD_D00 (GPIO_NUM_45)
#define GPIO_LCD_D01 (GPIO_NUM_16)
#define GPIO_LCD_D02 (GPIO_NUM_15)
#define GPIO_LCD_D03 (GPIO_NUM_10)
#define GPIO_LCD_D04 (GPIO_NUM_8)
#define GPIO_LCD_D05 (GPIO_NUM_7)
#define GPIO_LCD_D06 (GPIO_NUM_6)
#define GPIO_LCD_D07 (GPIO_NUM_5)
#define GPIO_LCD_D08 (GPIO_NUM_NC)
#define GPIO_LCD_D09 (GPIO_NUM_NC)
#define GPIO_LCD_D10 (GPIO_NUM_NC)
#define GPIO_LCD_D11 (GPIO_NUM_NC)
#define GPIO_LCD_D12 (GPIO_NUM_NC)
#define GPIO_LCD_D13 (GPIO_NUM_NC)
#define GPIO_LCD_D14 (GPIO_NUM_NC)
#define GPIO_LCD_D15 (GPIO_NUM_NC)
/**
* @brief ESP32-S2-HMI-DevKit I2C GPIO defineation
*
*/
#define FUNC_I2C_EN (1)
#define GPIO_I2C_SCL (GPIO_NUM_18)
#define GPIO_I2C_SDA (GPIO_NUM_17)
/**
* @brief ESP32-S2-HMI-DevKit SDMMC GPIO defination
*
*/
#define FUNC_SDMMC_EN (1)
#define SDMMC_BUS_WIDTH (1)
#define GPIO_SDMMC_CLK (GPIO_NUM_9)
#define GPIO_SDMMC_CMD (GPIO_NUM_20)
#define GPIO_SDMMC_D0 (GPIO_NUM_19)
#define GPIO_SDMMC_D1 (GPIO_NUM_NC)
#define GPIO_SDMMC_D2 (GPIO_NUM_NC)
#define GPIO_SDMMC_D3 (GPIO_NUM_NC)
#define GPIO_SDMMC_DET (GPIO_NUM_NC)
/**
* @brief ESP32-S2-HMI-DevKit SDSPI GPIO definationv
*
*/
#define FUNC_SDSPI_EN (0)
#define GPIO_SDSPI_CS (GPIO_NUM_NC)
#define GPIO_SDSPI_SCLK (GPIO_NUM_NC)
#define GPIO_SDSPI_MISO (GPIO_NUM_NC)
#define GPIO_SDSPI_MOSI (GPIO_NUM_NC)
/**
* @brief ESP32-S2-HMI-DevKit SPI GPIO defination
*
*/
#define FUNC_SPI_EN (0)
#define GPIO_SPI_CS (GPIO_NUM_34)
#define GPIO_SPI_MISO (GPIO_NUM_37)
#define GPIO_SPI_MOSI (GPIO_NUM_35)
#define GPIO_SPI_SCLK (GPIO_NUM_36)
/**
* @brief ESP32-S2-HMI-DevKit RMT GPIO defination
*
*/
#define FUNC_RMT_EN (0)
#define GPIO_RMT_IR (GPIO_NUM_NC)
#define GPIO_RMT_LED (GPIO_NUM_0)
/**
* @brief ESP32-S2-HMI-DevKit I2S GPIO defination
*
*/
#define FUNC_I2S_EN (1)
#define GPIO_I2S_LRCK (GPIO_NUM_NC)
#define GPIO_I2S_MCLK (GPIO_NUM_NC)
#define GPIO_I2S_SCLK (GPIO_NUM_0)
#define GPIO_I2S_SDIN (GPIO_NUM_1)
#define GPIO_I2S_DOUT (GPIO_NUM_48)
/**
* @brief ESP32-S3-HMI-DevKit power control IO
*
*/
#define GPIO_PWR_CTRL (GPIO_NUM_NC)
#define GPIO_PWR_ON_LEVEL (1)
/**
* @brief ESP32-S3-HMI-DevKit camrea control IO
*
*/
#define FUNC_CAM_EN (1)
#define GPIO_CAM_SCL (GPIO_I2C_SCL)
#define GPIO_CAM_SDA (GPIO_I2C_SDA)
#define GPIO_CAM_PCLK (GPIO_NUM_11)
#define GPIO_CAM_XCLK (GPIO_NUM_40)
#define GPIO_CAM_HSYNC (GPIO_NUM_38)
#define GPIO_CAM_VSYNC (GPIO_NUM_21)
#define GPIO_CAM_RST (GPIO_NUM_NC)
#define GPIO_CAM_PWDN (GPIO_NUM_NC)
#define GPIO_CAM_Y2 (GPIO_NUM_13)
#define GPIO_CAM_Y3 (GPIO_NUM_47)
#define GPIO_CAM_Y4 (GPIO_NUM_14)
#define GPIO_CAM_Y5 (GPIO_NUM_3)
#define GPIO_CAM_Y6 (GPIO_NUM_12)
#define GPIO_CAM_Y7 (GPIO_NUM_42)
#define GPIO_CAM_Y8 (GPIO_NUM_41)
#define GPIO_CAM_Y9 (GPIO_NUM_39)
/**
* @file esp32_c3_devkit.c
* @author your name (you@domain.com)
* @brief
* @version 0.1
* @date 2021-07-27
*
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "esp_err.h"
#include "bsp_board.h"
esp_err_t bsp_board_init(void)
{
return ESP_OK;
}
esp_err_t bsp_board_power_ctrl(power_module_t module, bool on)
{
(void) module;
(void) on;
return ESP_ERR_NOT_SUPPORTED;
}
/**
* @file esp32_s2_hmi_devkit.c
* @brief
* @version 0.1
* @date 2021-07-05
*
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdbool.h>
#include "bsp_board.h"
#include "bsp_i2c.h"
#include "esp_log.h"
#include "tca9554.h"
#if (!CONFIG_IDF_TARGET_ESP32S2)
/* Check for IDF target. This dev board uses ESP32-S2 */
#error "Please set idf target to `ESP32-S2`"
#endif
#define PWR_PA_BIT (1 << 3)
#define PWR_PA_ON_LEVEL (1)
#define PWR_ALL_BIT (1 << 4)
#define PWR_ALL_ON_LEVEL (0)
#define PWR_LCD_BL (1 << 7)
#define PWR_LCD_ON_LEVEL (1)
static const char *TAG = "board";
esp_err_t bsp_board_init(void)
{
/* Init I2C bus */
ESP_ERROR_CHECK(bsp_i2c_init(I2C_NUM_0, 400 * 1000));
/* Open all periphral power */
ESP_ERROR_CHECK(bsp_board_power_ctrl(POWER_MODULE_ALL, true));
ESP_ERROR_CHECK(bsp_board_power_ctrl(POWER_MODULE_LCD, true));
return ESP_OK;
}
esp_err_t bsp_board_power_ctrl(power_module_t module, bool on)
{
/* Config power control IO */
static esp_err_t bsp_io_config_state = ESP_FAIL;
if (ESP_OK != bsp_io_config_state) {
bsp_io_config_state = ESP_OK;
bsp_io_config_state |= tca9554_init();
bsp_io_config_state |= tca9554_set_configuration(0b00000101);
bsp_io_config_state |= tca9554_write_output_pins(0b11000111);
}
/* Checko IO config result */
if (ESP_OK != bsp_io_config_state) {
ESP_LOGE(TAG, "Failed initialize power control IO");
return bsp_io_config_state;
}
/* Get output level of IO expander */
uint8_t io_level;
esp_err_t ret_val = tca9554_read_output_pins(&io_level);
if (ESP_OK != ret_val) {
ESP_LOGE(TAG, "Fail read IO expander's output level");
return ret_val;
} else {
ESP_LOGD(TAG, "Output IO level read: %02X", io_level);
}
/* Control independent power domain */
switch (module) {
case POWER_MODULE_LCD:
if (on ^ PWR_LCD_ON_LEVEL) {
io_level &= ~PWR_LCD_BL;
} else {
io_level |= PWR_LCD_BL;
}
break;
case POWER_MODULE_AUDIO:
if (on ^ PWR_PA_ON_LEVEL) {
io_level &= ~PWR_PA_BIT;
} else {
io_level |= PWR_PA_BIT;
}
break;
case POWER_MODULE_ALL:
if (on ^ PWR_ALL_ON_LEVEL) {
io_level &= ~PWR_ALL_BIT;
} else {
io_level |= PWR_ALL_BIT;
}
break;
default:
return ESP_ERR_INVALID_ARG;
}
/* Write expected output level to IO expander */
ESP_LOGD(TAG, "Output IO level write : %02X", io_level);
ret_val = tca9554_write_output_pins(io_level);
return ret_val;
}
/**
* @file esp32_s2_kaluga.c
* @brief
* @version 0.1
* @date 2021-07-05
*
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "bsp_board.h"
#include "bsp_i2c.h"
#include "driver/gpio.h"
#include "esp_err.h"
#include "esp_log.h"
static const char *TAG = "board";
esp_err_t bsp_board_init(void)
{
bsp_board_power_ctrl(POWER_MODULE_ALL, true);
bsp_i2c_init(I2C_NUM_0, 400 * 1000);
return ESP_OK;
}
esp_err_t bsp_board_power_ctrl(power_module_t module, bool on)
{
/* Config power control IO */
static esp_err_t bsp_io_config_state = ESP_FAIL;
if (ESP_OK != bsp_io_config_state) {
gpio_config_t io_conf;
io_conf.intr_type = GPIO_INTR_DISABLE;
io_conf.mode = GPIO_MODE_OUTPUT;
io_conf.pin_bit_mask = 1ULL << GPIO_PWR_CTRL;
io_conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
io_conf.pull_up_en = GPIO_PULLUP_DISABLE;
bsp_io_config_state = gpio_config(&io_conf);
}
/* Checko IO config result */
if (ESP_OK != bsp_io_config_state) {
ESP_LOGE(TAG, "Failed initialize power control IO");
return bsp_io_config_state;
}
/* Control independent power domain */
switch (module) {
case POWER_MODULE_LCD:
// gpio_set_level(GPIO_LCD_BL, on ? (GPIO_LCD_BL_ON) : (!GPIO_LCD_BL_ON));
break;
case POWER_MODULE_AUDIO:
gpio_set_level(GPIO_PWR_CTRL, on ? (GPIO_PWR_ON_LEVEL) : (!GPIO_PWR_ON_LEVEL));
break;
case POWER_MODULE_ALL:
break;
default:
return ESP_ERR_INVALID_ARG;
}
return ESP_OK;
}
/**
* @file esp32_s3_cube.c
* @brief
* @version 0.1
* @date 2021-07-28
*
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "esp_err.h"
#include "esp_log.h"
#include "bsp_board.h"
#include "bsp_i2c.h"
#include "bsp_storage.h"
#include "mpu6050.h"
#include "nvs_flash.h"
static const char *TAG = "board";
static IRAM_ATTR void gpio_isr_handler(void *arg)
{
gpio_set_level(GPIO_NUM_45, !gpio_get_level(GPIO_NUM_17));
gpio_set_level(GPIO_PWR_CTRL, gpio_get_level(GPIO_NUM_1) ? (GPIO_PWR_ON_LEVEL) : (!GPIO_PWR_ON_LEVEL));
}
esp_err_t bsp_board_init(void)
{
/*!< Function test for dev board - Motor */
gpio_config_t io_conf_motor;
io_conf_motor.intr_type = GPIO_INTR_DISABLE;
io_conf_motor.mode = GPIO_MODE_OUTPUT;
io_conf_motor.pin_bit_mask = 1ULL << GPIO_NUM_45;
io_conf_motor.pull_down_en = GPIO_PULLDOWN_DISABLE;
io_conf_motor.pull_up_en = GPIO_PULLUP_DISABLE;
ESP_ERROR_CHECK(gpio_config(&io_conf_motor));
/*!< Function test for dev board - Mute_Button */
gpio_config_t io_conf_key;
io_conf_key.intr_type = GPIO_INTR_ANYEDGE;
io_conf_key.mode = GPIO_MODE_INPUT;
io_conf_key.pin_bit_mask = 1ULL << GPIO_NUM_17;
io_conf_key.pull_down_en = GPIO_PULLDOWN_DISABLE;
io_conf_key.pull_up_en = GPIO_PULLUP_ENABLE;
ESP_ERROR_CHECK(gpio_config(&io_conf_key));
/* Install GPIO ISR service to enable GPIO ISR callback */
gpio_install_isr_service(0);
ESP_ERROR_CHECK(gpio_isr_handler_add(GPIO_NUM_17, gpio_isr_handler, NULL));
/* The mute IC will not be reset. Make sure the io level of PA control is the same as mute state. */
gpio_set_level(GPIO_PWR_CTRL, gpio_get_level(GPIO_NUM_1) ? (GPIO_PWR_ON_LEVEL) : (!GPIO_PWR_ON_LEVEL));
return ESP_OK;
}
esp_err_t bsp_board_power_ctrl(power_module_t module, bool on)
{
/* Config power control IO */
static esp_err_t bsp_io_config_state = ESP_FAIL;
if (ESP_OK != bsp_io_config_state) {
gpio_config_t io_conf;
io_conf.intr_type = GPIO_INTR_DISABLE;
io_conf.mode = GPIO_MODE_OUTPUT;
io_conf.pin_bit_mask = 1ULL << GPIO_PWR_CTRL;
io_conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
io_conf.pull_up_en = GPIO_PULLUP_DISABLE;
bsp_io_config_state = gpio_config(&io_conf);
}
/* Checko IO config result */
if (ESP_OK != bsp_io_config_state) {
ESP_LOGE(TAG, "Failed initialize power control IO");
return bsp_io_config_state;
}
/* Control independent power domain */
switch (module) {
case POWER_MODULE_LCD:
gpio_set_level(GPIO_LCD_BL, on ? (GPIO_LCD_BL_ON) : (!GPIO_LCD_BL_ON));
break;
case POWER_MODULE_AUDIO:
gpio_set_level(GPIO_PWR_CTRL, on ? (GPIO_PWR_ON_LEVEL) : (!GPIO_PWR_ON_LEVEL));
break;
case POWER_MODULE_ALL:
break;
default:
return ESP_ERR_INVALID_ARG;
}
return ESP_OK;
}
/**
* @file esp32_s3_hmi_devkit.c
* @brief
* @version 0.1
* @date 2021-07-05
*
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdbool.h>
#include "bsp_board.h"
#include "bsp_i2c.h"
#include "bsp_storage.h"
#include "bsp_tp.h"
#include "driver/gpio.h"
#include "esp_log.h"
#if (!CONFIG_IDF_TARGET_ESP32S3)
/* Check for IDF target. This dev board uses ESP32-S3 */
#error "Please set idf target to `ESP32-S3`"
#endif
static const char *TAG = "board";
esp_err_t bsp_board_init(void)
{
/* Open all periphral power */
ESP_ERROR_CHECK(bsp_board_power_ctrl(POWER_MODULE_ALL, true));
/* Wait for power stable */
vTaskDelay(pdMS_TO_TICKS(10));
/* Init I2C bus */
ESP_ERROR_CHECK(bsp_i2c_init(I2C_NUM_0, 400 * 1000));
/* Init input device */
ESP_ERROR_CHECK(bsp_tp_init());
/* Init SDMMC card */
ESP_ERROR_CHECK(bsp_storage_init(BSP_STORAGE_SD_CARD));
return ESP_OK;
}
esp_err_t bsp_board_power_ctrl(power_module_t module, bool on)
{
/* Config power control IO */
static esp_err_t bsp_io_config_state = ESP_FAIL;
if (ESP_OK != bsp_io_config_state) {
gpio_config_t io_conf;
io_conf.intr_type = GPIO_INTR_DISABLE;
io_conf.mode = GPIO_MODE_OUTPUT;
io_conf.pin_bit_mask = 1ULL << GPIO_PWR_CTRL;
io_conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
io_conf.pull_up_en = GPIO_PULLUP_DISABLE;
bsp_io_config_state = gpio_config(&io_conf);
}
/* Checko IO config result */
if (ESP_OK != bsp_io_config_state) {
ESP_LOGE(TAG, "Failed initialize power control IO");
return bsp_io_config_state;
}
/* Control independent power domain */
switch (module) {
case POWER_MODULE_LCD:
case POWER_MODULE_AUDIO:
// gpio_set_level(GPIO_NUM_46, on ? (GPIO_PWR_ON_LEVEL) : (!GPIO_PWR_ON_LEVEL));
break;
case POWER_MODULE_ALL:
gpio_set_level(GPIO_PWR_CTRL, on ? (GPIO_PWR_ON_LEVEL) : (!GPIO_PWR_ON_LEVEL));
break;
default:
return ESP_ERR_INVALID_ARG;
}
return ESP_OK;
}
/**
* @file esp32_s3_hmi_devkit.c
* @brief
* @version 0.1
* @date 2021-07-05
*
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdbool.h>
#include "bsp_board.h"
#include "bsp_i2c.h"
#include "bsp_storage.h"
#include "bsp_tp.h"
#include "driver/gpio.h"
#include "esp_log.h"
esp_err_t bsp_board_init(void)
{
/* Init I2C bus */
ESP_ERROR_CHECK(bsp_i2c_init(I2C_NUM_0, 400 * 1000));
return ESP_OK;
}
/**
* @file esp32_wrover_kit.c
* @brief
* @version 0.1
* @date 2021-07-05
*
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "esp_err.h"
#include "bsp_board.h"
#include "bsp_i2c.h"
esp_err_t bsp_board_init(void)
{
ESP_ERROR_CHECK(bsp_i2c_init(I2C_NUM_0, 400 * 1000));
return ESP_OK;
}
esp_err_t bsp_board_power_ctrl(power_module_t module, bool on)
{
(void) module;
(void) on;
return ESP_ERR_NOT_SUPPORTED;
}
\ No newline at end of file
/**
* @file esp_custom_board.c
* @brief
* @version 0.1
* @date 2021-07-05
*
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "esp_err.h"
#include "bsp_board.h"
static const char *TAG = "board";
static bsp_board_t bsp_board = {
.init = board_init,
.pwr_ctrl = board_pwr_ctrl,
.enter_low_power = board_enter_low_power,
}
esp_err_t board_init(void *data)
{
(void) data;
/*!< Place your own initialize code hera */
ESP_LOGE(TAG, "Please replace with your own board initialize code.")
return ESP_ERR_NOT_SUPPORTED;
}
/**
* @file bsp_board.h
* @brief
* @version 0.1
* @date 2021-06-25
*
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <stdbool.h>
#include "esp_err.h"
/**
* @brief Add dev board pin defination and check target.
*
*/
#if CONFIG_ESP32_S3_HMI_DEVKIT_BOARD
#include "bsp_board_esp32s3_hmi_devkit_1.h"
#elif CONFIG_ESP32_S3_LCD_CAM_BOARD
#include "bsp_board_esp32s3_lcd_cam.h"
#elif CONFIG_ESP32_S2_HMI_DEVKIT_BOARD
#include "bsp_board_esp32s2_hmi_devkit_1.h"
#elif CONFIG_ESP32_S2_KALUGA_BOARD
#include "bsp_board_esp32s2_kaluga_1.h"
#elif CONFIG_ESP32_WROVER_KIT_BOARD
#include "bsp_board_esp32_wrover_kit.h"
#elif CONFIG_ESP32_C3_DEVKIT_BOARD
#include "bsp_board_esp32_c3_devkit.h"
#elif CONFIG_ESP32_S3_CUBE_BOARD
#include "bsp_board_esp32_s3_cube.h"
#else
//CONFIG_ESP_CUSTOM_BOARD
// #include ""
#endif
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Power module of dev board.
* This can be expanded in the future use.
*
*/
typedef enum {
POWER_MODULE_LCD = 1, /*!< LCD power control */
POWER_MODULE_AUDIO, /*!< Audio PA power control */
POWER_MODULE_ALL = 0xff, /*!< All module power control */
} power_module_t;
typedef struct {
esp_err_t (*init)(void *); /*!< Initialize function of dev board. Skip if NULL. */
esp_err_t (*pwr_ctrl)(power_module_t, bool); /*!< Power control of dev board. NULL if not support. */
esp_err_t (*enter_low_power)(void); /*!< Enter low power mode. NULL if not support. */
} bsp_board_t;
typedef bsp_board_t *bsp_board_handle_t; /*!< Handle to board control object */
/**
* @brief Borad initialize.
* It will call dev board's
*
* @return
* - ESP_OK Success
* - Others: Refer to error code `esp_err.h`.
*/
esp_err_t bsp_board_init(void);
/**
* @brief Control power of dev board.
*
* @param module Refer to `power_module_t`.
* @param on Turn on or off specified power module. On if true.
* @return
* - ESP_OK Success
* - Others: Refer to error code `esp_err.h`.
*/
esp_err_t bsp_board_power_ctrl(power_module_t module, bool on);
#ifdef __cplusplus
}
#endif
/**
* @file bsp_camera.h
* @brief
* @version 0.1
* @date 2021-07-07
*
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include "esp_err.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief
*
* @return esp_err_t
*/
esp_err_t bsp_camera_init(void);
#ifdef __cplusplus
}
#endif
/**
* @author your name (you@domain.com)
* @brief
* @version 0.1
* @date 2021-07-20
*
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include "audio_hal.h"
#include "esp_err.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief
*
* @param sample_rate
* @return esp_err_t
*/
esp_err_t bsp_codec_init(audio_hal_iface_samples_t sample_rate);
#ifdef __cplusplus
}
#endif
/**
* @file bsp_i2c.h
* @brief
* @version 0.1
* @date 2021-06-25
*
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include "driver/i2c.h"
#include "esp_err.h"
#include "i2c_bus.h"
#ifndef I2C_ACK_CHECK_EN
#define I2C_ACK_CHECK_EN 1
#endif
#ifndef I2C_ACK_CHECK_DIS
#define I2C_ACK_CHECK_DIS 0
#endif
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initialize I2C bus of dev board.
*
* @return
* - ESP_OK Success
* - Others: Refer to error code `esp_err.h`.
*/
// esp_err_t bsp_i2c_init(void);
/**
* @brief
*
* @param i2c_num
* @param clk_speed
* @return esp_err_t
*/
esp_err_t bsp_i2c_init(i2c_port_t i2c_num, uint32_t clk_speed);
/**
* @brief
*
* @return esp_err_t
*/
esp_err_t bsp_i2c_probe(void);
/**
* @brief
*
* @param addr
* @return esp_err_t
*/
esp_err_t bsp_i2c_probe_addr(uint8_t addr);
/**
* @brief Add device to I2C bus.
*
* @param i2c_device_handle
* @param dev_addr
* @return
* - ESP_OK Success
* - Others: Refer to error code `esp_err.h`.
*/
esp_err_t bsp_i2c_add_device(i2c_bus_device_handle_t *i2c_device_handle, uint8_t dev_addr);
/**
* @brief Get handle of I2C bus.
*
* @return Handle of i2c bus. NULL if not or failed initialized.
*/
i2c_bus_handle_t bsp_i2c_bus_get_handle(void);
#ifdef __cplusplus
}
#endif
/**
* @file bsp_i2s.h
* @brief
* @version 0.1
* @date 2021-08-02
*
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include "esp_err.h"
#include "driver/i2s.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief
*
* @param i2s_num
* @param sample_rate
* @return esp_err_t
*/
esp_err_t bsp_i2s_init(i2s_port_t i2s_num, uint32_t sample_rate);
/**
* @brief
*
* @param i2s_num
* @return esp_err_t
*/
esp_err_t bsp_i2s_deinit(i2s_port_t i2s_num);
#ifdef __cplusplus
}
#endif
/**
* @file bsp_lcd.h
* @brief
* @version 0.1
* @date 2021-07-05
*
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <stdbool.h>
#include "bsp_board.h"
#include "esp_err.h"
#include "esp_lcd_types.h"
#include "freertos/FreeRTOS.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef bool (*bsp_lcd_trans_cb_t)(esp_lcd_panel_io_handle_t, void *, void *);
/**
* @brief Initialize LCD
*
* @return esp_err_t
*/
esp_err_t bsp_lcd_init(void);
/**
* @brief
*
* @return esp_err_t
*/
esp_err_t bsp_lcd_deinit(void);
/**
* @brief
*
* @param x1
* @param y1
* @param x2
* @param y2
* @param p_data
* @param ticks_to_wait
* @return esp_err_t
*/
esp_err_t bsp_lcd_flush(int x1, int y1, int x2, int y2, const void *p_data, TickType_t ticks_to_wait);
/**
* @brief
*
* @param ticks_to_wait
* @return esp_err_t
*/
esp_err_t bsp_lcd_flush_wait_done(TickType_t ticks_to_wait);
/**
* @brief
*
* @param trans_done_cb
* @param data
* @return esp_err_t
*/
esp_err_t bsp_lcd_set_cb(bool (*trans_done_cb)(void *), void *data);
#if LCD_IFACE_SPI
/**
* @brief
*
* @param p_io_handle
* @param trans_done_cb
* @return esp_err_t
*/
esp_err_t bsp_spi_lcd_init(esp_lcd_panel_io_handle_t *p_io_handle, bsp_lcd_trans_cb_t trans_done_cb);
/**
* @brief
*
* @return esp_err_t
*/
esp_err_t bsp_spi_lcd_deinit(void);
#endif
#if LCD_IFACE_I80
/**
* @brief
*
* @param p_io_handle
* @param trans_done_cb
* @return esp_err_t
*/
esp_err_t bsp_i80_lcd_init(esp_lcd_panel_io_handle_t *p_io_handle, bsp_lcd_trans_cb_t trans_done_cb);
/**
* @brief
*
* @return esp_err_t
*/
esp_err_t bsp_i80_lcd_deinit(void);
#endif
#ifdef __cplusplus
}
#endif
/**
* @file bsp_storage.h
* @brief
* @version 0.1
* @date 2021-07-06
*
* @copyright Copyright (c) 2021
*
*/
#pragma once
#include "esp_err.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
BSP_STORAGE_NONE = 0,
BSP_STORAGE_SD_CARD,
BSP_STORAGE_SPIFFS,
BSP_STORAGE_SEMIHOST,
} bsp_storage_dev_t;
esp_err_t bsp_storage_init(bsp_storage_dev_t dev);
esp_err_t bsp_storage_deinit(bsp_storage_dev_t dev);
esp_err_t bsp_storage_get_mount_point(bsp_storage_dev_t dev, char **p_mont_point);
#ifdef __cplusplus
}
#endif
/**
* @file bsp_tp.h
* @brief
* @version 0.1
* @date 2021-07-05
*
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include "esp_err.h"
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief
*
* @return esp_err_t
*/
esp_err_t bsp_tp_init(void);
/**
* @brief
*
* @param tp_num
* @param x
* @param y
* @return esp_err_t
*/
esp_err_t bsp_tp_read(uint8_t *tp_num, uint16_t *x, uint16_t *y);
#ifdef __cplusplus
}
#endif
/**
* @file bsp_camera.c
* @brief
* @version 0.1
* @date 2021-07-07
*
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "bsp_board.h"
#include "esp_camera.h"
#include "esp_err.h"
#include "esp_log.h"
static const char *TAG = "camera";
static camera_config_t camera_config = {
.pin_pwdn = GPIO_CAM_PWDN,
.pin_reset = GPIO_CAM_RST,
.pin_xclk = GPIO_CAM_XCLK,
.pin_sscb_sda = GPIO_CAM_SDA,
.pin_sscb_scl = GPIO_CAM_SCL,
.pin_d7 = GPIO_CAM_Y9,
.pin_d6 = GPIO_CAM_Y8,
.pin_d5 = GPIO_CAM_Y7,
.pin_d4 = GPIO_CAM_Y6,
.pin_d3 = GPIO_CAM_Y5,
.pin_d2 = GPIO_CAM_Y4,
.pin_d1 = GPIO_CAM_Y3,
.pin_d0 = GPIO_CAM_Y2,
.pin_vsync = GPIO_CAM_VSYNC,
.pin_href = GPIO_CAM_HSYNC,
.pin_pclk = GPIO_CAM_PCLK,
//XCLK 20MHz or 10MHz for OV2640 double FPS (Experimental)
.xclk_freq_hz = 20000000,
.ledc_timer = LEDC_TIMER_0,
.ledc_channel = LEDC_CHANNEL_0,
.pixel_format = PIXFORMAT_RGB565, //YUV422,GRAYSCALE,RGB565,JPEG
.frame_size = FRAMESIZE_QVGA, //QQVGA-UXGA Do not use sizes above QVGA when not JPEG
.jpeg_quality = 12, //0-63 lower number means higher quality
.fb_count = 1 //if more than one, i2s runs in continuous mode. Use only with JPEG
};
esp_err_t bsp_camera_init(void)
{
esp_err_t ret_val = ESP_OK;
ret_val |= esp_camera_init(&camera_config);
ret_val |= esp_camera_sensor_get()->set_vflip(esp_camera_sensor_get(), true);
if (ESP_OK != ret_val) {
ESP_LOGE(TAG, "Failed initialize camera : 0x%02X", ret_val);
}
return ret_val;
}
/**
* @file bsp_codec.c
* @brief
* @version 0.1
* @date 2021-07-20
*
* @copyright Copyright (c) 2021
*
*/
#include "bsp_codec.h"
#include "bsp_i2c.h"
#include "es7210.h"
#include "es8311.h"
#include "esp_log.h"
static const char *TAG = "codec";
typedef enum {
CODEC_TYPE_ES7210 = 0,
CODEC_TYPE_ES8311,
CODEC_TYPE_ES8388,
CODEC_TYPE_MAX,
CODEC_TYPE_NONE = -1,
} codec_type_t;
typedef struct {
uint8_t dev_addr;
char *dev_name;
codec_type_t dev_type;
} codec_dev_t;
static codec_dev_t codec_dev_list[] = {
{ 0x40, "ES7210", CODEC_TYPE_ES7210 },
{ 0x18, "ES8311", CODEC_TYPE_ES8311 },
{ 0x20, "ES8388", CODEC_TYPE_ES8388 },
};
static esp_err_t bsp_codec_prob(int *codec_type)
{
for (size_t i = 0; i < sizeof(codec_dev_list) / sizeof(codec_dev_list[0]); i++) {
if (ESP_OK == bsp_i2c_probe_addr(codec_dev_list[i].dev_addr)) {
*codec_type |= 1 << i;
ESP_LOGI(TAG, "Detected codec at 0x%02X. Name : %s",
codec_dev_list[i].dev_addr, codec_dev_list[i].dev_name);
}
}
if (0 == *codec_type) {
*codec_type = CODEC_TYPE_NONE;
ESP_LOGW(TAG, "Codec not detected");
return ESP_ERR_NOT_FOUND;
}
return ESP_OK;
}
esp_err_t bsp_codec_adc_init(audio_hal_iface_samples_t sample_rate)
{
esp_err_t ret_val = ESP_OK;
audio_hal_codec_config_t cfg = {
.codec_mode = AUDIO_HAL_CODEC_MODE_ENCODE,
.adc_input = AUDIO_HAL_ADC_INPUT_ALL,
.i2s_iface = {
.bits = AUDIO_HAL_BIT_LENGTH_16BITS,
.fmt = AUDIO_HAL_I2S_DSP,
.mode = AUDIO_HAL_MODE_SLAVE,
.samples = sample_rate,
},
};
ret_val |= es7210_adc_init(&cfg);
ret_val |= es7210_adc_config_i2s(cfg.codec_mode, &cfg.i2s_iface);
ret_val |= es7210_adc_set_gain(GAIN_37_5DB);
ret_val |= es7210_adc_ctrl_state(cfg.codec_mode, AUDIO_HAL_CTRL_START);
if (ESP_OK != ret_val) {
ESP_LOGE(TAG, "Failed initialize codec");
}
return ret_val;
}
esp_err_t bsp_codec_dac_init(audio_hal_iface_samples_t sample_rate)
{
esp_err_t ret_val = ESP_OK;
audio_hal_codec_config_t cfg = {
.codec_mode = AUDIO_HAL_CODEC_MODE_DECODE,
.dac_output = AUDIO_HAL_DAC_OUTPUT_LINE1,
.i2s_iface = {
.bits = AUDIO_HAL_BIT_LENGTH_16BITS,
.fmt = AUDIO_HAL_I2S_DSP,
.mode = AUDIO_HAL_MODE_SLAVE,
.samples = sample_rate,
},
};
ret_val |= es8311_codec_init(&cfg);
ret_val |= es8311_set_bits_per_sample(cfg.i2s_iface.bits);
ret_val |= es8311_config_fmt(cfg.i2s_iface.fmt);
ret_val |= es8311_codec_set_voice_volume(60);
ret_val |= es8311_codec_ctrl_state(cfg.codec_mode, AUDIO_HAL_CTRL_START);
if (ESP_OK != ret_val) {
ESP_LOGE(TAG, "Failed initialize codec");
}
return ret_val;
}
static esp_err_t bsp_codec_init_adc_dac(audio_hal_iface_samples_t sample_rate)
{
esp_err_t ret_val = ESP_OK;
audio_hal_codec_config_t cfg = {
.codec_mode = AUDIO_HAL_CODEC_MODE_BOTH,
.dac_output = AUDIO_HAL_DAC_OUTPUT_ALL,
.adc_input = AUDIO_HAL_ADC_INPUT_ALL,
.i2s_iface = {
.bits = AUDIO_HAL_BIT_LENGTH_16BITS,
.fmt = AUDIO_HAL_I2S_NORMAL,
.mode = AUDIO_HAL_MODE_SLAVE,
.samples = sample_rate,
},
};
ret_val |= es8311_codec_init(&cfg);
ret_val |= es8311_set_bits_per_sample(cfg.i2s_iface.bits);
ret_val |= es8311_config_fmt(cfg.i2s_iface.fmt);
ret_val |= es8311_codec_set_voice_volume(60);
ret_val |= es8311_set_mic_gain(ES8311_MIC_GAIN_30DB);
ret_val |= es8311_codec_ctrl_state(cfg.codec_mode, AUDIO_HAL_CTRL_START);
if (ESP_OK != ret_val) {
ESP_LOGE(TAG, "Failed initialize codec");
}
return ret_val;
}
esp_err_t bsp_codec_init(audio_hal_iface_samples_t sample_rate)
{
esp_err_t ret_val = ESP_OK;
static int codec_type = 0;
ret_val |= bsp_codec_prob(&codec_type);
if(CODEC_TYPE_NONE == codec_type) {
return ESP_ERR_NOT_FOUND;
}
/* Single Codec ES8311 only, Used for audio input and output */
if (1 << CODEC_TYPE_ES8311 == codec_type) {
ret_val |= bsp_codec_init_adc_dac(sample_rate);
return ret_val;
}
if (((1 << CODEC_TYPE_ES8311) + (1 << CODEC_TYPE_ES7210)) == codec_type) {
ret_val |= bsp_codec_adc_init(sample_rate);
ret_val |= bsp_codec_dac_init(sample_rate);
return ret_val;
}
ESP_LOGW(TAG, "Currently not support");
return ESP_ERR_NOT_SUPPORTED;
}
/**
* @file bsp_i2c.c
* @brief
* @version 0.1
* @date 2021-06-25
*
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "esp_log.h"
#include "bsp_i2c.h"
#include "bsp_board.h"
#include "driver/i2c.h"
#define ACK_CHECK_EN 0x1 /*!< I2C master will check ack from slave*/
static const char *TAG= "bsp_i2c";
static i2c_bus_handle_t i2c_bus_handle = NULL;
/* Make sure unused member(s) zero. Especially `clk_flags` */
static i2c_config_t conf = {
.mode = I2C_MODE_MASTER,
.scl_io_num = GPIO_I2C_SCL,
.sda_io_num = GPIO_I2C_SDA,
.scl_pullup_en = GPIO_PULLUP_ENABLE,
.sda_pullup_en = GPIO_PULLUP_ENABLE,
};
esp_err_t bsp_i2c_init(i2c_port_t i2c_num, uint32_t clk_speed)
{
/* Check if bus is already created */
if (NULL != i2c_bus_handle) {
ESP_LOGE(TAG, "I2C bus already initialized.");
return ESP_FAIL;
}
conf.master.clk_speed = clk_speed;
i2c_bus_handle = i2c_bus_create(i2c_num, &conf);
if (NULL == i2c_bus_handle) {
ESP_LOGE(TAG, "Failed create I2C bus");
return ESP_FAIL;
}
return ESP_OK;
}
esp_err_t bsp_i2c_add_device(i2c_bus_device_handle_t *i2c_device_handle, uint8_t dev_addr)
{
if (NULL == i2c_bus_handle) {
ESP_LOGE(TAG, "Failed create I2C device");
return ESP_FAIL;
}
*i2c_device_handle = i2c_bus_device_create(i2c_bus_handle, dev_addr, 400000);
if (NULL == i2c_device_handle) {
ESP_LOGE(TAG, "Failed create I2C device");
return ESP_FAIL;
}
return ESP_OK;
}
esp_err_t bsp_i2c_probe(void)
{
if (NULL == bsp_i2c_bus_get_handle()) {
ESP_LOGE(TAG, "I2C bus not initialized");
return ESP_ERR_INVALID_STATE;
}
i2c_bus_t *i2c_bus = (i2c_bus_t *) bsp_i2c_bus_get_handle();
for (size_t i = 1; i < 0x80; i++) {
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, ( i << 1 ), ACK_CHECK_EN);
i2c_master_stop(cmd);
esp_err_t ret_val = i2c_master_cmd_begin(i2c_bus->i2c_port, cmd, pdMS_TO_TICKS(500));
i2c_cmd_link_delete(cmd);
if(ESP_OK == ret_val) {
ESP_LOGW(TAG, "Found I2C Device at 0x%02X", i);
}
}
return ESP_OK;
}
esp_err_t bsp_i2c_probe_addr(uint8_t addr)
{
/* Use 7 bit address here */
if (addr >= 0x80) {
return ESP_ERR_INVALID_ARG;
}
/* Check if I2C bus initialized */
if (NULL == bsp_i2c_bus_get_handle()) {
ESP_LOGE(TAG, "I2C bus not initialized");
return ESP_ERR_INVALID_STATE;
}
/* Get I2C bus object from i2c_bus_handle */
i2c_bus_t *i2c_bus = (i2c_bus_t *) bsp_i2c_bus_get_handle();
/* Create probe cmd link */
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, ( addr << 1 ), ACK_CHECK_EN);
i2c_master_stop(cmd);
/* Start probe cmd link */
esp_err_t ret_val = i2c_master_cmd_begin(i2c_bus->i2c_port, cmd, pdMS_TO_TICKS(500));
/* Delete cmd link after probe ends */
i2c_cmd_link_delete(cmd);
/* Get probe result if ESP_OK equals to ret_val */
return ret_val;
}
i2c_bus_handle_t bsp_i2c_bus_get_handle(void)
{
return i2c_bus_handle;
}
/**
* @file bsp_i2s.c
* @brief
* @version 0.1
* @date 2021-07-23
*
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "bsp_board.h"
#include "bsp_i2s.h"
#include "driver/gpio.h"
#include "driver/i2s.h"
#include "esp_err.h"
#include "esp_log.h"
#include "freertos/FreeRTOS.h"
// static const char *TAG = "bsp_i2s";
#if SOC_I2S_SUPPORTS_TDM
/**
* @brief Will usb TDM mode to drive more than one codec on I2S bus.
*
*/
#define I2S_CONFIG_DEFAULT() { \
.mode = I2S_MODE_MASTER | I2S_MODE_TX | I2S_MODE_RX, \
.sample_rate = sample_rate, \
.bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT, \
.channel_format = I2S_CHANNEL_FMT_MULTIPLE, \
.communication_format = I2S_COMM_FORMAT_STAND_PCM_SHORT, \
.dma_buf_count = 8, \
.dma_buf_len = 256, \
.use_apll = true, \
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1 | ESP_INTR_FLAG_IRAM, \
.fixed_mclk = 0, \
.chan_mask = I2S_TDM_ACTIVE_CH0 | I2S_TDM_ACTIVE_CH1, \
}
#else
#define I2S_CONFIG_DEFAULT() { \
.mode = I2S_MODE_MASTER | I2S_MODE_TX | I2S_MODE_RX, \
.sample_rate = sample_rate, \
.bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT, \
.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT, \
.communication_format = I2S_COMM_FORMAT_STAND_I2S, \
.dma_buf_count = 8, \
.dma_buf_len = 256, \
.use_apll = true, \
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1 | ESP_INTR_FLAG_IRAM, \
.mclk_multiple = I2S_MCLK_MULTIPLE_DEFAULT, \
}
#endif
esp_err_t bsp_i2s_init(i2s_port_t i2s_num, uint32_t sample_rate)
{
esp_err_t ret_val = ESP_OK;
i2s_config_t i2s_config = I2S_CONFIG_DEFAULT();
i2s_pin_config_t pin_config = {
.bck_io_num = GPIO_I2S_SCLK,
.ws_io_num = GPIO_I2S_LRCK,
.data_out_num = GPIO_I2S_DOUT,
.data_in_num = GPIO_I2S_SDIN,
.mck_io_num = GPIO_I2S_MCLK,
};
ret_val |= i2s_driver_install(i2s_num, &i2s_config, 0, NULL);
ret_val |= i2s_set_pin(i2s_num, &pin_config);
return ret_val;
}
esp_err_t bsp_i2s_deinit(i2s_port_t i2s_num)
{
return i2s_driver_uninstall(i2s_num);
}
/**
* @file bsp_storage.c
* @brief
* @version 0.1
* @date 2021-06-25
*
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "bsp_board.h"
#include "bsp_storage.h"
#include "esp_err.h"
#include "esp_spiffs.h"
#include "esp_vfs_fat.h"
#include "esp_vfs_semihost.h"
#include "sdmmc_cmd.h"
/* Add SDMMC driver header if SoC supports SDMMC */
#if SOC_SDMMC_HOST_SUPPORTED
#include "driver/sdmmc_host.h"
#endif /* SOC_SDMMC_HOST_SUPPORTED */
static const char *TAG = "bsp_sdcard";
const char sd_mount_point[] = "/sdcard";
const char spiffs_mount_point[] = "/spiffs";
const char host_mount_point[] = "/host";
/* SD/MMC card information structure */
static sdmmc_card_t *card;
static esp_err_t bsp_sdcard_init(void)
{
esp_err_t ret_val = ESP_OK;
/* Check if SDMMC is supported on board. */
if (!FUNC_SDMMC_EN && !FUNC_SDSPI_EN) {
ESP_LOGE(TAG, "SDMMC and SDSPI not supported on this board!");
return ESP_ERR_NOT_SUPPORTED;
}
/**
* @brief Options for mounting the filesystem.
* If format_if_mount_failed is set to true, SD card will be partitioned and
* formatted in case when mounting fails.
*
*/
esp_vfs_fat_sdmmc_mount_config_t mount_config = {
.format_if_mount_failed = false,
.max_files = 2,
.allocation_unit_size = 16 * 1024
};
/**
* @brief Use settings defined above to initialize SD card and mount FAT filesystem.
* Note: esp_vfs_fat_sdmmc/sdspi_mount is all-in-one convenience functions.
* Please check its source code and implement error recovery when developing
* production applications.
*
*/
sdmmc_host_t host =
#if FUNC_SDMMC_EN
SDMMC_HOST_DEFAULT();
#else
SDSPI_HOST_DEFAULT();
spi_bus_config_t bus_cfg = {
.mosi_io_num = GPIO_SDSPI_MOSI,
.miso_io_num = GPIO_SDSPI_MISO,
.sclk_io_num = GPIO_SDSPI_SCLK,
.quadwp_io_num = GPIO_NUM_NC,
.quadhd_io_num = GPIO_NUM_NC,
.max_transfer_sz = 4000,
};
ret_val = spi_bus_initialize(host.slot, &bus_cfg, SPI_DMA_CH_AUTO);
if (ret_val != ESP_OK) {
ESP_LOGE(TAG, "Failed to initialize bus.");
return ret_val;
}
#endif
/**
* @brief This initializes the slot without card detect (CD) and write protect (WP) signals.
* Modify slot_config.gpio_cd and slot_config.gpio_wp if your board has these signals.
*
*/
#if FUNC_SDMMC_EN
sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT();
#else
sdspi_device_config_t slot_config = SDSPI_DEVICE_CONFIG_DEFAULT();
#endif
#if FUNC_SDMMC_EN
/* Config SD data width. 0, 4 or 8. Currently for SD card, 8 bit is not supported. */
slot_config.width = SDMMC_BUS_WIDTH;
/**
* @brief On chips where the GPIOs used for SD card can be configured, set them in
* the slot_config structure.
*
*/
#if SOC_SDMMC_USE_GPIO_MATRIX
slot_config.clk = GPIO_SDMMC_CLK;
slot_config.cmd = GPIO_SDMMC_CMD;
slot_config.d0 = GPIO_SDMMC_D0;
slot_config.d1 = GPIO_SDMMC_D1;
slot_config.d2 = GPIO_SDMMC_D2;
slot_config.d3 = GPIO_SDMMC_D3;
#endif
slot_config.cd = GPIO_SDMMC_DET;
slot_config.flags |= SDMMC_SLOT_FLAG_INTERNAL_PULLUP;
#else
slot_config.gpio_cs = GPIO_SDSPI_CS;
slot_config.host_id = host.slot;
#endif
/**
* @brief Enable internal pullups on enabled pins. The internal pullups
* are insufficient however, please make sure 10k external pullups are
* connected on the bus. This is for debug / example purpose only.
*/
/* get FAT filesystem on SD card registered in VFS. */
ret_val =
#if FUNC_SDMMC_EN
esp_vfs_fat_sdmmc_mount(sd_mount_point, &host, &slot_config, &mount_config, &card);
#else
esp_vfs_fat_sdspi_mount(sd_mount_point, &host, &slot_config, &mount_config, &card);
#endif
/* Check for SDMMC mount result. */
if (ret_val != ESP_OK) {
if (ret_val == ESP_FAIL) {
ESP_LOGE(TAG, "Failed to mount filesystem. "
"If you want the card to be formatted, set the EXAMPLE_FORMAT_IF_MOUNT_FAILED menuconfig option.");
} else {
ESP_LOGE(TAG, "Failed to initialize the card (%s). "
"Make sure SD card lines have pull-up resistors in place.", esp_err_to_name(ret_val));
}
return ret_val;
}
/* Card has been initialized, print its properties. */
sdmmc_card_print_info(stdout, card);
return ret_val;
}
static esp_err_t bsp_sdcard_deinit(void)
{
/* Unmount an SD card from the FAT filesystem and release resources acquired */
esp_err_t ret_val = esp_vfs_fat_sdcard_unmount(sd_mount_point, card);
/* Make SD/MMC card information structure pointer NULL */
card = NULL;
return ret_val;
}
static esp_err_t bsp_spiffs_init(void)
{
esp_vfs_spiffs_conf_t conf = {
.base_path = spiffs_mount_point,
.partition_label = NULL,
.max_files = 2,
.format_if_mount_failed = false,
};
esp_err_t ret_val = esp_vfs_spiffs_register(&conf);
if (ESP_OK != ret_val) {
if (ESP_FAIL == ret_val) {
ESP_LOGE(TAG, "Failed to mount or format filesystem");
} else if (ESP_ERR_NOT_FOUND == ret_val) {
ESP_LOGE(TAG, "Failed to find SPIFFS partition");
} else {
ESP_LOGE(TAG, "Failed to initialize SPIFFS (%s)", esp_err_to_name(ret_val));
}
}
return ret_val;
}
esp_err_t bsp_storage_init(bsp_storage_dev_t dev)
{
switch (dev) {
case BSP_STORAGE_SD_CARD:
return bsp_sdcard_init();
break;
case BSP_STORAGE_SPIFFS:
return bsp_spiffs_init();
break;
case BSP_STORAGE_SEMIHOST:
return esp_vfs_semihost_register(host_mount_point, NULL);
break;
default:
break;
}
return ESP_ERR_NOT_SUPPORTED;
}
esp_err_t bsp_storage_deinit(bsp_storage_dev_t dev)
{
switch (dev) {
case BSP_STORAGE_SD_CARD:
return bsp_sdcard_deinit();
break;
case BSP_STORAGE_SPIFFS:
return esp_vfs_spiffs_unregister(NULL);
break;
case BSP_STORAGE_SEMIHOST:
return esp_vfs_semihost_unregister(host_mount_point);
break;
default:
break;
}
return ESP_ERR_NOT_SUPPORTED;
}
esp_err_t bsp_storage_get_mount_point(bsp_storage_dev_t dev, char **p_mont_point)
{
switch (dev) {
case BSP_STORAGE_SD_CARD:
if (NULL == card) {
ESP_LOGE(TAG, "Card not initialized!");
return ESP_ERR_INVALID_STATE;
}
*p_mont_point = (char *) sd_mount_point;
break;
case BSP_STORAGE_SPIFFS:
*p_mont_point = (char *) spiffs_mount_point;
break;
case BSP_STORAGE_SEMIHOST:
*p_mont_point = (char *) host_mount_point;
break;
default:
break;
}
return ESP_OK;
}
/**
* @file bsp_tp.c
* @brief
* @version 0.1
* @date 2021-07-05
*
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "bsp_i2c.h"
#include "bsp_board.h"
#include "bsp_tp.h"
#include "esp_log.h"
#include "esp_err.h"
#include "i2c_bus.h"
#include "ft5x06.h"
#include "goodix.h"
static const char *TAG = "bsp_tp";
typedef enum {
TP_VENDOR_NONE = -1,
TP_VENDOR_FT = 0,
TP_VENDOR_GT,
TP_VENDOR_MAX,
} tp_vendor_t;
typedef struct {
char *dev_name;
uint8_t dev_addr;
tp_vendor_t dev_vendor;
} tp_dev_t;
static tp_dev_t tp_dev_list[] = {
{ "FocalTech", 0x38, TP_VENDOR_FT, },
{ "Goodix", 0x14, TP_VENDOR_GT },
};
static tp_vendor_t tp_vendor = TP_VENDOR_NONE;
static esp_err_t bsp_tp_prob(tp_vendor_t *p_tp_vendor)
{
for (size_t i = 0; i < sizeof(tp_dev_list) / sizeof(tp_dev_list[0]); i++) {
if (ESP_OK == bsp_i2c_probe_addr(tp_dev_list[i].dev_addr)) {
*p_tp_vendor = (tp_vendor_t) i;
ESP_LOGI(TAG, "Detected touch panel at 0x%02X. Vendor : %s",
tp_dev_list[i].dev_addr, tp_dev_list[i].dev_name);
return ESP_OK;
}
}
*p_tp_vendor = TP_VENDOR_NONE;
ESP_LOGW(TAG, "Touch panel not detected");
return ESP_ERR_NOT_FOUND;
}
esp_err_t bsp_tp_init(void)
{
esp_err_t ret_val = ESP_OK;
ret_val |= bsp_tp_prob(&tp_vendor);
switch (tp_vendor) {
case TP_VENDOR_FT:
ret_val |= ft5x06_init();
break;
case TP_VENDOR_GT:
ret_val |= goodix_tp_init();
break;
default:
ret_val = ESP_OK; // ESP_ERR_NOT_FOUND;
break;
}
return ret_val;
}
esp_err_t bsp_tp_read(uint8_t *tp_num, uint16_t *x, uint16_t *y)
{
esp_err_t ret_val = ESP_OK;
switch (tp_vendor) {
case TP_VENDOR_FT:
ret_val |= ft5x06_read_pos(tp_num, x, y);
break;
case TP_VENDOR_GT:
ret_val |= goodix_tp_read(tp_num, x, y);
break;
default:
return ESP_OK; // ESP_ERR_NOT_FOUND;
break;
}
#if TOUCH_PANEL_SWAP_XY
uint16_t swap = *x;
*x = *y;
*y = swap;
#endif
#if TOUCH_PANEL_INVERSE_X
*x = LCD_WIDTH - ( *x + 1);
#endif
#if TOUCH_PANEL_INVERSE_Y
*y = LCD_HEIGHT - (*y + 1);
#endif
return ret_val;
}
/**
* @file bsp_indev.c
* @brief
* @version 0.1
* @date 2021-08-24
*
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "bsp_board.h"
#include "esp_err.h"
typedef enum {
INDEV_MOUSE,
INDEV_TOUCH,
INDEV_KEYBOARD,
} indev_type_t;
typedef void *bsp_indev_handle_t;
typedef uint32_t bsp_indev_data_t;
esp_err_t bsp_indev_init(void)
{
return ESP_OK;
}
esp_err_t bsp_indev_send_data(bsp_indev_handle_t handle, bsp_indev_data_t *data)
{
return ESP_OK;
}
esp_err_t bsp_indev_recv_data(bsp_indev_handle_t handle, bsp_indev_data_t *data)
{
//
}
/**
* @file indev_mouse.c
* @brief
* @version 0.1
* @date 2021-08-25
*
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <string.h>
#include "esp_err.h"
#include "esp_log.h"
static const char *TAG = "indev_mouse";
static indev_mouse_satatus_data_t indev_mouse_satatus_data;
static indev_mouse_config_t indev_mouse_config = { .x_range = 65535, .y_range = 65535, };
esp_err_t indev_mouse_init(void)
{
return ESP_OK;
}
esp_err_t indev_mouse_set_range(uint16_t x_range, uint16_t y_range)
{
indev_mouse_config.x_range = x_range ? x_range : (uint16_t) 0xffff;
indev_mouse_config.y_range = y_range ? y_range : (uint16_t) 0xffff;
return ESP_OK;
}
esp_err_t indev_mouse_get_range(uint16_t *x_range, uint16_t *y_range)
{
if (NULL == x_range || NULL == y_range) {
return ESP_ERR_INVALID_ARG;
}
*x_range = indev_mouse_config.x_range;
*y_range = indev_mouse_config.y_range;
return ESP_OK;
}
esp_err_t indev_mouse_report_data(indev_mouse_report_data_t *data)
{
if (NULL == data) {
return ESP_ERR_INVALID_ARG;
}
/* Expand data range to `int32_t` */
int32_t x = indev_mouse_satatus_data.x;
int32_t y = indev_mouse_satatus_data.y;
int32_t z = indev_mouse_satatus_data.z;
/* Add delta value to status data */
x += data->dx;
y += data->dy;
z += data->dz;
/* Check for coordinate range */
x = x < 0 ? 0 : x;
x = x > indev_mouse_config.x_range ? indev_mouse_config.x_range : x;
y = y < 0 ? 0 : y;
y = y > indev_mouse_config.y_range ? indev_mouse_config.y_range : y;
/* Store value to `indev_mouse_satatus_data` */
indev_mouse_satatus_data.x = x;
indev_mouse_satatus_data.y = y;
indev_mouse_satatus_data.z = z;
return ESP_OK;
}
esp_err_t indev_mouse_get_status_data(indev_mouse_satatus_data_t *data)
{
if (NULL == data) {
return ESP_ERR_INVALID_ARG;
}
memcpy(data, &indev_mouse_satatus_data, sizeof(indev_mouse_satatus_data));
return ESP_OK;
}
/**
* @file indev_mouse.h
* @author your name (you@domain.com)
* @brief
* @version 0.1
* @date 2021-08-25
*
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include "esp_err.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef strcuct {
uint16_t x_range;
uint16_t y_range;
} indev_mouse_config_t;
typedef struct {
int16_t dx;
int16_t dy;
int16_t dz;
int16_t key;
} indev_mouse_report_data_t;
typedef struct {
uint16_t x;
uint16_t y;
int16_t z;
int16_t key;
} indev_mouse_satatus_data_t;
/**
* @brief
*
* @return esp_err_t
*/
esp_err_t indev_mouse_init(void);
/**
* @brief
*
* @param x_range
* @param y_range
* @return esp_err_t
*/
esp_err_t indev_mouse_set_range(uint16_t x_range, uint16_t y_range);
/**
* @brief
*
* @param x_range
* @param y_range
* @return esp_err_t
*/
esp_err_t indev_mouse_get_range(uint16_t *x_range, uint16_t *y_range);
/**
* @brief
*
* @param data
* @return esp_err_t
*/
esp_err_t indev_mouse_report_data(indev_mouse_report_data_t *data);
/**
* @brief
*
* @param data
* @return esp_err_t
*/
esp_err_t indev_mouse_get_status_data(indev_mouse_satatus_data_t *data);
#ifdef __cplusplus
}
#endif
/**
* @file indev_tp.c
* @brief
* @version 0.1
* @date 2021-08-25
*
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdbool.h>
#include "esp_err.h"
#include "esp_log.h"
#include "bsp_i2c.h"
typedef struct {
tp_type_t dev_id;
uint8_t dev_addr;
char * dev_name;
} tp_prob_t;
typedef enum {
TP_TYPE_FT = 0,
TP_TYPE_GT,
TP_TYPE_MAX,
} tp_type_t;
typedef struct {
uint16_t x;
uint16_t y;
bool pressed;
tp_gesture_t gesture;
} indev_tp_data_t;
static const tp_prob_t indev_tp_list[] = {
{ TP_TYPE_FT, 0x38, "FT" }, /*!< FocalTech */
{ TP_TYPE_GT, 0x14, "GT" }, /*!< Goodix */
{ TP_TYPE_MAX, 0xff, "MAX" }, /*!< Used for warning prevent */
};
typedef strcut {
esp_err_t (*init)(void); /*!< Touch panel initialize */
esp_err_t (*read)(uint16_t *, uint16_t *, bool *); /*!< Read touch point(s) of touch panel */
esp_err_t (*read_gesture)(uint8_t *); /*!< Read gesture of touch panel */
} indev_tp_t;
static indev_tp_t indev_tp = NULL;
static const char *TAG = __FILE__;
static esp_err_t indev_tp_prob(void)
{
size_t i = 0;
for (; i < TP_TYPE_MAX; i++) {
if (ESP_OK == bsp_i2c_probe_addr(indev_tp_list[i].dev_addr)) {
ESP_LOGI(TAG, "Touch panel detected : %s", indev_tp_list[i].dev_name);
break;
}
}
if (TP_TYPE_MAX == i) {
return ESP_ERR_NOT_FOUND;
}
/* Set indev_handle */
return ESP_OK;
}
esp_err_t indev_tp_init(void)
{
esp_err_t ret_val = indev_tp_prob();
if (ESP_OK != ret_val) {
ESP_LOGE(TAG, "Touch panel not found");
return ret_val;
}
indev_tp.init();
return ESP_OK;
}
typedef enum {
TP_GESTURE_NONE = 0,
TP_GESTURE_UP,
TP_GESTURE_DOWN,
TP_GESTURE_LEFT,
TP_GESTURE_RIGHT,
TP_GESTURE_ZOOM_IN,
TP_GESTURE_ZOOM_OUT,
} tp_gesture_t;
esp_err_t indev_tp_read(indev_tp_data_t *data)
{
uint16_t x, y;
bool p;
esp_err_t ret_val = indev_tp.read(&x, &y, &p);
if (ESP_OK != ret_val) {
data->x = 0;
data->y = 0;
data->pressed = false;
data->gesture = TP_GESTURE_NONE;
return ret_val;
}
data->x = x;
data->y = y;
data->pressed = p;
/* Currently not ported */
data->gesture = TP_GESTURE_NONE;
return ESP_OK;
}
esp_err_t indev_tp_config_swap_reverse(bool swap, bool x_reverse, bool y_reverse)
{
return ESP_OK;
}
esp_err_t indev_tp_read(indev_tp_data_t *data)
{
return ESP_OK;
}
/**
* @file bsp_lcd.c
* @brief
* @version 0.1
* @date 2021-06-25
*
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "bsp_lcd.h"
#include "bsp_board.h"
#include "driver/gpio.h"
#include "driver/spi_master.h"
#include "esp_compiler.h"
#include "esp_log.h"
#include "esp_lcd_panel_io.h"
#include "esp_lcd_panel_vendor.h"
#include "esp_lcd_panel_ops.h"
#include "freertos/FreeRTOS.h"
#include "freertos/semphr.h"
#include "freertos/task.h"
#include "soc/soc_memory_layout.h"
static const char *TAG = "bsp_lcd";
static esp_lcd_panel_io_handle_t io_handle = NULL;
static esp_lcd_panel_handle_t panel_handle = NULL;
static void *p_user_data = NULL;
static bool (*p_on_trans_done_cb)(void *) = NULL;
static SemaphoreHandle_t bsp_lcd_flush_done_sem = NULL;
static bool lcd_trans_done_cb(esp_lcd_panel_io_handle_t, void *, void *);
esp_err_t bsp_lcd_init(void)
{
#if LCD_IFACE_I80
bsp_i80_lcd_init(&io_handle, lcd_trans_done_cb);
#elif LCD_IFACE_SPI
bsp_spi_lcd_init(&io_handle, lcd_trans_done_cb);
#else
#error "Please specify LCD interface type"
#endif
esp_lcd_panel_dev_config_t panel_config = {
.reset_gpio_num = GPIO_LCD_RST,
.color_space = ESP_LCD_COLOR_SPACE_RGB,
.bits_per_pixel = 16,
};
#if LCD_DISP_IC_NT
ESP_ERROR_CHECK(esp_lcd_new_panel_nt35510(io_handle, &panel_config, &panel_handle));
#elif LCD_DISP_IC_ST
ESP_ERROR_CHECK(esp_lcd_new_panel_st7789(io_handle, &panel_config, &panel_handle));
#else
#error "Invalid LCD type"
#endif
/**
* @brief Configure LCD rotation and mirror
*
*/
esp_err_t ret_val = ESP_OK;
ret_val |= esp_lcd_panel_reset(panel_handle);
ret_val |= esp_lcd_panel_init(panel_handle);
ret_val |= esp_lcd_panel_invert_color(panel_handle, LCD_COLOR_INV);
ret_val |= esp_lcd_panel_set_gap(panel_handle, 0, 0);
ret_val |= esp_lcd_panel_swap_xy(panel_handle, LCD_SWAP_XY);
ret_val |= esp_lcd_panel_mirror(panel_handle, LCD_MIRROR_X, LCD_MIRROR_Y);
/**
* @brief Configure LCD backlight IO.
*
*/
if (GPIO_NUM_NC != GPIO_LCD_BL) {
gpio_config_t bk_gpio_config = {
.mode = GPIO_MODE_OUTPUT,
/*!< Prevent left shift negtive value warning */
.pin_bit_mask = GPIO_LCD_BL > 0 ? 1ULL << GPIO_LCD_BL : 0ULL,
};
gpio_config(&bk_gpio_config);
gpio_set_level(GPIO_LCD_BL, GPIO_LCD_BL_ON);
}
/**
* @brief Create mutex to receive LCD flush event.
*
*/
if (NULL != bsp_lcd_flush_done_sem) {
ESP_LOGE(TAG, "LCD already initialized");
return ESP_ERR_INVALID_STATE;
}
bsp_lcd_flush_done_sem = xSemaphoreCreateBinary();
if (NULL == bsp_lcd_flush_done_sem) {
return ESP_ERR_NO_MEM;
}
/* If any function is checking LCD trans status before transmition */
xSemaphoreGive(bsp_lcd_flush_done_sem);
return ESP_OK;
}
esp_err_t bsp_lcd_deinit(void)
{
esp_err_t ret_val = ESP_OK;
ret_val |= esp_lcd_panel_del(panel_handle);
ret_val |= esp_lcd_panel_io_del(io_handle);
#if LCD_IFACE_I80
ret_val |= bsp_i80_lcd_deinit();
#elif LCD_IFACE_SPI
ret_val |= bsp_spi_lcd_deinit();
#else
#error "Please specify LCD interface type"
#endif
return ret_val;
}
esp_err_t bsp_lcd_flush(int x1, int y1, int x2, int y2, const void *p_data, TickType_t ticks_to_wait)
{
/* Wait for previous tansmition done */
if (pdPASS != xSemaphoreTake(bsp_lcd_flush_done_sem, ticks_to_wait)) {
return ESP_ERR_TIMEOUT;
}
return esp_lcd_panel_draw_bitmap(panel_handle, x1, y1, x2, y2, p_data);
}
esp_err_t bsp_lcd_flush_wait_done(TickType_t ticks_to_wait)
{
if (pdPASS != xSemaphoreTake(bsp_lcd_flush_done_sem, ticks_to_wait)) {
return ESP_ERR_TIMEOUT;
}
xSemaphoreGive(bsp_lcd_flush_done_sem);
return ESP_OK;
}
esp_err_t bsp_lcd_set_cb(bool (*trans_done_cb)(void *), void *data)
{
if (esp_ptr_executable(trans_done_cb)) {
p_on_trans_done_cb = trans_done_cb;
p_user_data = data;
} else {
ESP_LOGE(TAG, "Invalid function pointer");
return ESP_ERR_INVALID_ARG;
}
return ESP_OK;
}
static bool lcd_trans_done_cb(esp_lcd_panel_io_handle_t panel_io, void *user_data, void *event_data)
{
(void) panel_io;
(void) user_data;
(void) event_data;
/* Used for `bsp_lcd_flush_wait` */
if (likely(NULL != bsp_lcd_flush_done_sem)) {
xSemaphoreGive(bsp_lcd_flush_done_sem);
}
/* Call user registered function */
if (NULL != p_on_trans_done_cb) {
return p_on_trans_done_cb(p_user_data);
}
return false;
}
/**
* @file bsp_lcd_i80.c
* @brief
* @version 0.1
* @date 2021-08-20
*
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "bsp_lcd.h"
#include "bsp_board.h"
#include "driver/gpio.h"
#include "esp_err.h"
#include "esp_log.h"
#include "esp_lcd_panel_io.h"
#include "freertos/FreeRTOS.h"
#include "freertos/semphr.h"
#include "freertos/task.h"
#if LCD_IFACE_I80
static const char *TAG = "bsp_lcd_i80";
static esp_lcd_i80_bus_handle_t i80_bus = NULL;
esp_err_t bsp_i80_lcd_init(esp_lcd_panel_io_handle_t *p_io_handle, bsp_lcd_trans_cb_t trans_done_cb)
{
esp_err_t ret_val = ESP_OK;
if (NULL == p_io_handle) {
ESP_LOGE(TAG, "Invalid LCD IO handle");
return ESP_ERR_INVALID_ARG;
}
esp_lcd_i80_bus_config_t bus_config = {
.dc_gpio_num = GPIO_LCD_DC,
.wr_gpio_num = GPIO_LCD_WR,
.data_gpio_nums = {
GPIO_LCD_D00, GPIO_LCD_D01, GPIO_LCD_D02, GPIO_LCD_D03,
GPIO_LCD_D04, GPIO_LCD_D05, GPIO_LCD_D06, GPIO_LCD_D07,
GPIO_LCD_D08, GPIO_LCD_D09, GPIO_LCD_D10, GPIO_LCD_D11,
GPIO_LCD_D12, GPIO_LCD_D13, GPIO_LCD_D14, GPIO_LCD_D15,
},
.bus_width = LCD_BUS_WIDTH,
.max_transfer_bytes = LCD_WIDTH * LCD_HEIGHT * sizeof(uint16_t) + 32,
};
ret_val |= esp_lcd_new_i80_bus(&bus_config, &i80_bus);
esp_lcd_panel_io_i80_config_t io_config = {
.cs_gpio_num = GPIO_LCD_CS,
.pclk_hz = LCD_FREQ,
.trans_queue_depth = 4,
.dc_levels = {
.dc_idle_level = 0,
.dc_cmd_level = 0,
.dc_dummy_level = 0,
.dc_data_level = 1,
},
.flags = {
.swap_color_bytes = 1,
},
.on_color_trans_done = trans_done_cb,
.user_data = NULL,
.lcd_cmd_bits = 8,
.lcd_param_bits = 8,
};
ret_val |= esp_lcd_new_panel_io_i80(i80_bus, &io_config, p_io_handle);
ESP_LOGD(TAG,
"LCD Initialized with Intel - 8080 - %d Bit interface. Clock speed : %d",
bus_config.bus_width, io_config.pclk_hz);
return ret_val;
}
esp_err_t bsp_i80_lcd_deinit(void)
{
esp_err_t ret_val = ESP_OK;
ret_val |= esp_lcd_del_i80_bus(i80_bus);
return ret_val;
}
#endif /* LCD_IFACE_I80 */
/**
* @file bsp_lcd_spi.c
* @brief
* @version 0.1
* @date 2021-08-25
*
* @copyright Copyright 2021 Espressif Systems (Shanghai) Co. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "bsp_lcd.h"
#include "bsp_board.h"
#include "driver/gpio.h"
#include "driver/spi_master.h"
#include "esp_compiler.h"
#include "esp_log.h"
#include "esp_lcd_panel_io.h"
#include "esp_lcd_panel_vendor.h"
#include "esp_lcd_panel_ops.h"
#include "freertos/FreeRTOS.h"
#include "freertos/semphr.h"
#include "freertos/task.h"
#include "soc/soc_memory_layout.h"
#if LCD_IFACE_SPI
static const char *TAG = "bsp_lcd_spi";
esp_err_t bsp_spi_lcd_init(esp_lcd_panel_io_handle_t *p_io_handle, bsp_lcd_trans_cb_t trans_done_cb)
{
esp_err_t ret_val = ESP_OK;
if (NULL == p_io_handle) {
ESP_LOGE(TAG, "Invalid LCD IO handle");
return ESP_ERR_INVALID_ARG;
}
spi_bus_config_t buscfg = {
.sclk_io_num = GPIO_LCD_CLK,
#if (LCD_BUS_WIDTH == 1)
.mosi_io_num = GPIO_LCD_DIN,
.miso_io_num = GPIO_NUM_NC,
.quadwp_io_num = GPIO_NUM_NC,
.quadhd_io_num = GPIO_NUM_NC,
#elif (LCD_BUS_WIDTH == 8)
.data0_io_num = GPIO_LCD_D00,
.data1_io_num = GPIO_LCD_D01,
.data2_io_num = GPIO_LCD_D02,
.data3_io_num = GPIO_LCD_D03,
.data4_io_num = GPIO_LCD_D04,
.data5_io_num = GPIO_LCD_D05,
.data6_io_num = GPIO_LCD_D06,
.data7_io_num = GPIO_LCD_D07,
.flags = SPICOMMON_BUSFLAG_OCTAL,
#endif
.max_transfer_sz = LCD_WIDTH * LCD_HEIGHT * sizeof(uint16_t)
};
ret_val |= spi_bus_initialize(LCD_HOST, &buscfg, SPI_DMA_CH_AUTO);
esp_lcd_panel_io_spi_config_t io_config = {
.dc_gpio_num = GPIO_LCD_DC,
.cs_gpio_num = GPIO_LCD_CS,
.pclk_hz = LCD_FREQ,
.spi_mode = 0,
.trans_queue_depth = 10,
.lcd_cmd_bits =
#if LCD_DISP_IC_NT
16,
#elif LCD_DISP_IC_ST
8,
#else
8, /* TBD */
#endif
.lcd_param_bits =
#if LCD_DISP_IC_NT
16,
#elif LCD_DISP_IC_ST
8,
#else
8, /* TBD */
#endif
.on_color_trans_done = trans_done_cb,
.user_data = NULL,
};
#if (LCD_BUS_WIDTH == 8)
io_config.flags.octal_mode = 1;
io_config.spi_mode = 3;
#endif
ret_val |= esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t) LCD_HOST, &io_config, p_io_handle);
return ESP_OK;
}
esp_err_t bsp_spi_lcd_deinit(void)
{
esp_err_t ret_val = ESP_OK;
ret_val |= spi_bus_free(LCD_HOST);
return ret_val;
}
#endif /* LCD_IFACE_SPI */
idf_component_register(
SRC_DIRS
"es7210"
"es8311"
"es8388"
INCLUDE_DIRS
"es7210"
"es8311"
"es8388"
"include"
REQUIRES
bsp
i2c_bus)
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Subproject commit ab58297280c2dbb02f83f02ad26b7cc05afa6760
# if(CONFIG_ESP32_S3_CUBE_BOARD)
set(COMPONENT_SRCDIRS
./MediaHal
./MediaHal/Codec
./SystemSal
./button
./SDCardConfig
./led
)
set(COMPONENT_ADD_INCLUDEDIRS
./MediaHal/Board
./MediaHal/Codec
./MediaHal
./SystemSal
./userconfig
./button/include
./SDCardConfig
./led/include
)
set(COMPONENT_REQUIRES
fatfs
esp_adc_cal
nvs_flash
)
register_component()
# endif()
menu "Audio Media HAL"
choice AUDIO_BOARD
prompt "Audio hardware board"
default ESP_LYRAT_MINI_V1_1_BOARD
help
Select an audio board to use with the ESP-ADF
config ESP_LYRAT_MINI_V1_1_BOARD
bool "ESP32-Lyrat Mini V1.1"
config ESP32_KORVO_V1_1_BOARD
bool "ESP32-Korvo V1.1"
config ESP32_S3_KORVO_V1_0_BOARD
bool "ESP32-S3-Korvo V1.0"
depends on IDF_TARGET_ESP32S3BETA
config ESP_KORVO_MIX_B_V1_0_BOARD
bool "ESP_KORVO_MIX_B_V1.0"
depends on IDF_TARGET_ESP32S3BETA
config ESP_KORVO_MIX_A_V1_0_BOARD
bool "ESP_KORVO_MIX_A_V1.0"
config ESP32_S3_KORVO_V2_0_BOARD
bool "ESP32-S3-Korvo V2.0"
depends on IDF_TARGET_ESP32S3
config ESP_KORVO_MIX_B_V2_0_BOARD
bool "ESP_KORVO_MIX_B_V2.0"
depends on IDF_TARGET_ESP32S3
config ESP32_S2_KALUGA_1_V1_2_BOARD
bool "ESP32-S2-Kaluga-1 v1.2"
config ESP32_S3_KORVO_V3_0_BOARD
bool "ESP32-S3-Korvo V3.0"
config ESP32_S3_CUBE_V2_0_BOARD
bool "ESP32-S3-CUBE V2.0"
endchoice
choice MIC_ARRAY_TYPE
prompt "Mic-array type"
depends on ESP32_KORVO_V1_1_BOARD || ESP32_S3_KORVO_V1_0_BOARD || ESP_KORVO_MIX_A_V1_0_BOARD || ESP32_S3_KORVO_V2_0_BOARD || ESP_KORVO_MIX_B_V2_0_BOARD || ESP32_S3_KORVO_V3_0_BOARD
config 2_MIC_LINEAR_ARRAY
bool "2-mic linear array"
config 3_MIC_CIRCULAR_ARRAY
bool "3-mic circular array"
endchoice
endmenu
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
* ES8311.h -- ES8311 ALSA SoC Audio Codec
*
* Authors:
*
* Based on ES8374.h by David Yang
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#ifndef _ES7243_H
#define _ES7243_H
#include "ESCodec_common.h"
esp_err_t Es7243Init(void);
int Es7243ReadReg(uint8_t regAdd);
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#ifndef _GET_SDCARD_H_
#define _GET_SDCARD_H_
#include "stdio.h"
#include "stdlib.h"
int sd_card_mount(const char* basePath);
int FatfsComboWrite(const void* buffer, int size, int count, FILE* stream);
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
idf_component_register(
SRC_DIRS
"."
INCLUDE_DIRS
"include" )
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment