This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 461ae475fdd764cbd14ecd425f028dad4f16c514 Author: ViezeVingertjes <[email protected]> AuthorDate: Wed Nov 25 17:43:00 2026 +0100 boards/esp32s3: Add Waveshare ESP32-S3-Touch-AMOLED-2.16 board. Add initial support for the Waveshare ESP32-S3-Touch-AMOLED-2.16, an ESP32-S3R8 board with 16MB flash, 8MB octal PSRAM, a 2.16" 480x480 QSPI AMOLED with touch, AXP2101 PMIC, QMI8658 IMU, PCF85063 RTC, ES8311/ES7210 audio and a microSD slot. This first step brings up the board itself: * USB Serial/JTAG console (the board has no USB-UART bridge). * BOOT (GPIO0), IO18 (GPIO18) and PWR (AXP2101 PWRON mirrored on GPIO16, active high) keys through the buttons lower half. * Shared I2C0 bus on GPIO15/GPIO14 for all on-board peripherals. * Make and CMake build support. * Configurations: nsh, i2c, psram and buttons. * Board documentation with pin mapping and I2C address map. Display, touch, PMIC, RTC, IMU, audio and SD card support follow in separate changes. Tested on hardware: NSH over USB Serial/JTAG, i2c scan finds all six on-board devices, PSRAM adds 8MB to the heap. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: ViezeVingertjes <[email protected]> --- .../esp32s3-touch-amoled-216.jpg | Bin 0 -> 47410 bytes .../boards/esp32s3-touch-amoled-216/index.rst | 183 ++++++++++++++++ boards/Kconfig | 16 ++ .../esp32s3-touch-amoled-216/CMakeLists.txt | 7 + .../esp32s3/esp32s3-touch-amoled-216/Kconfig | 29 +++ .../configs/buttons/defconfig | 67 ++++++ .../esp32s3-touch-amoled-216/configs/i2c/defconfig | 58 +++++ .../esp32s3-touch-amoled-216/configs/nsh/defconfig | 54 +++++ .../configs/psram/defconfig | 58 +++++ .../esp32s3-touch-amoled-216/include/board.h | 69 ++++++ .../include/board_memorymap.h | 118 +++++++++++ .../esp32s3-touch-amoled-216/scripts/Make.defs | 56 +++++ .../esp32s3-touch-amoled-216/src/CMakeLists.txt | 17 ++ .../esp32s3/esp32s3-touch-amoled-216/src/Make.defs | 34 +++ .../src/esp32s3-touch-amoled-216.h | 147 +++++++++++++ .../esp32s3-touch-amoled-216/src/esp32s3_boot.c | 85 ++++++++ .../esp32s3-touch-amoled-216/src/esp32s3_bringup.c | 233 +++++++++++++++++++++ .../esp32s3-touch-amoled-216/src/esp32s3_buttons.c | 168 +++++++++++++++ .../esp32s3-touch-amoled-216/src/esp32s3_reset.c | 87 ++++++++ 19 files changed, 1486 insertions(+) diff --git a/Documentation/platforms/xtensa/esp32s3/boards/esp32s3-touch-amoled-216/esp32s3-touch-amoled-216.jpg b/Documentation/platforms/xtensa/esp32s3/boards/esp32s3-touch-amoled-216/esp32s3-touch-amoled-216.jpg new file mode 100644 index 00000000000..52ba2da627f Binary files /dev/null and b/Documentation/platforms/xtensa/esp32s3/boards/esp32s3-touch-amoled-216/esp32s3-touch-amoled-216.jpg differ diff --git a/Documentation/platforms/xtensa/esp32s3/boards/esp32s3-touch-amoled-216/index.rst b/Documentation/platforms/xtensa/esp32s3/boards/esp32s3-touch-amoled-216/index.rst new file mode 100644 index 00000000000..1da86f69b59 --- /dev/null +++ b/Documentation/platforms/xtensa/esp32s3/boards/esp32s3-touch-amoled-216/index.rst @@ -0,0 +1,183 @@ +==================================== +Waveshare ESP32-S3-Touch-AMOLED-2.16 +==================================== + +.. tags:: arch:xtensa, chip:esp32s3, vendor:espressif + +This page discusses issues unique to NuttX configurations for the +Waveshare ESP32-S3-Touch-AMOLED-2.16 board. + +.. figure:: esp32s3-touch-amoled-216.jpg + :align: center + + ESP32-S3-Touch-AMOLED-2.16 (image: Waveshare, Apache-2.0) + +The ESP32-S3-Touch-AMOLED-2.16 is a compact development board with a +2.16 inch square AMOLED touch display, power management with a Li-ion +battery charger, motion sensing, a real time clock, audio input and output +and a microSD card slot. + +Features +======== + + - ESP32-S3R8, dual core Xtensa LX7 at up to 240 MHz, with 8MB octal PSRAM + - 16MB quad SPI flash + - 2.16 inch 480x480 AMOLED, CO5300 controller on a QSPI bus + - CST9220 capacitive touch controller + - AXP2101 power management IC with Li-ion battery charger + - QMI8658 6-axis IMU (accelerometer and gyroscope) + - PCF85063 real time clock with backup supply + - ES8311 audio codec driving a speaker amplifier + - ES7210 four channel audio ADC with two microphones + - microSD card slot + - BOOT, PWR and one user (IO18) key + - USB Type-C connected to the ESP32-S3 USB Serial/JTAG controller + +Board documentation: https://www.waveshare.com/wiki/ESP32-S3-Touch-AMOLED-2.16 + +Schematic and examples: https://github.com/waveshareteam/ESP32-S3-Touch-AMOLED-2.16 + +Serial Console +============== + +The board has no USB to UART bridge. The USB Type-C connector goes to the +ESP32-S3 USB Serial/JTAG controller, which is used both to flash the board +and as the NuttShell console (``/dev/console``, enumerated by the host as +``/dev/ttyACM0`` on Linux). UART0 (GPIO43 TX, GPIO44 RX) is available on +the side header. + +Board Buttons +============= + +The board has three keys: + + ====== ======== ==================================================== + Key GPIO Description + ====== ======== ==================================================== + BOOT GPIO0 Active low. Held at reset, enters the ROM bootloader + IO18 GPIO18 Active low, free for the application + PWR GPIO16 AXP2101 PWRON key, mirrored to GPIO16 (active high) + ====== ======== ==================================================== + +The PWR key is wired to the PWRON pin of the AXP2101. A MOSFET mirrors +its level to GPIO16, so the application can see it as a normal key, but +the AXP2101 still acts on it: a long press powers the board off and a +short press powers it back on. + +I2C Bus +======= + +All of the on-board peripherals except the display and the SD card share +one I2C bus, I2C0, on GPIO15 (SDA) and GPIO14 (SCL): + + ======== ======== =============================== + Address Device Function + ======== ======== =============================== + 0x18 ES8311 Audio codec (playback) + 0x34 AXP2101 Power management + 0x40 ES7210 Audio ADC (microphones) + 0x51 PCF85063 Real time clock + 0x5A CST9220 Touch controller + 0x6B QMI8658 IMU + ======== ======== =============================== + +Pin Mapping +=========== + + ========== ================================================== + GPIO Function + ========== ================================================== + GPIO0 BOOT key + GPIO1 microSD MOSI + GPIO2 microSD SCLK + GPIO3 microSD MISO + GPIO4-7 AMOLED QSPI data 0-3 + GPIO8 I2S data out (to ES8311) + GPIO9 I2S bit clock + GPIO10 I2S data in (from ES7210) + GPIO11 Touch interrupt + GPIO12 AMOLED QSPI chip select + GPIO13 RTC interrupt + GPIO14 I2C SCL + GPIO15 I2C SDA + GPIO16 PWR key (SYS_OUT) + GPIO17 IMU interrupt 1 + GPIO18 IO18 key + GPIO19/20 USB D-/D+ + GPIO21 IMU interrupt 2 + GPIO38 AMOLED QSPI clock + GPIO39 AMOLED reset + GPIO40 Touch reset + GPIO41 microSD chip select + GPIO42 I2S master clock + GPIO43/44 UART0 TX/RX + GPIO45 I2S word select + GPIO46 Speaker amplifier enable + ========== ================================================== + +Configurations +============== + +All of the configurations presented below can be tested by running the +following commands:: + + $ ./tools/configure.sh esp32s3-touch-amoled-216:<config_name> + $ make flash ESPTOOL_PORT=/dev/ttyACM0 -j + +Where ``<config_name>`` is the name of the board configuration you want to +use, e.g. ``nsh``. To access the console, open ``/dev/ttyACM0`` with a +serial terminal such as ``picocom`` or ``minicom``. + +buttons +------- + +This configuration shows the use of the buttons subsystem. It can be used +by executing the ``buttons`` application and pressing the BOOT, IO18 or +PWR key:: + + nsh> buttons + buttons_main: Starting the button_daemon + buttons_main: button_daemon started + button_daemon: Running + button_daemon: Opening /dev/buttons + button_daemon: Supported BUTTONs 0x07 + BOOT was pressed + BOOT was released + IO18 was pressed + IO18 was released + PWR was pressed + PWR was released + +i2c +--- + +This configuration enables the I2C bus driver and the ``i2c`` tool, which +can be used to inspect the on-board peripherals:: + + nsh> i2c dev 0x08 0x77 + 0 1 2 3 4 5 6 7 8 9 a b c d e f + 00: -- -- -- -- -- -- -- -- + 10: -- -- -- -- -- -- -- -- 18 -- -- -- -- -- -- -- + 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + 30: -- -- -- -- 34 -- -- -- -- -- -- -- -- -- -- -- + 40: 40 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + 50: -- 51 -- -- -- -- -- -- -- -- 5a -- -- -- -- -- + 60: -- -- -- -- -- -- -- -- -- -- -- 6b -- -- -- -- + 70: -- -- -- -- -- -- -- -- + +nsh +--- + +Basic NuttShell configuration (console enabled on the USB Serial/JTAG +controller). + +psram +----- + +This configuration enables the 8MB octal PSRAM and adds it to the heap. +The ``free`` command shows the extra memory, and the ``heap`` test can be +used to exercise it:: + + nsh> free + total used free maxused maxfree nused nfree name + 8775692 23020 8752672 23400 8388592 75 4 Umem diff --git a/boards/Kconfig b/boards/Kconfig index 3dcd354d893..f2a53359790 100644 --- a/boards/Kconfig +++ b/boards/Kconfig @@ -719,6 +719,18 @@ config ARCH_BOARD_ESP32S3_TOUCH_LCD_7 CPU with dual Xtensa LX7 cores, 7" LCD with Touchscreen, CAN, RS485, USB, etc. +config ARCH_BOARD_ESP32S3_TOUCH_AMOLED_216 + bool "Waveshare ESP32-S3-Touch-AMOLED-2.16" + depends on ARCH_CHIP_ESP32S3WROOM1N16R8 + select ARCH_HAVE_BUTTONS + select ARCH_HAVE_IRQBUTTONS if ESPRESSIF_GPIO_IRQ + ---help--- + The Waveshare ESP32-S3-Touch-AMOLED-2.16 board features the + ESP32-S3R8 (8MB octal PSRAM) with 16MB flash, a 2.16" 480x480 QSPI + AMOLED (CO5300) with capacitive touch (CST9220), an AXP2101 PMIC, + a QMI8658 IMU, a PCF85063 RTC, an ES8311 codec, an ES7210 ADC with + two microphones, a speaker amplifier and a microSD card slot. + config ARCH_BOARD_ESP32S3_WS_LCD128 bool "WaveShare ESP32-S3-(Touch)-LCD-1.28" depends on ARCH_CHIP_ESP32S3CUSTOM @@ -4289,6 +4301,7 @@ config ARCH_BOARD default "esp32s3-korvo-2" if ARCH_BOARD_ESP32S3_KORVO_2 default "lckfb-szpi-esp32s3" if ARCH_BOARD_ESP32S3_LCKFB_SZPI default "esp32s3-touch-lcd7" if ARCH_BOARD_ESP32S3_TOUCH_LCD_7 + default "esp32s3-touch-amoled-216" if ARCH_BOARD_ESP32S3_TOUCH_AMOLED_216 default "esp32s3-ws-lcd128" if ARCH_BOARD_ESP32S3_WS_LCD128 default "esp32c6-devkitc" if ARCH_BOARD_ESP32C6_DEVKITC default "esp32c6-devkitm" if ARCH_BOARD_ESP32C6_DEVKITM @@ -5771,6 +5784,9 @@ endif if ARCH_BOARD_ESP32S3_TOUCH_LCD_7 source "boards/xtensa/esp32s3/esp32s3-touch-lcd7/Kconfig" endif +if ARCH_BOARD_ESP32S3_TOUCH_AMOLED_216 +source "boards/xtensa/esp32s3/esp32s3-touch-amoled-216/Kconfig" +endif if ARCH_BOARD_ESP32S3_WS_LCD128 source "boards/xtensa/esp32s3/esp32s3-ws-lcd128/Kconfig" endif diff --git a/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/CMakeLists.txt b/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/CMakeLists.txt new file mode 100644 index 00000000000..727102b21c7 --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/CMakeLists.txt @@ -0,0 +1,7 @@ +# ############################################################################## +# boards/xtensa/esp32s3/esp32s3-touch-amoled-216/CMakeLists.txt +# +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## + +add_subdirectory(src) diff --git a/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/Kconfig b/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/Kconfig new file mode 100644 index 00000000000..33ca224ef24 --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/Kconfig @@ -0,0 +1,29 @@ +############################################################################ +# boards/xtensa/esp32s3/esp32s3-touch-amoled-216/Kconfig +# +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you 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. +# +############################################################################ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +if ARCH_BOARD_ESP32S3_TOUCH_AMOLED_216 + +endif # ARCH_BOARD_ESP32S3_TOUCH_AMOLED_216 diff --git a/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/configs/buttons/defconfig b/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/configs/buttons/defconfig new file mode 100644 index 00000000000..6af6c8a04ed --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/configs/buttons/defconfig @@ -0,0 +1,67 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +CONFIG_ARCH="xtensa" +CONFIG_ARCH_BOARD="esp32s3-touch-amoled-216" +CONFIG_ARCH_BOARD_COMMON=y +CONFIG_ARCH_BOARD_ESP32S3_TOUCH_AMOLED_216=y +CONFIG_ARCH_BUTTONS=y +CONFIG_ARCH_CHIP="esp32s3" +CONFIG_ARCH_CHIP_ESP32S3=y +CONFIG_ARCH_CHIP_ESP32S3WROOM1N16R8=y +CONFIG_ARCH_INTERRUPTSTACK=2048 +CONFIG_ARCH_IRQBUTTONS=y +CONFIG_ARCH_IRQ_TO_NDX=y +CONFIG_ARCH_MINIMAL_VECTORTABLE_DYNAMIC=y +CONFIG_ARCH_NUSER_INTERRUPTS=2 +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARCH_XTENSA=y +CONFIG_BOARD_LOOPSPERMSEC=16717 +CONFIG_BUILTIN=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_ESP32S3_USBSERIAL=y +CONFIG_ESPRESSIF_GPIO_IRQ=y +CONFIG_ETC_ROMFS=y +CONFIG_EXAMPLES_BUTTONS=y +CONFIG_EXAMPLES_BUTTONS_NAME0="BOOT" +CONFIG_EXAMPLES_BUTTONS_NAME1="IO18" +CONFIG_EXAMPLES_BUTTONS_NAME2="PWR" +CONFIG_EXAMPLES_BUTTONS_NAMES=y +CONFIG_EXAMPLES_BUTTONS_QTD=3 +CONFIG_EXPERIMENTAL=y +CONFIG_FS_PROCFS=y +CONFIG_FS_ROMFS=y +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +CONFIG_IDLETHREAD_STACKSIZE=3072 +CONFIG_INIT_ENTRYPOINT="init_main" +CONFIG_INIT_STACKSIZE=8192 +CONFIG_INPUT=y +CONFIG_INPUT_BUTTONS=y +CONFIG_INPUT_BUTTONS_DEBOUNCE_DELAY=20 +CONFIG_INPUT_BUTTONS_LOWER=y +CONFIG_INTELHEX_BINARY=y +CONFIG_LIBC_EXECFUNCS=y +CONFIG_LINE_MAX=64 +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_READLINE=y +CONFIG_PREALLOC_TIMERS=4 +CONFIG_RAM_SIZE=114688 +CONFIG_RAM_START=0x20000000 +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_CHILD_STATUS=y +CONFIG_SCHED_HAVE_PARENT=y +CONFIG_SCHED_WAITPID=y +CONFIG_START_DAY=6 +CONFIG_START_MONTH=12 +CONFIG_START_YEAR=2011 +CONFIG_SYSLOG_BUFFER=y +CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_NSH_STACKSIZE=8192 +CONFIG_SYSTEM_NXINIT=y diff --git a/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/configs/i2c/defconfig b/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/configs/i2c/defconfig new file mode 100644 index 00000000000..6fbec0cd777 --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/configs/i2c/defconfig @@ -0,0 +1,58 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +CONFIG_ARCH="xtensa" +CONFIG_ARCH_BOARD="esp32s3-touch-amoled-216" +CONFIG_ARCH_BOARD_COMMON=y +CONFIG_ARCH_BOARD_ESP32S3_TOUCH_AMOLED_216=y +CONFIG_ARCH_CHIP="esp32s3" +CONFIG_ARCH_CHIP_ESP32S3=y +CONFIG_ARCH_CHIP_ESP32S3WROOM1N16R8=y +CONFIG_ARCH_INTERRUPTSTACK=2048 +CONFIG_ARCH_IRQ_TO_NDX=y +CONFIG_ARCH_MINIMAL_VECTORTABLE_DYNAMIC=y +CONFIG_ARCH_NUSER_INTERRUPTS=2 +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARCH_XTENSA=y +CONFIG_BOARD_LOOPSPERMSEC=16717 +CONFIG_BUILTIN=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_ESP32S3_I2C0=y +CONFIG_ESP32S3_I2C0_SCLPIN=14 +CONFIG_ESP32S3_I2C0_SDAPIN=15 +CONFIG_ESP32S3_USBSERIAL=y +CONFIG_ETC_ROMFS=y +CONFIG_EXPERIMENTAL=y +CONFIG_FS_PROCFS=y +CONFIG_FS_ROMFS=y +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +CONFIG_IDLETHREAD_STACKSIZE=3072 +CONFIG_INIT_ENTRYPOINT="init_main" +CONFIG_INIT_STACKSIZE=8192 +CONFIG_INTELHEX_BINARY=y +CONFIG_LIBC_EXECFUNCS=y +CONFIG_LINE_MAX=64 +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_READLINE=y +CONFIG_PREALLOC_TIMERS=4 +CONFIG_RAM_SIZE=114688 +CONFIG_RAM_START=0x20000000 +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_CHILD_STATUS=y +CONFIG_SCHED_HAVE_PARENT=y +CONFIG_SCHED_WAITPID=y +CONFIG_START_DAY=6 +CONFIG_START_MONTH=12 +CONFIG_START_YEAR=2011 +CONFIG_SYSLOG_BUFFER=y +CONFIG_SYSTEM_I2CTOOL=y +CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_NSH_STACKSIZE=8192 +CONFIG_SYSTEM_NXINIT=y diff --git a/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/configs/nsh/defconfig b/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/configs/nsh/defconfig new file mode 100644 index 00000000000..144a17347aa --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/configs/nsh/defconfig @@ -0,0 +1,54 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +CONFIG_ARCH="xtensa" +CONFIG_ARCH_BOARD="esp32s3-touch-amoled-216" +CONFIG_ARCH_BOARD_COMMON=y +CONFIG_ARCH_BOARD_ESP32S3_TOUCH_AMOLED_216=y +CONFIG_ARCH_CHIP="esp32s3" +CONFIG_ARCH_CHIP_ESP32S3=y +CONFIG_ARCH_CHIP_ESP32S3WROOM1N16R8=y +CONFIG_ARCH_INTERRUPTSTACK=2048 +CONFIG_ARCH_IRQ_TO_NDX=y +CONFIG_ARCH_MINIMAL_VECTORTABLE_DYNAMIC=y +CONFIG_ARCH_NUSER_INTERRUPTS=2 +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARCH_XTENSA=y +CONFIG_BOARD_LOOPSPERMSEC=16717 +CONFIG_BUILTIN=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_ESP32S3_USBSERIAL=y +CONFIG_ETC_ROMFS=y +CONFIG_EXPERIMENTAL=y +CONFIG_FS_PROCFS=y +CONFIG_FS_ROMFS=y +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +CONFIG_IDLETHREAD_STACKSIZE=3072 +CONFIG_INIT_ENTRYPOINT="init_main" +CONFIG_INIT_STACKSIZE=8192 +CONFIG_INTELHEX_BINARY=y +CONFIG_LIBC_EXECFUNCS=y +CONFIG_LINE_MAX=64 +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_READLINE=y +CONFIG_PREALLOC_TIMERS=4 +CONFIG_RAM_SIZE=114688 +CONFIG_RAM_START=0x20000000 +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_CHILD_STATUS=y +CONFIG_SCHED_HAVE_PARENT=y +CONFIG_SCHED_WAITPID=y +CONFIG_START_DAY=6 +CONFIG_START_MONTH=12 +CONFIG_START_YEAR=2011 +CONFIG_SYSLOG_BUFFER=y +CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_NSH_STACKSIZE=8192 +CONFIG_SYSTEM_NXINIT=y diff --git a/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/configs/psram/defconfig b/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/configs/psram/defconfig new file mode 100644 index 00000000000..54cd2600845 --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/configs/psram/defconfig @@ -0,0 +1,58 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +CONFIG_ARCH="xtensa" +CONFIG_ARCH_BOARD="esp32s3-touch-amoled-216" +CONFIG_ARCH_BOARD_COMMON=y +CONFIG_ARCH_BOARD_ESP32S3_TOUCH_AMOLED_216=y +CONFIG_ARCH_CHIP="esp32s3" +CONFIG_ARCH_CHIP_ESP32S3=y +CONFIG_ARCH_CHIP_ESP32S3WROOM1N16R8=y +CONFIG_ARCH_INTERRUPTSTACK=2048 +CONFIG_ARCH_IRQ_TO_NDX=y +CONFIG_ARCH_MINIMAL_VECTORTABLE_DYNAMIC=y +CONFIG_ARCH_NUSER_INTERRUPTS=2 +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARCH_XTENSA=y +CONFIG_BOARD_LOOPSPERMSEC=16717 +CONFIG_BUILTIN=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_ESP32S3_SPIRAM=y +CONFIG_ESP32S3_SPIRAM_MODE_OCT=y +CONFIG_ESP32S3_USBSERIAL=y +CONFIG_ETC_ROMFS=y +CONFIG_EXPERIMENTAL=y +CONFIG_FS_PROCFS=y +CONFIG_FS_ROMFS=y +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +CONFIG_IDLETHREAD_STACKSIZE=3072 +CONFIG_INIT_ENTRYPOINT="init_main" +CONFIG_INIT_STACKSIZE=8192 +CONFIG_INTELHEX_BINARY=y +CONFIG_LIBC_EXECFUNCS=y +CONFIG_LINE_MAX=64 +CONFIG_MM_REGIONS=2 +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_READLINE=y +CONFIG_PREALLOC_TIMERS=4 +CONFIG_RAM_SIZE=114688 +CONFIG_RAM_START=0x20000000 +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_CHILD_STATUS=y +CONFIG_SCHED_HAVE_PARENT=y +CONFIG_SCHED_WAITPID=y +CONFIG_START_DAY=6 +CONFIG_START_MONTH=12 +CONFIG_START_YEAR=2011 +CONFIG_SYSLOG_BUFFER=y +CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_NSH_STACKSIZE=8192 +CONFIG_SYSTEM_NXINIT=y +CONFIG_TESTING_HEAP=y diff --git a/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/include/board.h b/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/include/board.h new file mode 100644 index 00000000000..4e052cce6c5 --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/include/board.h @@ -0,0 +1,69 @@ +/**************************************************************************** + * boards/xtensa/esp32s3/esp32s3-touch-amoled-216/include/board.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you 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. + * + ****************************************************************************/ + +#ifndef __BOARDS_XTENSA_ESP32S3_ESP32S3_TOUCH_AMOLED_216_INCLUDE_BOARD_H +#define __BOARDS_XTENSA_ESP32S3_ESP32S3_TOUCH_AMOLED_216_INCLUDE_BOARD_H + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Clocking *****************************************************************/ + +/* The ESP32-S3-Touch-AMOLED-2.16 board is fitted with a 40MHz crystal */ + +#define BOARD_XTAL_FREQUENCY 40000000 + +#ifdef CONFIG_ESP32S3_DEFAULT_CPU_FREQ_MHZ +# define BOARD_CLOCK_FREQUENCY (CONFIG_ESP32S3_DEFAULT_CPU_FREQ_MHZ * 1000000) +#else +# define BOARD_CLOCK_FREQUENCY 80000000 +#endif + +/* LED definitions **********************************************************/ + +/* The board has no user LEDs */ + +#define BOARD_NLEDS 0 + +/* Button definitions *******************************************************/ + +/* The board has three keys: + * + * BOOT - GPIO0, active low. + * IO18 - GPIO18, active low (labelled "IO18" on the silkscreen). + * PWR - The AXP2101 PWRON key. Its level is mirrored to GPIO16 + * (SYS_OUT) through a MOSFET, so the key reads high on GPIO16 + * while it is pressed. Holding it for several seconds makes + * the AXP2101 power the board off. + */ + +#define BUTTON_BOOT 0 +#define BUTTON_IO18 1 +#define BUTTON_PWR 2 +#define NUM_BUTTONS 3 + +#define BUTTON_BOOT_BIT (1 << BUTTON_BOOT) +#define BUTTON_IO18_BIT (1 << BUTTON_IO18) +#define BUTTON_PWR_BIT (1 << BUTTON_PWR) + +#endif /* __BOARDS_XTENSA_ESP32S3_ESP32S3_TOUCH_AMOLED_216_INCLUDE_BOARD_H */ diff --git a/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/include/board_memorymap.h b/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/include/board_memorymap.h new file mode 100644 index 00000000000..29596e57d7d --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/include/board_memorymap.h @@ -0,0 +1,118 @@ +/**************************************************************************** + * boards/xtensa/esp32s3/esp32s3-touch-amoled-216/include/board_memorymap.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you 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. + * + ****************************************************************************/ + +#ifndef __BOARDS_XTENSA_ESP32S3_ESP32S3_TOUCH_AMOLED_216_INCLUDE_BOARD_MEMORYMAP_H +#define __BOARDS_XTENSA_ESP32S3_ESP32S3_TOUCH_AMOLED_216_INCLUDE_BOARD_MEMORYMAP_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <stdint.h> + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Kernel ROM */ + +#define KIROM_START (uintptr_t)__kirom_start +#define KIROM_SIZE (uintptr_t)__kirom_size +#define KDROM_START (uintptr_t)__kdrom_start +#define KDROM_SIZE (uintptr_t)__kdrom_size + +/* Kernel RAM */ + +#define KIRAM_START (uintptr_t)__kiram_start +#define KIRAM_SIZE (uintptr_t)__kiram_size +#define KIRAM_END (uintptr_t)__kiram_end +#define KDRAM_START (uintptr_t)__kdram_start +#define KDRAM_SIZE (uintptr_t)__kdram_size +#define KDRAM_END (uintptr_t)__kdram_end + +/* Exception vectors */ + +#define VECTORS_START (uintptr_t)__vectors_start +#define VECTORS_END (uintptr_t)__vectors_end + +/* User ROM */ + +#define UIROM_START (uintptr_t)__uirom_start +#define UIROM_SIZE (uintptr_t)__uirom_size +#define UIROM_END (uintptr_t)__uirom_end +#define UDROM_START (uintptr_t)__udrom_start +#define UDROM_SIZE (uintptr_t)__udrom_size +#define UDROM_END (uintptr_t)__udrom_end + +/* User RAM */ + +#define UIRAM_START (uintptr_t)__uiram_start +#define UIRAM_SIZE (uintptr_t)__uiram_size +#define UIRAM_END (uintptr_t)__uiram_end +#define UDRAM_START (uintptr_t)__udram_start +#define UDRAM_SIZE (uintptr_t)__udram_size +#define UDRAM_END (uintptr_t)__udram_end + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/* Kernel ROM (RX) */ + +extern uint8_t __kirom_start[]; +extern uint8_t __kirom_size[]; +extern uint8_t __kdrom_start[]; +extern uint8_t __kdrom_size[]; + +/* Kernel RAM (RW) */ + +extern uint8_t __kiram_start[]; +extern uint8_t __kiram_size[]; +extern uint8_t __kiram_end[]; +extern uint8_t __kdram_start[]; +extern uint8_t __kdram_size[]; +extern uint8_t __kdram_end[]; + +/* Exception vectors */ + +extern uint8_t __vectors_start[]; +extern uint8_t __vectors_end[]; + +/* User ROM (RX) */ + +extern uint8_t __uirom_start[]; +extern uint8_t __uirom_size[]; +extern uint8_t __uirom_end[]; +extern uint8_t __udrom_start[]; +extern uint8_t __udrom_size[]; +extern uint8_t __udrom_end[]; + +/* User RAM (RW) */ + +extern uint8_t __uiram_start[]; +extern uint8_t __uiram_size[]; +extern uint8_t __uiram_end[]; +extern uint8_t __udram_start[]; +extern uint8_t __udram_size[]; +extern uint8_t __udram_end[]; + +#endif /* __BOARDS_XTENSA_ESP32S3_ESP32S3_TOUCH_AMOLED_216_INCLUDE_BOARD_MEMORYMAP_H */ diff --git a/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/scripts/Make.defs b/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/scripts/Make.defs new file mode 100644 index 00000000000..a55188b7203 --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/scripts/Make.defs @@ -0,0 +1,56 @@ +############################################################################ +# boards/xtensa/esp32s3/esp32s3-touch-amoled-216/scripts/Make.defs +# +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you 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 $(TOPDIR)/.config +include $(TOPDIR)/tools/Config.mk +include $(TOPDIR)/tools/esp32s3/Config.mk +include $(TOPDIR)/arch/xtensa/src/lx7/Toolchain.defs + +ARCHSCRIPT += $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)esp32s3_peripherals.ld +ARCHSCRIPT += $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)esp32s3_rom_aliases.ld + +# Pick the linker scripts from the board level if they exist, if not +# pick the common linker scripts. + +ifeq ($(CONFIG_BUILD_PROTECTED),y) + ARCHSCRIPT += $(call FINDSCRIPT,protected_memory.ld) + ARCHSCRIPT += $(call FINDSCRIPT,kernel-space.ld) +else + ARCHSCRIPT += $(call FINDSCRIPT,flat_memory.ld) + ifneq ($(CONFIG_ESP32S3_APP_FORMAT_LEGACY),y) + ARCHSCRIPT += $(call FINDSCRIPT,esp32s3_sections.ld) + else + ARCHSCRIPT += $(call FINDSCRIPT,legacy_sections.ld) + endif +endif + +ifneq ($(CONFIG_DEBUG_NOOPT),y) + ARCHOPTIMIZATION += -fno-strength-reduce +endif + + +CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) +CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) +CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) +CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) +CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) +AFLAGS := $(CFLAGS) -D__ASSEMBLY__ diff --git a/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/src/CMakeLists.txt b/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/src/CMakeLists.txt new file mode 100644 index 00000000000..99122d8f555 --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/src/CMakeLists.txt @@ -0,0 +1,17 @@ +# ############################################################################## +# boards/xtensa/esp32s3/esp32s3-touch-amoled-216/src/CMakeLists.txt +# +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## + +set(SRCS esp32s3_boot.c esp32s3_bringup.c) + +if(CONFIG_BOARDCTL_RESET) + list(APPEND SRCS esp32s3_reset.c) +endif() + +if(CONFIG_ARCH_BUTTONS) + list(APPEND SRCS esp32s3_buttons.c) +endif() + +target_sources(board PRIVATE ${SRCS}) diff --git a/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/src/Make.defs b/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/src/Make.defs new file mode 100644 index 00000000000..be70ab58589 --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/src/Make.defs @@ -0,0 +1,34 @@ +############################################################################ +# boards/xtensa/esp32s3/esp32s3-touch-amoled-216/src/Make.defs +# +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you 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. +# + +CSRCS = esp32s3_boot.c esp32s3_bringup.c + +ifeq ($(CONFIG_BOARDCTL_RESET),y) +CSRCS += esp32s3_reset.c +endif + +ifeq ($(CONFIG_ARCH_BUTTONS),y) +CSRCS += esp32s3_buttons.c +endif + +DEPPATH += --dep-path board +VPATH += :board +CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board diff --git a/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/src/esp32s3-touch-amoled-216.h b/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/src/esp32s3-touch-amoled-216.h new file mode 100644 index 00000000000..5b96a8e69d6 --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/src/esp32s3-touch-amoled-216.h @@ -0,0 +1,147 @@ +/**************************************************************************** + * boards/xtensa/esp32s3/esp32s3-touch-amoled-216/src/esp32s3-touch-amoled-216.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you 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. + * + ****************************************************************************/ + +#ifndef __BOARDS_XTENSA_ESP32S3_ESP32S3_TOUCH_AMOLED_216_SRC_ESP32S3_TOUCH_AMOLED_216_H +#define __BOARDS_XTENSA_ESP32S3_ESP32S3_TOUCH_AMOLED_216_SRC_ESP32S3_TOUCH_AMOLED_216_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> +#include <nuttx/compiler.h> +#include <stdint.h> + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Keys *********************************************************************/ + +#define GPIO_BUTTON_BOOT 0 /* BOOT key, active low */ +#define GPIO_BUTTON_IO18 18 /* IO18 key, active low */ +#define GPIO_BUTTON_PWR 16 /* SYS_OUT, AXP2101 PWRON key, active high */ + +/* I2C **********************************************************************/ + +/* A single I2C bus, GPIO15 (SDA) and GPIO14 (SCL), is shared by the + * touch controller, AXP2101, QMI8658, PCF85063, ES8311 and ES7210. + */ + +#define BOARD_I2C_BUS 0 + +/* QSPI AMOLED panel (CO5300), on SPI2 in quad mode *************************/ + +#define GPIO_LCD_CS 12 +#define GPIO_LCD_SCLK 38 +#define GPIO_LCD_SIO0 4 +#define GPIO_LCD_SIO1 5 +#define GPIO_LCD_SIO2 6 +#define GPIO_LCD_SIO3 7 +#define GPIO_LCD_RST 39 + +/* Touch controller (CST9220) ***********************************************/ + +#define GPIO_TP_INT 11 +#define GPIO_TP_RST 40 + +/* QMI8658 IMU **************************************************************/ + +#define GPIO_IMU_INT1 17 +#define GPIO_IMU_INT2 21 + +/* PCF85063 RTC *************************************************************/ + +#define GPIO_RTC_INT 13 + +/* Audio ********************************************************************/ + +/* ES8311 (playback) and ES7210 (capture) share the I2S0 clocks: + * MCLK GPIO42, BCLK GPIO9, LRCK GPIO45, DOUT GPIO8 and DIN GPIO10. + * GPIO46 enables the speaker power amplifier. + */ + +#define GPIO_SPK_PA_EN 46 + +/* microSD card, on SPI3 ****************************************************/ + +#define GPIO_SD_MOSI 1 +#define GPIO_SD_SCLK 2 +#define GPIO_SD_MISO 3 +#define GPIO_SD_CS 41 + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +/**************************************************************************** + * Name: esp32s3_bringup + * + * Description: + * Perform architecture-specific initialization + * + * CONFIG_BOARD_LATE_INITIALIZE=y : + * Called from board_late_initialize(). + * + * CONFIG_BOARD_LATE_INITIALIZE=n && CONFIG_BOARDCTL=y : + * Called from the NSH library via board_app_initialize(). + * + ****************************************************************************/ + +int esp32s3_bringup(void); + +/**************************************************************************** + * Name: board_i2c_init + * + * Description: + * Configure the I2C driver. + * + * Returned Value: + * Zero (OK) is returned on success; A negated errno value is returned + * to indicate the nature of any failure. + * + ****************************************************************************/ + +#ifdef CONFIG_I2C_DRIVER +int board_i2c_init(void); +#endif + +/**************************************************************************** + * Name: board_spiflash_init + * + * Description: + * Initialize the SPI Flash and register the MTD device. + * + * Returned Value: + * Zero (OK) is returned on success; A negated errno value is returned + * to indicate the nature of any failure. + * + ****************************************************************************/ + +#ifdef CONFIG_ESP32S3_SPIFLASH +int board_spiflash_init(void); +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_XTENSA_ESP32S3_ESP32S3_TOUCH_AMOLED_216_SRC_ESP32S3_TOUCH_AMOLED_216_H */ diff --git a/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/src/esp32s3_boot.c b/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/src/esp32s3_boot.c new file mode 100644 index 00000000000..37c51383fdd --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/src/esp32s3_boot.c @@ -0,0 +1,85 @@ +/**************************************************************************** + * boards/xtensa/esp32s3/esp32s3-touch-amoled-216/src/esp32s3_boot.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include <nuttx/debug.h> + +#include <nuttx/board.h> +#include <nuttx/mm/mm.h> +#include <arch/board/board.h> + +#include "esp32s3-touch-amoled-216.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: esp32s3_board_initialize + * + * Description: + * All ESP32-S3 boards must provide the following entry point. + * This entry point is called early in the initialization -- after all + * memory has been configured and mapped but before any devices have been + * initialized. + * + ****************************************************************************/ + +void esp32s3_board_initialize(void) +{ +} + +/**************************************************************************** + * Name: board_late_initialize + * + * Description: + * If CONFIG_BOARD_LATE_INITIALIZE is selected, then an additional + * initialization call will be performed in the boot-up sequence to a + * function called board_late_initialize(). board_late_initialize() will + * be called immediately after up_initialize() is called and just before + * the initial application is started. This additional initialization + * phase may be used, for example, to initialize board-specific device + * drivers. + * + ****************************************************************************/ + +#ifdef CONFIG_BOARD_LATE_INITIALIZE +void board_late_initialize(void) +{ + /* Perform board-specific initialization */ + + esp32s3_bringup(); +} +#endif diff --git a/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/src/esp32s3_bringup.c b/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/src/esp32s3_bringup.c new file mode 100644 index 00000000000..4f36ce7ddf4 --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/src/esp32s3_bringup.c @@ -0,0 +1,233 @@ +/**************************************************************************** + * boards/xtensa/esp32s3/esp32s3-touch-amoled-216/src/esp32s3_bringup.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include <errno.h> +#include <syslog.h> + +#include <nuttx/board.h> +#include <nuttx/fs/fs.h> +#include <arch/board/board.h> + +#ifdef CONFIG_ESP32S3_SPIRAM_BANKSWITCH_ENABLE +# include <nuttx/himem/himem.h> +#endif + +#ifdef CONFIG_ESPRESSIF_HR_TIMER +# include "espressif/esp_hr_timer.h" +#endif + +#ifdef CONFIG_ESP32S3_PARTITION_TABLE +# include "esp32s3_partition.h" +#endif + +#ifdef CONFIG_ESP32S3_TIMER +# include "esp32s3_board_tim.h" +#endif + +#ifdef CONFIG_WATCHDOG +# include "esp32s3_board_wdt.h" +#endif + +#ifdef CONFIG_RTC_DRIVER +# include "espressif/esp_rtc.h" +#endif + +#ifdef CONFIG_INPUT_BUTTONS +# include <nuttx/input/buttons.h> +#endif + +#ifdef CONFIG_ESPRESSIF_WIFI +# include "esp32s3_board_wlan.h" +#endif + +#ifdef CONFIG_ESPRESSIF_BLE +# include "esp32s3_ble.h" +#endif + +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST +# include "esp32s3_wifi_adapter.h" +#endif + +#include "esp32s3-touch-amoled-216.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: esp32s3_bringup + * + * Description: + * Perform architecture-specific initialization + * + * CONFIG_BOARD_LATE_INITIALIZE=y : + * Called from board_late_initialize(). + * + * CONFIG_BOARD_LATE_INITIALIZE=n && CONFIG_BOARDCTL=y : + * Called from the NSH library via board_app_initialize(). + * + ****************************************************************************/ + +int esp32s3_bringup(void) +{ + int ret; + +#if defined(CONFIG_ESP32S3_SPIRAM) && \ + defined(CONFIG_ESP32S3_SPIRAM_BANKSWITCH_ENABLE) + ret = esp_himem_init(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to init HIMEM: %d\n", ret); + } +#endif + +#ifdef CONFIG_ESPRESSIF_HR_TIMER + ret = esp_hr_timer_init(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: esp_hr_timer_init() failed: %d\n", ret); + } +#endif + +#ifdef CONFIG_FS_PROCFS + /* Mount the procfs file system */ + + ret = nx_mount(NULL, "/proc", "procfs", 0, NULL); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret); + } +#endif + +#ifdef CONFIG_FS_TMPFS + /* Mount the tmpfs file system */ + + ret = nx_mount(NULL, CONFIG_LIBC_TMPDIR, "tmpfs", 0, NULL); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to mount tmpfs at %s: %d\n", + CONFIG_LIBC_TMPDIR, ret); + } +#endif + +#ifdef CONFIG_ESP32S3_SPIFLASH + ret = board_spiflash_init(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to initialize SPI Flash: %d\n", ret); + } +#endif + +#ifdef CONFIG_ESP32S3_PARTITION_TABLE + ret = esp32s3_partition_init(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to initialize partitions: %d\n", ret); + } +#endif + +#ifdef CONFIG_ESP32S3_TIMER + ret = board_tim_init(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to initialize timers: %d\n", ret); + } +#endif + +#ifdef CONFIG_WATCHDOG + ret = board_wdt_init(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to initialize watchdog: %d\n", ret); + } +#endif + +#ifdef CONFIG_RTC_DRIVER + /* Register the ESP32-S3 internal RTC as /dev/rtc0 */ + + ret = esp_rtc_driverinit(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to instantiate the RTC driver: %d\n", + ret); + } +#endif + +#ifdef CONFIG_I2C_DRIVER + /* Register the shared board I2C bus as /dev/i2c0 */ + + ret = board_i2c_init(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to initialize I2C driver: %d\n", ret); + } +#endif + +#ifdef CONFIG_INPUT_BUTTONS + /* Register the BOOT, IO18 and PWR keys as /dev/buttons */ + + ret = btn_lower_initialize("/dev/buttons"); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: btn_lower_initialize() failed: %d\n", ret); + } +#endif + +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST + ret = esp_wifi_bt_coexist_init(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to initialize Wi-Fi and BT coexist\n"); + } +#endif + +#ifdef CONFIG_ESPRESSIF_BLE + ret = esp32s3_ble_initialize(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to initialize BLE: %d\n", ret); + } +#endif + +#ifdef CONFIG_ESPRESSIF_WIFI + ret = board_wlan_init(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to initialize wlan subsystem: %d\n", + ret); + } +#endif + + /* If we got here then perhaps not all initialization was successful, but + * at least enough succeeded to bring-up NSH with perhaps reduced + * capabilities. + */ + + UNUSED(ret); + return OK; +} diff --git a/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/src/esp32s3_buttons.c b/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/src/esp32s3_buttons.c new file mode 100644 index 00000000000..6f467291317 --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/src/esp32s3_buttons.c @@ -0,0 +1,168 @@ +/**************************************************************************** + * boards/xtensa/esp32s3/esp32s3-touch-amoled-216/src/esp32s3_buttons.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include <stdbool.h> +#include <stdint.h> +#include <errno.h> + +#include <nuttx/arch.h> +#include <nuttx/board.h> +#include <nuttx/irq.h> +#include <arch/board/board.h> + +#include "espressif/esp_gpio.h" + +#include "esp32s3-touch-amoled-216.h" + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +struct button_desc_s +{ + uint8_t gpio; /* GPIO the key is wired to */ + bool activehigh; /* True if the GPIO reads high while pressed */ + bool pullup; /* True if the internal pull-up should be enabled */ +}; + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/* Indexed by the BUTTON_* identifiers in board.h. BOOT and IO18 have + * external 10K pull-ups to 3V3; the internal pull-up is enabled as well so + * that the reading is defined even if those resistors are not fitted. + * GPIO16 is driven by a MOSFET with an external pull-up, so no internal + * bias is applied there. + */ + +static const struct button_desc_s g_buttons[NUM_BUTTONS] = +{ + [BUTTON_BOOT] = + { + GPIO_BUTTON_BOOT, false, true + }, + [BUTTON_IO18] = + { + GPIO_BUTTON_IO18, false, true + }, + [BUTTON_PWR] = + { + GPIO_BUTTON_PWR, true, false + }, +}; + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_button_initialize + * + * Description: + * board_button_initialize() must be called to initialize button resources. + * After that, board_buttons() may be called to collect the current state + * of all buttons or board_button_irq() may be called to register button + * interrupt handlers. + * + ****************************************************************************/ + +uint32_t board_button_initialize(void) +{ + int i; + + for (i = 0; i < NUM_BUTTONS; i++) + { + gpio_pinattr_t attr = INPUT_FUNCTION_2 | CHANGE; + + if (g_buttons[i].pullup) + { + attr |= PULLUP; + } + + esp_configgpio(g_buttons[i].gpio, attr); + } + + return NUM_BUTTONS; +} + +/**************************************************************************** + * Name: board_buttons + * + * Description: + * After board_button_initialize() has been called, board_buttons() may be + * called to collect the state of all buttons. board_buttons() returns a + * bit set with each bit associated with a button. See the BUTTON_*_BIT + * definitions in board.h for the meaning of each bit. + * + ****************************************************************************/ + +uint32_t board_buttons(void) +{ + uint32_t ret = 0; + int i; + + /* This may be called from the GPIO interrupt: just sample the keys, + * debouncing is left to the upper half + * (CONFIG_INPUT_BUTTONS_DEBOUNCE_DELAY). + */ + + for (i = 0; i < NUM_BUTTONS; i++) + { + if (esp_gpioread(g_buttons[i].gpio) == g_buttons[i].activehigh) + { + ret |= (1 << i); + } + } + + return ret; +} + +/**************************************************************************** + * Name: board_button_irq + * + * Description: + * board_button_irq() may be called to register an interrupt handler that + * will be called when a button is depressed or released. The ID value is + * a button enumeration value that uniquely identifies a button resource. + * See the BUTTON_* definitions in board.h for the meaning of enumeration + * value. + * + ****************************************************************************/ + +#ifdef CONFIG_ARCH_IRQBUTTONS +int board_button_irq(int id, xcpt_t irqhandler, void *arg) +{ + if (id < 0 || id >= NUM_BUTTONS) + { + return -EINVAL; + } + + return esp_gpio_irq(g_buttons[id].gpio, irqhandler, arg); +} +#endif diff --git a/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/src/esp32s3_reset.c b/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/src/esp32s3_reset.c new file mode 100644 index 00000000000..c8a8c6999d9 --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-touch-amoled-216/src/esp32s3_reset.c @@ -0,0 +1,87 @@ +/**************************************************************************** + * boards/xtensa/esp32s3/esp32s3-touch-amoled-216/src/esp32s3_reset.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include <stdlib.h> +#include <nuttx/debug.h> +#include <assert.h> +#include <nuttx/arch.h> +#include <nuttx/board.h> + +#include "esp32s3_systemreset.h" + +#ifdef CONFIG_BOARDCTL_RESET + +#if CONFIG_BOARD_ASSERT_RESET_VALUE == EXIT_SUCCESS +# error "CONFIG_BOARD_ASSERT_RESET_VALUE must not be equal to EXIT_SUCCESS" +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_reset + * + * Description: + * Reset board. Support for this function is required by board-level + * logic if CONFIG_BOARDCTL_RESET is selected. + * + * Input Parameters: + * status - Status information provided with the reset event. This + * meaning of this status information is board-specific. If not + * used by a board, the value zero may be provided in calls to + * board_reset(). + * + * Returned Value: + * If this function returns, then it was not possible to power-off the + * board due to some constraints. The return value in this case is a + * board-specific reason for the failure to shutdown. + * + ****************************************************************************/ + +int board_reset(int status) +{ + syslog(LOG_INFO, "reboot status=%d\n", status); + + switch (status) + { + case EXIT_SUCCESS: + up_shutdown_handler(); + break; + case CONFIG_BOARD_ASSERT_RESET_VALUE: + break; + default: + break; + } + + up_systemreset(); + + return 0; +} + +#endif /* CONFIG_BOARDCTL_RESET */
