diff --git a/Documentation/applications/examples/lvgldemo/index.rst b/Documentation/applications/examples/lvgldemo/index.rst index 3e721952738a9..c59dfd91087f7 100644 --- a/Documentation/applications/examples/lvgldemo/index.rst +++ b/Documentation/applications/examples/lvgldemo/index.rst @@ -1,3 +1,5 @@ +.. _lvgldemo: + ====================== ``lvgldemo`` LVGL Demo ====================== diff --git a/Documentation/platforms/xtensa/esp32s3/boards/esp32s3-ws-lcd128/ESP32-S3-LCD-1.28-details-inter.jpg b/Documentation/platforms/xtensa/esp32s3/boards/esp32s3-ws-lcd128/ESP32-S3-LCD-1.28-details-inter.jpg new file mode 100644 index 0000000000000..36d1c2977f8fb Binary files /dev/null and b/Documentation/platforms/xtensa/esp32s3/boards/esp32s3-ws-lcd128/ESP32-S3-LCD-1.28-details-inter.jpg differ diff --git a/Documentation/platforms/xtensa/esp32s3/boards/esp32s3-ws-lcd128/ESP32-S3-LCD-1.28-details-intro.jpg b/Documentation/platforms/xtensa/esp32s3/boards/esp32s3-ws-lcd128/ESP32-S3-LCD-1.28-details-intro.jpg new file mode 100644 index 0000000000000..a44dc75e75fbe Binary files /dev/null and b/Documentation/platforms/xtensa/esp32s3/boards/esp32s3-ws-lcd128/ESP32-S3-LCD-1.28-details-intro.jpg differ diff --git a/Documentation/platforms/xtensa/esp32s3/boards/esp32s3-ws-lcd128/ESP32-S3-LCD-1.28-details-size.jpg b/Documentation/platforms/xtensa/esp32s3/boards/esp32s3-ws-lcd128/ESP32-S3-LCD-1.28-details-size.jpg new file mode 100644 index 0000000000000..7eb185853e2be Binary files /dev/null and b/Documentation/platforms/xtensa/esp32s3/boards/esp32s3-ws-lcd128/ESP32-S3-LCD-1.28-details-size.jpg differ diff --git a/Documentation/platforms/xtensa/esp32s3/boards/esp32s3-ws-lcd128/ESP32-S3-Touch-LCD-1.28-details-inter.jpg b/Documentation/platforms/xtensa/esp32s3/boards/esp32s3-ws-lcd128/ESP32-S3-Touch-LCD-1.28-details-inter.jpg new file mode 100644 index 0000000000000..eebcd6d5748d2 Binary files /dev/null and b/Documentation/platforms/xtensa/esp32s3/boards/esp32s3-ws-lcd128/ESP32-S3-Touch-LCD-1.28-details-inter.jpg differ diff --git a/Documentation/platforms/xtensa/esp32s3/boards/esp32s3-ws-lcd128/ESP32-S3-Touch-LCD-1.28-details-intro.jpg b/Documentation/platforms/xtensa/esp32s3/boards/esp32s3-ws-lcd128/ESP32-S3-Touch-LCD-1.28-details-intro.jpg new file mode 100644 index 0000000000000..f6b91c6e4f974 Binary files /dev/null and b/Documentation/platforms/xtensa/esp32s3/boards/esp32s3-ws-lcd128/ESP32-S3-Touch-LCD-1.28-details-intro.jpg differ diff --git a/Documentation/platforms/xtensa/esp32s3/boards/esp32s3-ws-lcd128/ESP32-S3-Touch-LCD-1.28-details-size-1.jpg b/Documentation/platforms/xtensa/esp32s3/boards/esp32s3-ws-lcd128/ESP32-S3-Touch-LCD-1.28-details-size-1.jpg new file mode 100644 index 0000000000000..d0cc889cdf83f Binary files /dev/null and b/Documentation/platforms/xtensa/esp32s3/boards/esp32s3-ws-lcd128/ESP32-S3-Touch-LCD-1.28-details-size-1.jpg differ diff --git a/Documentation/platforms/xtensa/esp32s3/boards/esp32s3-ws-lcd128/ESP32-S3-Touch-LCD-1.28-details-size-2.jpg b/Documentation/platforms/xtensa/esp32s3/boards/esp32s3-ws-lcd128/ESP32-S3-Touch-LCD-1.28-details-size-2.jpg new file mode 100644 index 0000000000000..650e9831cb8e0 Binary files /dev/null and b/Documentation/platforms/xtensa/esp32s3/boards/esp32s3-ws-lcd128/ESP32-S3-Touch-LCD-1.28-details-size-2.jpg differ diff --git a/Documentation/platforms/xtensa/esp32s3/boards/esp32s3-ws-lcd128/ESP32-S3-Touch-LCD-1.28.jpg b/Documentation/platforms/xtensa/esp32s3/boards/esp32s3-ws-lcd128/ESP32-S3-Touch-LCD-1.28.jpg new file mode 100644 index 0000000000000..c2a8e6c8132a0 Binary files /dev/null and b/Documentation/platforms/xtensa/esp32s3/boards/esp32s3-ws-lcd128/ESP32-S3-Touch-LCD-1.28.jpg differ diff --git a/Documentation/platforms/xtensa/esp32s3/boards/esp32s3-ws-lcd128/index.rst b/Documentation/platforms/xtensa/esp32s3/boards/esp32s3-ws-lcd128/index.rst new file mode 100644 index 0000000000000..cc9b4720cf20e --- /dev/null +++ b/Documentation/platforms/xtensa/esp32s3/boards/esp32s3-ws-lcd128/index.rst @@ -0,0 +1,189 @@ +================= +ESP32S3-WS-LCD128 +================= + +.. tags:: chip:esp32s3 + +.. figure:: ESP32-S3-Touch-LCD-1.28.jpg + :align: center + +This board definition is a starting point for development with +`ESP32-S3-LCD-1.28 `__ and +`ESP32-S3-Touch-LCD-1.28 `__ +which are low-cost ($16/$22) open-source hardware designed by +`WaveShare `_. High-performance Xtensa based +ESP32-S3 MCU, small size, onboard round 1.28" LCD display, capacitive touch +screen (Touch version only), Li-ion accumulator charge manager, 6-axis sensor +(3-axis accelerometer and 3-axis gyroscope), and quick module attachmend +1.27mm connectors (non-Touch version only), makes it a perfect candidate +for integration into your projects and products quickly. + +.. list-table:: + :width: 100% + :class: borderless + + * - .. figure:: ESP32-S3-LCD-1.28-details-intro.jpg + :target: https://www.waveshare.com/wiki/ESP32-S3-LCD-1.28 + :align: center + + ESP32-S3-LCD-1.28. + + - .. figure:: ESP32-S3-Touch-LCD-1.28-details-intro.jpg + :target: https://www.waveshare.com/wiki/ESP32-S3-Touch-LCD-1.28 + :align: center + + ESP32-S3-Touch-LCD-1.28. + +These boards are almost identical. Touch version has touch screen, +while non-Touch version has two connectors exposing more GPIOs at the bottom, +thus slightly different signal routes. Because of that similarity, a single +board definition is provided by NuttX, while features and configuration +details are build time Kconfig selectable. + +Both boards are based on existing :ref:`esp32s3` chip implementation. +WaveShare WIKI contians board details, generic examples, documentation, and +schematics for the +`ESP32-S3-LCD-1.28 `__ and +`ESP32-S3-Touch-LCD-1.28 `__. + +.. note:: Implementation is experimental and still early stage of development! + + +Features +======== + + - ESP32-S3R2 Xtensa® 32-bit LX7 dual-core processor, up to 240MHz frequency. + - 2.4GHz Wi-Fi (802.11 b/g/n) and Bluetooth® 5 (BLE) with onboard antenna. + - Built in 512KB of SRAM and 384KB ROM, on-chip 2MB PSRAM, external 16MB + W25Q128JVSIQ NOR Flash memory. + - USB-C connector and CH343P USB-to-UART converter (flashing, console). + - Onboard GC9A01A controlled round 1.28" 240×240 resolution 65K color LCD. + - Onboard QMI8658 6-axis IMU (3-axis accelerometer and 3-axis gyroscope). + - Onboard 3.7V MX1.25 lithium battery re/discharge header, ETA6096 charger. + - Touch version: + + - CST816S capacitive touch display controller. + - 6 × GPIO exposed over SH1.0 connector. + + - Non-Touch version: + + - 32 x GPIO exposed over 2 x 2x10 1.27mm female connectors. + + +Pinouts +======= + + - ESP32-S3-LCD-1.28: + + .. figure:: ESP32-S3-LCD-1.28-details-inter.jpg + :align: center + + - ESP32-S3-Touch-LCD-1.28: + + .. figure:: ESP32-S3-Touch-LCD-1.28-details-inter.jpg + :align: center + +Dimensions +========== + + - ESP32-S3-LCD-1.28: + + .. figure:: ESP32-S3-LCD-1.28-details-size.jpg + :align: center + + - ESP32-S3-Touch-LCD-1.28: + + .. figure:: ESP32-S3-Touch-LCD-1.28-details-size-1.jpg + :align: center + + .. figure:: ESP32-S3-Touch-LCD-1.28-details-size-2.jpg + :align: center + + +Serial Console +============== + +UART0 is by default used for the serial console. It connects to the on-board +CH343P converter and is available on the USB-C connector that can be also used +for firmware flashing. + + +Buttons +======= + +Board Buttons +------------- + +There are two buttons labeled BOOT and RESET. The RESET button is not available +to the software and can be used as manual hardware Reset trigger. +The BOOT button is connected to IO0 and on reset / power-on it triggers the +BootROM serial bootloader when pressed. After reset the BOOT button can be used +as software input. + + +Configurations +============== + +All of the available configurations provide basic testing utilities or serve +as an example starting point for your own projects. +Use them by running the following commands:: + + $ ./tools/configure.sh esp32s3-ws-lcd128: + $ make flash ESPTOOL_PORT= -j + +Notes: + + - ```` is the name of board configuration you want to use + (i.e. nsh, lvgl). Then use a serial console terminal like ``cu`` or + ``minicom`` configured to 115200 8N1. + - ```` is usually ``/dev/ttyUSB0`` or ``/dev/cuaU0`` + depending on the OS you are using. + - On BSD systems use GNU Make (``gmake``) in place of ``make``. + +coremark +-------- + +Provides CoreMark benchmarking utility. + +notouch-lvgl +------------ + +This is a demonstration of the LVGL graphics library running on the NuttX's +GC9A01A LCD driver. Demo will launch itself on boot and you should see it on +the screen right away. This configuration uses the :ref:`lvgldemo` application. + +.. note:: This configuration has ``CONFIG_ARCH_BOARD_ESP32S3_WS_LCD128_NOTOUCH`` + set. It selects LCD pins valid for the Non-Touch board variant. + +nsh +--- + +Basic NuttShell configuration (console enabled in UART0, exposed via +USB connection by means of CH343P converter, at 115200 bps). + +qmi8658 +------- + +Provides QMI8658 IMU ``uorb_listener`` example. + +ostest +------ + +Provides ``ostest`` NuttX self-test utility. + +touch-lvgl +---------- + +This is a demonstration of the LVGL graphics library running on the NuttX's +GC9A01A LCD driver. Demo will launch itself on boot and you should see it on +the screen right away. This configuration uses the :ref:`lvgldemo` application. + +.. note:: This configuration has ``CONFIG_ARCH_BOARD_ESP32S3_WS_LCD128_TOUCH`` + set. It selects LCD pins valid for the Touch board variant. + +.. warning:: Touch screen driver is not yet implemented! Work in progress. + +watchdog +-------- + +Provides watchdog testing utilities. diff --git a/Documentation/platforms/xtensa/esp32s3/index.rst b/Documentation/platforms/xtensa/esp32s3/index.rst index b5707e3c636f2..a58c085dac6ef 100644 --- a/Documentation/platforms/xtensa/esp32s3/index.rst +++ b/Documentation/platforms/xtensa/esp32s3/index.rst @@ -1,3 +1,5 @@ +.. _esp32s3: + ================== Espressif ESP32-S3 ================== diff --git a/boards/Kconfig b/boards/Kconfig index 4a0b2547ffa80..598823e8eac11 100644 --- a/boards/Kconfig +++ b/boards/Kconfig @@ -597,6 +597,35 @@ config ARCH_BOARD_ESP32S3_LCKFB_SZPI select ARCH_HAVE_BUTTONS select ARCH_HAVE_IRQBUTTONS if ESPRESSIF_GPIO_IRQ +config ARCH_BOARD_ESP32S3_WS_LCD128 + bool "WaveShare ESP32-S3-(Touch)-LCD-1.28" + depends on ARCH_CHIP_ESP32S3CUSTOM + select ESP32S3_UART0 + select ESP32S3_SPI2 + select SPI_CMDDATA + select LCD + select LCD_DEV + select LCD_GC9A01 + ---help--- + This board comes in two variants: + 1. Touch screen marked ESP32-S3-Touch-LCD-1.28 [1]. + 2. No-Touch marked ESP32-S3-LCD-1.28 [2]. + + WaveShare ESP32-S3-(Touch)-LCD-1.28 board uses up to 240MHz dual core LX7 + 32-bit ESP32-S3R2 SoC with WiFi (802.11b/g/n) and Bluetooh 5 (LE) using + onboard antenna, 512KB SRAM, 384KB ROM, onboard 2MB PSRAM, external 16MB + NOR Flash (W25Q128JVSIQ). Flashing and console over CH434P UART-to-USB-C. + Board is equipped with round 240x240 GCA01 65K color SPI LCD, CST819 I2C + touch screen (touch variant), QMI8658 6-axis IMU, ETA6096 3.7V lithium + charger (MX1.25 connector), reset and boot buttons. + + Touch varian provides 6 GPIO over SH-1.0 12 pin connector (goldpin ended + cable attached). Non-touch variant provides two 2x10 1.27mm female board + connectors. + + [1] www.waveshare.com/esp32-s3-lcd-1.28.htm + [2] www.waveshare.com/esp32-s3-touch-lcd-1.28.htm + config ARCH_BOARD_ESP32C6_DEVKITC bool "Espressif ESP32-C6-DevKitC-1" depends on ARCH_CHIP_ESP32C6WROOM1 @@ -3628,6 +3657,7 @@ config ARCH_BOARD default "esp32s3-box" if ARCH_BOARD_ESP32S3_BOX default "esp32s3-korvo-2" if ARCH_BOARD_ESP32S3_KORVO_2 default "lckfb-szpi-esp32s3" if ARCH_BOARD_ESP32S3_LCKFB_SZPI + 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 default "esp32c6-xiao" if ARCH_BOARD_ESP32C6_XIAO @@ -4917,6 +4947,9 @@ endif if ARCH_BOARD_ESP32S3_LHCBIT source "boards/xtensa/esp32s3/esp32s3-lhcbit/Kconfig" endif +if ARCH_BOARD_ESP32S3_WS_LCD128 +source "boards/xtensa/esp32s3/esp32s3-ws-lcd128/Kconfig" +endif if ARCH_BOARD_ESP32S3_XIAO source "boards/xtensa/esp32s3/esp32s3-xiao/Kconfig" endif diff --git a/boards/xtensa/esp32s3/esp32s3-ws-lcd128/Kconfig b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/Kconfig new file mode 100644 index 0000000000000..4098fac387383 --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/Kconfig @@ -0,0 +1,38 @@ +# +# 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_WS_LCD128 + +choice + prompt "BOARD VARIANT" + default ARCH_BOARD_ESP32S3_WS_LCD128_NOTOUCH + ---help--- + There are two variants of the board with [1] and without [2] touch screen. + These boards also have slightly different signals and capabilities. + Non-touch variant has two connectors with many more GPIO available. + + [1] https://www.waveshare.com/esp32-s3-touch-lcd-1.28.htm + [2] https://www.waveshare.com/esp32-s3-lcd-1.28.htm + + NOTE: Touch screen driver is not yet implemented! + +config ARCH_BOARD_ESP32S3_WS_LCD128_NOTOUCH + bool "NO-TOUCH ESP32-S3-LCD-1.28" + select LCD + ---help--- + Mark this choice if your board has no touch screen module installed. + www.waveshare.com/esp32-s3-lcd-1.28.htm + +config ARCH_BOARD_ESP32S3_WS_LCD128_TOUCH + bool "TOUCH ESP32-S3-Touch-LCD-1.28" + help + Mark this choice if your board has touch screen module installed. + www.waveshare.com/esp32-s3-touch-lcd-1.28.htm + + NOTE: Touch screen driver is not yet implemented! + +endchoice + +endif # ARCH_BOARD_ESP32S3_WS_LCD128 diff --git a/boards/xtensa/esp32s3/esp32s3-ws-lcd128/configs/coremark/defconfig b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/configs/coremark/defconfig new file mode 100644 index 0000000000000..474346c16b817 --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/configs/coremark/defconfig @@ -0,0 +1,44 @@ +# +# 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_LEDS is not set +# CONFIG_NDEBUG is not set +CONFIG_ARCH="xtensa" +CONFIG_ARCH_BOARD="esp32s3-ws-lcd128" +CONFIG_ARCH_BOARD_COMMON=y +CONFIG_ARCH_BOARD_ESP32S3_WS_LCD128=y +CONFIG_ARCH_CHIP="esp32s3" +CONFIG_ARCH_CHIP_ESP32S3=y +CONFIG_ARCH_CHIP_ESP32S3CUSTOM=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_BENCHMARK_COREMARK=y +CONFIG_BOARD_LOOPSPERMSEC=16717 +CONFIG_DEBUG_CUSTOMOPT=y +CONFIG_DEBUG_OPTLEVEL="-O3" +CONFIG_ESP32S3_UART0=y +CONFIG_FS_PROCFS=y +CONFIG_IDLETHREAD_STACKSIZE=3072 +CONFIG_INIT_ENTRYPOINT="coremark_main" +CONFIG_INIT_STACKSIZE=3072 +CONFIG_INTELHEX_BINARY=y +CONFIG_PREALLOC_TIMERS=4 +CONFIG_RAM_SIZE=114688 +CONFIG_RAM_START=0x20000000 +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_WAITPID=y +CONFIG_SMP=y +CONFIG_SMP_NCPUS=2 +CONFIG_START_DAY=6 +CONFIG_START_MONTH=12 +CONFIG_START_YEAR=2011 +CONFIG_SYSLOG_BUFFER=y +CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/boards/xtensa/esp32s3/esp32s3-ws-lcd128/configs/notouch-lvgl/defconfig b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/configs/notouch-lvgl/defconfig new file mode 100644 index 0000000000000..1d44efb1fc6d1 --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/configs/notouch-lvgl/defconfig @@ -0,0 +1,78 @@ +# +# 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_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +CONFIG_ARCH="xtensa" +CONFIG_ARCH_BOARD="esp32s3-ws-lcd128" +CONFIG_ARCH_BOARD_COMMON=y +CONFIG_ARCH_BOARD_ESP32S3_WS_LCD128=y +CONFIG_ARCH_BOARD_ESP32S3_WS_LCD128_NOTOUCH=y +CONFIG_ARCH_CHIP="esp32s3" +CONFIG_ARCH_CHIP_ESP32S3=y +CONFIG_ARCH_CHIP_ESP32S3CUSTOM=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_INITTHREAD_STACKSIZE=8192 +CONFIG_BOARD_LATE_INITIALIZE=y +CONFIG_BOARD_LOOPSPERMSEC=16717 +CONFIG_BUILTIN=y +CONFIG_DEBUG_ASSERTIONS=y +CONFIG_DEBUG_ASSERTIONS_EXPRESSION=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_ESP32S3_DMA=y +CONFIG_ESP32S3_PSRAM_2M=y +CONFIG_ESP32S3_SPEED_UP_ISR=y +CONFIG_ESP32S3_SPI2_CLKPIN=10 +CONFIG_ESP32S3_SPI2_CSPIN=9 +CONFIG_ESP32S3_SPI2_MISOPIN=12 +CONFIG_EXAMPLES_LVGLDEMO=y +CONFIG_FS_PROCFS=y +CONFIG_GRAPHICS_LVGL=y +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +CONFIG_IDLETHREAD_STACKSIZE=8192 +CONFIG_INIT_ENTRYPOINT="lvgldemo_main" +CONFIG_INIT_STACKSIZE=16384 +CONFIG_INTELHEX_BINARY=y +CONFIG_LCD_FRAMEBUFFER=y +CONFIG_LCD_GC9A01_BGR=y +CONFIG_LCD_GC9A01_FREQUENCY=50000000 +CONFIG_LCD_PORTRAIT=y +CONFIG_LINE_MAX=64 +CONFIG_LV_FONT_MONTSERRAT_20=y +CONFIG_LV_USE_CLIB_MALLOC=y +CONFIG_LV_USE_CLIB_SPRINTF=y +CONFIG_LV_USE_CLIB_STRING=y +CONFIG_LV_USE_DEMO_WIDGETS=y +CONFIG_LV_USE_LOG=y +CONFIG_LV_USE_NUTTX=y +CONFIG_LV_USE_NUTTX_LCD=y +CONFIG_MM_REGIONS=2 +CONFIG_NDEBUG=y +CONFIG_NSH_ARCHINIT=y +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_LPWORK=y +CONFIG_SCHED_WAITPID=y +CONFIG_SPI_DRIVER=y +CONFIG_START_DAY=6 +CONFIG_START_MONTH=12 +CONFIG_START_YEAR=2011 +CONFIG_SYSLOG_BUFFER=y +CONFIG_SYSTEM_NSH=y +CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/boards/xtensa/esp32s3/esp32s3-ws-lcd128/configs/nsh/defconfig b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/configs/nsh/defconfig new file mode 100644 index 0000000000000..3adf3b0783239 --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/configs/nsh/defconfig @@ -0,0 +1,52 @@ +# +# 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_LEDS is not set +# CONFIG_ESP32S3_RTC is not set +# CONFIG_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +CONFIG_ARCH="xtensa" +CONFIG_ARCH_BOARD="esp32s3-ws-lcd128" +CONFIG_ARCH_BOARD_COMMON=y +CONFIG_ARCH_BOARD_ESP32S3_WS_LCD128=y +CONFIG_ARCH_CHIP="esp32s3" +CONFIG_ARCH_CHIP_ESP32S3=y +CONFIG_ARCH_CHIP_ESP32S3CUSTOM=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_FEATURES=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_ESP32S3_UART0=y +CONFIG_FS_PROCFS=y +CONFIG_IDLETHREAD_STACKSIZE=3072 +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INIT_STACKSIZE=3072 +CONFIG_INTELHEX_BINARY=y +CONFIG_LINE_MAX=64 +CONFIG_NSH_ARCHINIT=y +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_WAITPID=y +CONFIG_START_DAY=23 +CONFIG_START_MONTH=1 +CONFIG_START_YEAR=2026 +CONFIG_SYSLOG_BUFFER=y +CONFIG_SYSTEM_NSH=y +CONFIG_UART0_SERIAL_CONSOLE=y + diff --git a/boards/xtensa/esp32s3/esp32s3-ws-lcd128/configs/ostest/defconfig b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/configs/ostest/defconfig new file mode 100644 index 0000000000000..68ca025de5cbb --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/configs/ostest/defconfig @@ -0,0 +1,53 @@ +# +# 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_LEDS is not set +# CONFIG_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +CONFIG_ARCH="xtensa" +CONFIG_ARCH_BOARD="esp32s3-ws-lcd128" +CONFIG_ARCH_BOARD_COMMON=y +CONFIG_ARCH_BOARD_ESP32S3_WS_LCD128=y +CONFIG_ARCH_CHIP="esp32s3" +CONFIG_ARCH_CHIP_ESP32S3=y +CONFIG_ARCH_CHIP_ESP32S3CUSTOM=y +CONFIG_ARCH_INTERRUPTSTACK=2048 +CONFIG_ARCH_IRQ_TO_NDX=y +CONFIG_ARCH_MINIMAL_VECTORTABLE_DYNAMIC=y +CONFIG_ARCH_NUSER_INTERRUPTS=2 +CONFIG_ARCH_SETJMP_H=y +CONFIG_ARCH_STACKDUMP=y +CONFIG_ARCH_XTENSA=y +CONFIG_BOARD_LOOPSPERMSEC=16717 +CONFIG_BUILTIN=y +CONFIG_DEBUG_FEATURES=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_ESP32S3_UART0=y +CONFIG_FS_PROCFS=y +CONFIG_IDLETHREAD_STACKSIZE=3072 +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INIT_STACKSIZE=3072 +CONFIG_INTELHEX_BINARY=y +CONFIG_LINE_MAX=64 +CONFIG_NSH_ARCHINIT=y +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_THREAD_LOCAL=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_TESTING_OSTEST=y +CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/boards/xtensa/esp32s3/esp32s3-ws-lcd128/configs/qmi8658/defconfig b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/configs/qmi8658/defconfig new file mode 100644 index 0000000000000..b3364a5a18e0b --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/configs/qmi8658/defconfig @@ -0,0 +1,60 @@ +# +# 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_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +CONFIG_ARCH="xtensa" +CONFIG_ARCH_BOARD="esp32s3-ws-lcd128" +CONFIG_ARCH_BOARD_COMMON=y +CONFIG_ARCH_BOARD_ESP32S3_WS_LCD128=y +CONFIG_ARCH_CHIP="esp32s3" +CONFIG_ARCH_CHIP_ESP32S3=y +CONFIG_ARCH_CHIP_ESP32S3CUSTOM=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_DEBUG_UORB=y +CONFIG_ESP32S3_I2C0=y +CONFIG_FS_PROCFS=y +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +CONFIG_I2C_DRIVER=y +CONFIG_IDLETHREAD_STACKSIZE=3072 +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INIT_STACKSIZE=3072 +CONFIG_INTELHEX_BINARY=y +CONFIG_LINE_MAX=64 +CONFIG_NSH_ARCHINIT=y +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_HPWORK=y +CONFIG_SCHED_WAITPID=y +CONFIG_SENSORS=y +CONFIG_SENSORS_QMI8658=y +CONFIG_SENSORS_QMI8658_POLL=y +CONFIG_START_DAY=6 +CONFIG_START_MONTH=12 +CONFIG_START_YEAR=2011 +CONFIG_SYSLOG_BUFFER=y +CONFIG_SYSTEM_NSH=y +CONFIG_UART0_SERIAL_CONSOLE=y +CONFIG_UORB=y +CONFIG_UORB_LISTENER=y +CONFIG_UORB_STACKSIZE=4096 +CONFIG_USENSOR=y diff --git a/boards/xtensa/esp32s3/esp32s3-ws-lcd128/configs/touch-lvgl/defconfig b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/configs/touch-lvgl/defconfig new file mode 100644 index 0000000000000..4dc861581fdbb --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/configs/touch-lvgl/defconfig @@ -0,0 +1,79 @@ +# +# 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_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +CONFIG_ARCH="xtensa" +CONFIG_ARCH_BOARD="esp32s3-ws-lcd128" +CONFIG_ARCH_BOARD_COMMON=y +CONFIG_ARCH_BOARD_ESP32S3_WS_LCD128=y +CONFIG_ARCH_BOARD_ESP32S3_WS_LCD128_TOUCH=y +CONFIG_ARCH_CHIP="esp32s3" +CONFIG_ARCH_CHIP_ESP32S3=y +CONFIG_ARCH_CHIP_ESP32S3CUSTOM=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_INITTHREAD_STACKSIZE=8192 +CONFIG_BOARD_LATE_INITIALIZE=y +CONFIG_BOARD_LOOPSPERMSEC=16717 +CONFIG_BUILTIN=y +CONFIG_DEBUG_ASSERTIONS=y +CONFIG_DEBUG_ASSERTIONS_EXPRESSION=y +CONFIG_DEBUG_FEATURES=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_ESP32S3_DMA=y +CONFIG_ESP32S3_PSRAM_2M=y +CONFIG_ESP32S3_SPEED_UP_ISR=y +CONFIG_ESP32S3_SPI2_CLKPIN=10 +CONFIG_ESP32S3_SPI2_CSPIN=9 +CONFIG_ESP32S3_SPI2_MISOPIN=12 +CONFIG_EXAMPLES_LVGLDEMO=y +CONFIG_FS_PROCFS=y +CONFIG_GRAPHICS_LVGL=y +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +CONFIG_IDLETHREAD_STACKSIZE=8192 +CONFIG_INIT_ENTRYPOINT="lvgldemo_main" +CONFIG_INIT_STACKSIZE=16384 +CONFIG_INTELHEX_BINARY=y +CONFIG_LCD_FRAMEBUFFER=y +CONFIG_LCD_GC9A01_BGR=y +CONFIG_LCD_GC9A01_FREQUENCY=50000000 +CONFIG_LCD_PORTRAIT=y +CONFIG_LINE_MAX=64 +CONFIG_LV_FONT_MONTSERRAT_20=y +CONFIG_LV_USE_CLIB_MALLOC=y +CONFIG_LV_USE_CLIB_SPRINTF=y +CONFIG_LV_USE_CLIB_STRING=y +CONFIG_LV_USE_DEMO_WIDGETS=y +CONFIG_LV_USE_LOG=y +CONFIG_LV_USE_NUTTX=y +CONFIG_LV_USE_NUTTX_LCD=y +CONFIG_MM_REGIONS=2 +CONFIG_NDEBUG=y +CONFIG_NSH_ARCHINIT=y +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_LPWORK=y +CONFIG_SCHED_WAITPID=y +CONFIG_SPI_DRIVER=y +CONFIG_START_DAY=6 +CONFIG_START_MONTH=12 +CONFIG_START_YEAR=2011 +CONFIG_SYSLOG_BUFFER=y +CONFIG_SYSTEM_NSH=y +CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/boards/xtensa/esp32s3/esp32s3-ws-lcd128/configs/watchdog/defconfig b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/configs/watchdog/defconfig new file mode 100644 index 0000000000000..b1808d3156dfa --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/configs/watchdog/defconfig @@ -0,0 +1,56 @@ +# +# 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_LEDS is not set +# CONFIG_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +CONFIG_ARCH="xtensa" +CONFIG_ARCH_BOARD="esp32s3-ws-lcd128" +CONFIG_ARCH_BOARD_COMMON=y +CONFIG_ARCH_BOARD_ESP32S3_WS_LCD128=y +CONFIG_ARCH_CHIP="esp32s3" +CONFIG_ARCH_CHIP_ESP32S3=y +CONFIG_ARCH_CHIP_ESP32S3CUSTOM=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_MWDT0=y +CONFIG_ESP32S3_MWDT1=y +CONFIG_ESP32S3_RWDT=y +CONFIG_ESP32S3_UART0=y +CONFIG_EXAMPLES_WATCHDOG=y +CONFIG_FS_PROCFS=y +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +CONFIG_IDLETHREAD_STACKSIZE=3072 +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INIT_STACKSIZE=3072 +CONFIG_INTELHEX_BINARY=y +CONFIG_LINE_MAX=64 +CONFIG_NSH_ARCHINIT=y +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_WAITPID=y +CONFIG_START_DAY=6 +CONFIG_START_MONTH=12 +CONFIG_START_YEAR=2011 +CONFIG_SYSLOG_BUFFER=y +CONFIG_SYSTEM_NSH=y +CONFIG_UART0_SERIAL_CONSOLE=y +CONFIG_WATCHDOG=y diff --git a/boards/xtensa/esp32s3/esp32s3-ws-lcd128/include/board.h b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/include/board.h new file mode 100644 index 0000000000000..5e99e3b79f015 --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/include/board.h @@ -0,0 +1,55 @@ +/**************************************************************************** + * boards/xtensa/esp32s3/esp32s3-ws-lcd128/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_WS_LCD128_INCLUDE_BOARD_H +#define __BOARDS_XTENSA_ESP32S3_ESP32S3_WS_LCD128_INCLUDE_BOARD_H + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Clocking *****************************************************************/ + +/* The ESP32-S3 DevKit 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 **********************************************************/ + +/* Define how many LEDs this board has (needed by userleds) */ + +#define BOARD_NLEDS 0 + +/* GPIO pins used by the GPIO Subsystem */ + +//#define BOARD_NGPIOOUT 1 /* Amount of GPIO Output pins */ +//#define BOARD_NGPIOIN 1 /* Amount of GPIO Input without Interruption */ +//#define BOARD_NGPIOINT 1 /* Amount of GPIO Input w/ Interruption pins */ + + +#endif /* __BOARDS_XTENSA_ESP32S3_ESP32S3_WS_LCD128_INCLUDE_BOARD_H */ diff --git a/boards/xtensa/esp32s3/esp32s3-ws-lcd128/include/board_memorymap.h b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/include/board_memorymap.h new file mode 100644 index 0000000000000..68ac9c87dd3e8 --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/include/board_memorymap.h @@ -0,0 +1,118 @@ +/**************************************************************************** + * boards/xtensa/esp32s3/esp32s3-ws-lcd128/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_WS_LCD128_INCLUDE_BOARD_MEMORYMAP_H +#define __BOARDS_XTENSA_ESP32S3_ESP32S3_WS_LCD128_INCLUDE_BOARD_MEMORYMAP_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * 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_WS_LCD128_INCLUDE_BOARD_MEMORYMAP_H */ diff --git a/boards/xtensa/esp32s3/esp32s3-ws-lcd128/scripts/Make.defs b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/scripts/Make.defs new file mode 100644 index 0000000000000..dc7d09f5ab736 --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/scripts/Make.defs @@ -0,0 +1,57 @@ +############################################################################ +# boards/xtensa/esp32s3/esp32s3-ws-lcd128/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 + +ARCHPICFLAGS = -fpic + +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-ws-lcd128/src/Make.defs b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/src/Make.defs new file mode 100644 index 0000000000000..96072d67e6a9a --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/src/Make.defs @@ -0,0 +1,54 @@ +############################################################################ +# boards/xtensa/esp32s3/esp32s3-ws-lcd128/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),y) + CSRCS += esp32s3_appinit.c +ifeq ($(CONFIG_BOARDCTL_RESET),y) + CSRCS += esp32s3_reset.c +endif +endif + +ifeq ($(CONFIG_ARCH_BUTTONS),y) + CSRCS += esp32s3_buttons.c +endif + +ifeq ($(CONFIG_DEV_GPIO),y) + CSRCS += esp32s3_gpio.c +endif + +ifeq ($(CONFIG_SENSORS_QMI8658),y) + CSRCS += esp32s3_board_imu_qmi8658.c +endif + +ifeq ($(CONFIG_LCD_GC9A01),y) + CSRCS += esp32s3_board_lcd_gc9a01.c +endif + +ifeq ($(CONFIG_SPI),y) + CSRCS += esp32s3_board_spi.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-ws-lcd128/src/esp32s3-ws-lcd128.h b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/src/esp32s3-ws-lcd128.h new file mode 100644 index 0000000000000..2600cc24b5dc9 --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/src/esp32s3-ws-lcd128.h @@ -0,0 +1,193 @@ +/**************************************************************************** + * boards/xtensa/esp32s3/esp32s3-ws-lcd128/src/esp32s3-ws-lcd128.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_WS_LCD128_SRC_ESP32S3_WS_LCD128_H +#define __BOARDS_XTENSA_ESP32S3_ESP32S3_WS_LCD128_SRC_ESP32S3_WS_LCD128_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* IMU */ + +#define QMI8658_I2C_PORT (0) +#define QMI8658_I2C_ADDR (0x6A) + +/* RMT gpio */ + +#define RMT_RXCHANNEL (4) +#define RMT_TXCHANNEL (0) + +#ifdef CONFIG_RMT_LOOP_TEST_MODE +# define RMT_INPUT_PIN (0) +# define RMT_OUTPUT_PIN (0) +#else +# define RMT_INPUT_PIN (16) +#endif + +#define RMT_OUTPUT_PIN (15) + +/* LCD gpio */ + +#if defined(CONFIG_ARCH_BOARD_ESP32S3_WS_LCD128_TOUCH) && \ + defined(CONFIG_ARCH_BOARD_ESP32S3_WS_LCD128_NOTOUCH) +# error "CONFIG_ARCH_BOARD_ESP32S3_WS_LCD128_TOUCH is defined." +# error "CONFIG_ARCH_BOARD_ESP32S3_WS_LCD128_NOTOUCH is defined." +# error "These options are exclusive!" +#elif !defined(CONFIG_ARCH_BOARD_ESP32S3_WS_LCD128_TOUCH) && \ + !defined(CONFIG_ARCH_BOARD_ESP32S3_WS_LCD128_NOTOUCH) +# error "CONFIG_ARCH_BOARD_ESP32S3_WS_LCD128_TOUCH is not defined." +# error "CONFIG_ARCH_BOARD_ESP32S3_WS_LCD128_NOTOUCH is not defined." +# error "One of them must be defined!" +#elif defined(CONFIG_ARCH_BOARD_ESP32S3_WS_LCD128_TOUCH) +# ifdef CONFIG_LCD +# define DISPLAY_SPI (2) +# define DISPLAY_RST (14) +# define DISPLAY_DC (8) +# define DISPLAY_BCKL (2) +# endif +#elif defined(CONFIG_ARCH_BOARD_ESP32S3_WS_LCD128_NOTOUCH) +# ifdef CONFIG_LCD +# define DISPLAY_SPI (2) +# define DISPLAY_RST (12) +# define DISPLAY_DC (8) +# define DISPLAY_BCKL (40) +# endif +#endif + + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: esp32s3_bringup + * + * Description: + * Perform architecture-specific initialization + * + * CONFIG_BOARD_LATE_INITIALIZE=y : + * Called from board_late_initialize(). + * + * CONFIG_BOARD_LATE_INITIALIZE=y && CONFIG_BOARDCTL=y : + * Called from the NSH library via board_app_initialize() + * + ****************************************************************************/ + +int esp32s3_bringup(void); + +/**************************************************************************** + * Name: esp32s3_gpio_init + * + * Description: + * Configure the GPIO driver. + * + * Returned Value: + * Zero (OK) is returned on success; A negated errno value is returned + * to indicate the nature of any failure. + * + ****************************************************************************/ + +#ifdef CONFIG_DEV_GPIO +int esp32s3_gpio_init(void); +#endif + +/**************************************************************************** + * Name: board_spiflash_init + * + * Description: + * Initialize the SPIFLASH and register the MTD device. + * + ****************************************************************************/ + +#ifdef CONFIG_ESP32S3_SPIFLASH +int board_spiflash_init(void); +#endif + +/**************************************************************************** + * 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_i2sdev_initialize + * + * Description: + * This function is called by platform-specific, setup logic to configure + * and register the generic I2S audio driver. This function will register + * the driver as /dev/audio/pcm[x] where x is determined by the I2S port + * number. + * + * Input Parameters: + * port - The I2S port used for the device + * enable_tx - Register device as TX if true + * enable_rx - Register device as RX if true + * + * Returned Value: + * Zero is returned on success. Otherwise, a negated errno value is + * returned to indicate the nature of the failure. + * + ****************************************************************************/ + +#ifdef CONFIG_ESPRESSIF_I2S +int board_i2sdev_initialize(int port, bool enable_tx, bool enable_rx); +#endif + +#ifdef CONFIG_ESP32S3_TWAI +int esp32s3_twai_setup(void); +#endif + +#if defined(CONFIG_LCD) +int board_lcd_initialize(void); +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_XTENSA_ESP32S3_ESP32S3_WS_LCD128_SRC_ESP32S3_WS_LCD128_H */ diff --git a/boards/xtensa/esp32s3/esp32s3-ws-lcd128/src/esp32s3_appinit.c b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/src/esp32s3_appinit.c new file mode 100644 index 0000000000000..6ec0a750d94bf --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/src/esp32s3_appinit.c @@ -0,0 +1,82 @@ +/**************************************************************************** + * boards/xtensa/esp32s3/esp32s3-ws-lcd128/src/esp32s3_appinit.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 + +#include +#include + +#include "esp32s3-ws-lcd128.h" + +#ifdef CONFIG_BOARDCTL + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_app_initialize + * + * Description: + * Perform application specific initialization. This function is never + * called directly from application code, but only indirectly via the + * (non-standard) boardctl() interface using the command BOARDIOC_INIT. + * + * Input Parameters: + * arg - The boardctl() argument is passed to the board_app_initialize() + * implementation without modification. The argument has no + * meaning to NuttX; the meaning of the argument is a contract + * between the board-specific initialization logic and the + * matching application logic. The value could be such things as a + * mode enumeration value, a set of DIP switch settings, a + * pointer to configuration data read from a file or serial FLASH, + * or whatever you would like to do with it. Every implementation + * should accept zero/NULL as a default configuration. + * + * Returned Value: + * Zero (OK) is returned on success; a negated errno value is returned on + * any failure to indicate the nature of the failure. + * + ****************************************************************************/ + +int board_app_initialize(uintptr_t arg) +{ +#ifdef CONFIG_BOARD_LATE_INITIALIZE + /* Board initialization already performed by board_late_initialize() */ + + return OK; +#else + /* Perform board-specific initialization */ + + return esp32s3_bringup(); +#endif +} + +#endif /* CONFIG_BOARDCTL */ diff --git a/boards/xtensa/esp32s3/esp32s3-ws-lcd128/src/esp32s3_board_imu_qmi8658.c b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/src/esp32s3_board_imu_qmi8658.c new file mode 100644 index 0000000000000..87ebd9a44b877 --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/src/esp32s3_board_imu_qmi8658.c @@ -0,0 +1,84 @@ +/**************************************************************************** + * boards/xtensa/esp32s3/esp32s3-ws-lcd128/src/esp32s3_board_imu_qmi8658.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 + +#include +#include +#include +#include +#include +#include +#include + +#include "esp32s3_i2c.h" +#include "esp32s3-ws-lcd128.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: esp32s3_qmi8658_initialize + * + * Description: + * Initialize and register the QMI8658 6-axis IMU sensor driver. + * + * This function registers the uORB interface which creates: + * - "/dev/uorb/sensor_accel0" for accelerometer data + * - "/dev/uorb/sensor_gyro0" for gyroscope data + * + * Input Parameters: + * None + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +int esp32s3_qmi8658_initialize(void) +{ + struct i2c_master_s *i2c; + int ret; + + i2c = esp32s3_i2cbus_initialize(QMI8658_I2C_PORT); + if (!i2c) + { + i2cerr("Initialize I2C bus failed!\n"); + return -EINVAL; + } + + /* Register QMI8658 uORB sensor device */ + + ret = qmi8658_uorb_register(0, i2c, QMI8658_I2C_ADDR); + if (ret < 0) + { + syslog(LOG_ERR, "Failed to register QMI8658 uORB driver: %d\n", + ret); + } + + return ret; +} diff --git a/boards/xtensa/esp32s3/esp32s3-ws-lcd128/src/esp32s3_board_lcd_gc9a01.c b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/src/esp32s3_board_lcd_gc9a01.c new file mode 100644 index 0000000000000..2a090aa4f9a1b --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/src/esp32s3_board_lcd_gc9a01.c @@ -0,0 +1,145 @@ +/**************************************************************************** + * boards/xtensa/esp32s3/common/src/esp32s3_gc9a01.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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "espressif/esp_gpio.h" +#include "esp32s3_spi.h" +#include "esp32s3-ws-lcd128.h" + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static struct spi_dev_s *g_spidev; +static struct lcd_dev_s *g_lcd = NULL; + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_lcd_initialize + * + * Description: + * Initialize the LCD video hardware. The initial state of the LCD is + * fully initialized, display memory cleared, and the LCD ready to use, but + * with the power setting at 0 (full off). + * + ****************************************************************************/ + +int board_lcd_initialize(void) +{ + + syslog(LOG_DEBUG, "Initializing LCD GPIO pins."); + + /* SPI RX is not used. Same pin is used as LCD Data/Command control */ + + esp_configgpio(DISPLAY_DC, OUTPUT); + esp_gpiowrite(DISPLAY_DC, true); + + /* Pull LCD_RESET high */ + + esp_configgpio(DISPLAY_RST, OUTPUT); + esp_gpiowrite(DISPLAY_RST, false); + up_mdelay(50); + esp_gpiowrite(DISPLAY_RST, true); + up_mdelay(50); + + /* Set full brightness */ + + esp_configgpio(DISPLAY_BCKL, OUTPUT); + esp_gpiowrite(DISPLAY_BCKL, true); + + syslog(LOG_DEBUG, "Initializing LCD SPI %d port.\n", DISPLAY_SPI); + + g_spidev = esp32s3_spibus_initialize(DISPLAY_SPI); + if (!g_spidev) + { + syslog(LOG_ERR, "Failed to initialize LCD SPI port %d.\n", DISPLAY_SPI); + return -ENODEV; + } + + syslog(LOG_INFO, "Initialized SPI port %d.\n", DISPLAY_SPI); + + g_lcd = gc9a01_lcdinitialize(g_spidev); + if (!g_lcd) { + syslog(LOG_ERR, "Failed to initialize LCD %d.\n", 0); + return -ENODEV; + } + + return OK; +} + +/**************************************************************************** + * Name: board_lcd_getdev + * + * Description: + * Return a reference to the LCD object for the specified LCD. This + * allows support for multiple LCD devices. + * + ****************************************************************************/ + +struct lcd_dev_s *board_lcd_getdev(int devno) +{ + if (!g_lcd) + { + syslog(LOG_ERR, "ERROR: Failed to bind SPI port %d to LCD %d\n", + DISPLAY_SPI, devno); + return NULL; + } + else + { + syslog(LOG_INFO, "SPI port %d bound to LCD %d.\n", DISPLAY_SPI, devno); + return g_lcd; + } + return NULL; +} + +/**************************************************************************** + * Name: board_lcd_uninitialize + * + * Description: + * Uninitialize the LCD support + * + ****************************************************************************/ + +void board_lcd_uninitialize(void) +{ + /* Turn the display off */ + + g_lcd->setpower(g_lcd, 0); +} diff --git a/boards/xtensa/esp32s3/esp32s3-ws-lcd128/src/esp32s3_board_spi.c b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/src/esp32s3_board_spi.c new file mode 100644 index 0000000000000..1b9eac3df2271 --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/src/esp32s3_board_spi.c @@ -0,0 +1,163 @@ +/**************************************************************************** + * boards/xtensa/esp32s3/common/src/esp32s3_board_spi.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 + +#include +#include +#include + +#include +#include + +#include "espressif/esp_gpio.h" +#include "esp32s3-ws-lcd128.h" + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: spi_status + ****************************************************************************/ + +static inline uint8_t spi_status(struct spi_dev_s *dev, uint32_t devid) +{ + uint8_t status = 0; + +#ifdef CONFIG_MMCSD_SPI + if (devid == SPIDEV_MMCSD(0)) + { + status |= SPI_STATUS_PRESENT; + } +#endif + +#if defined(CONFIG_LCD_ILI9341) || defined(CONFIG_LCD_SSD1680) || defined(CONFIG_LCD_ST7789) || defined(CONFIG_LCD_GC9A01) + if (devid == SPIDEV_DISPLAY(0)) + { + status |= SPI_STATUS_PRESENT; + } +#endif + + return status; +} + +/**************************************************************************** + * Name: spi_cmddata + ****************************************************************************/ + +#ifdef CONFIG_SPI_CMDDATA + +static inline int spi_cmddata(struct spi_dev_s *dev, uint32_t devid, + bool cmd) +{ +#if defined(CONFIG_LCD_ILI9341) || defined(CONFIG_LCD_SSD1680) || defined(CONFIG_LCD_ST7789) || defined(CONFIG_LCD_GC9A01) + if (devid == SPIDEV_DISPLAY(0)) + { + /* This is the Data/Command control pad which determines whether the + * data bits are data or a command. + */ + + esp_gpiowrite(DISPLAY_DC, !cmd); + return OK; + } +#endif + + return -ENODEV; +} + +#endif + + +#if defined(CONFIG_ESP32S3_SPI2) && defined(CONFIG_ESP32S3_SPI_UDCS) +void esp32s3_spi2_select(struct spi_dev_s *dev, uint32_t devid, bool select) +{ + esp_gpiowrite(CONFIG_ESP32S3_SPI2_CSPIN, !select); +} +#endif + + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: esp32s3_spi2_status + ****************************************************************************/ + +#ifdef CONFIG_ESP32S3_SPI2 + +uint8_t esp32s3_spi2_status(struct spi_dev_s *dev, uint32_t devid) +{ + return spi_status(dev, devid); +} + +#endif + +/**************************************************************************** + * Name: esp32s3_spi2_cmddata + ****************************************************************************/ + +#if defined(CONFIG_ESP32S3_SPI2) && defined(CONFIG_SPI_CMDDATA) + +int esp32s3_spi2_cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd) +{ + spiinfo("devid: %" PRIu32 " CMD: %s\n", devid, cmd ? "command" : + "data"); + + return spi_cmddata(dev, devid, cmd); +} + +#endif + +/**************************************************************************** + * Name: esp32s3_spi3_status + ****************************************************************************/ + +#ifdef CONFIG_ESP32S3_SPI3 + +uint8_t esp32s3_spi3_status(struct spi_dev_s *dev, uint32_t devid) +{ + return spi_status(dev, devid); +} + +#endif + +/**************************************************************************** + * Name: esp32s3_spi3_cmddata + ****************************************************************************/ + +#if defined(CONFIG_ESP32S3_SPI3) && defined(CONFIG_SPI_CMDDATA) + +int esp32s3_spi3_cmddata(struct spi_dev_s *dev, uint32_t devid, bool cmd) +{ + spiinfo("devid: %" PRIu32 " CMD: %s\n", devid, cmd ? "command" : + "data"); + + return spi_cmddata(dev, devid, cmd); +} + +#endif diff --git a/boards/xtensa/esp32s3/esp32s3-ws-lcd128/src/esp32s3_boot.c b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/src/esp32s3_boot.c new file mode 100644 index 0000000000000..fa968070ee541 --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/src/esp32s3_boot.c @@ -0,0 +1,85 @@ +/**************************************************************************** + * boards/xtensa/esp32s3/esp32s3-ws-lcd128/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 + +#include + +#include +#include +#include + +#include "esp32s3-ws-lcd128.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-ws-lcd128/src/esp32s3_bringup.c b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/src/esp32s3_bringup.c new file mode 100644 index 0000000000000..7cccd826349ba --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/src/esp32s3_bringup.c @@ -0,0 +1,671 @@ +/**************************************************************************** + * boards/xtensa/esp32s3/esp32s3-ws-lcd128/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 + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#ifdef CONFIG_ESP32S3_TIMER +# include "esp32s3_board_tim.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 + +#ifdef CONFIG_ESP32S3_RT_TIMER +# include "esp32s3_rt_timer.h" +#endif + +#ifdef CONFIG_ESP32S3_I2C +# include "esp32s3_i2c.h" +#endif + +#ifdef CONFIG_ESPRESSIF_I2S +# include "espressif/esp_i2s.h" +#endif + +#ifdef CONFIG_WATCHDOG +# include "esp32s3_board_wdt.h" +#endif + +#ifdef CONFIG_INPUT_BUTTONS +# include +#endif + +#ifdef CONFIG_RTC_DRIVER +# include "esp32s3_rtc_lowerhalf.h" +#endif + +#ifdef CONFIG_VIDEO_FB +#include +#endif + +#ifdef CONFIG_ESPRESSIF_EFUSE +# include "espressif/esp_efuse.h" +#endif + +#ifdef CONFIG_ESPRESSIF_LEDC +# include "esp32s3_board_ledc.h" +#endif + +#ifdef CONFIG_ESP32S3_PARTITION_TABLE +# include "esp32s3_partition.h" +#endif + +#ifdef CONFIG_ESP_RMT +# include "esp32s3_board_rmt.h" +#endif + +#ifdef CONFIG_ESP_MCPWM +# include "esp32s3_board_mcpwm.h" +#endif + +#ifdef CONFIG_ESP32S3_SPI +#include "esp32s3_spi.h" +#include "esp32s3_board_spidev.h" +# ifdef CONFIG_ESPRESSIF_SPI_BITBANG +# include "espressif/esp_spi_bitbang.h" +# endif +#endif + +#ifdef CONFIG_SPI_SLAVE_DRIVER +#include "esp32s3_board_spislavedev.h" +#endif + +#if defined(CONFIG_ESP32S3_SDMMC) || defined(CONFIG_MMCSD_SPI) +#include "esp32s3_board_sdmmc.h" +#endif + +#ifdef CONFIG_ESP32S3_AES_ACCELERATOR +# include "esp32s3_aes.h" +#endif + +#ifdef CONFIG_ESPRESSIF_ADC +#include "esp32s3_board_adc.h" +#endif + +#ifdef CONFIG_ESPRESSIF_TEMP +# include "espressif/esp_temperature_sensor.h" +#endif + +#ifdef CONFIG_ESP_PCNT +# include "espressif/esp_pcnt.h" +# include "esp32s3_board_pcnt.h" +#endif + +#ifdef CONFIG_SYSTEM_NXDIAG_ESPRESSIF_CHIP_WO_TOOL +# include "espressif/esp_nxdiag.h" +#endif + +#ifdef CONFIG_ESP_SDM +# include "espressif/esp_sdm.h" +#endif + +#ifdef CONFIG_ESPRESSIF_SHA_ACCELERATOR +# include "espressif/esp_sha.h" +#endif + +#ifdef CONFIG_ESPRESSIF_USE_ULP_RISCV_CORE +# include "espressif/esp_ulp.h" +# ifdef CONFIG_ESPRESSIF_ULP_USE_TEST_BIN +# include "ulp/ulp_code.h" +# endif +#endif + +#include "esp32s3-ws-lcd128.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 + * + ****************************************************************************/ + +int esp32s3_bringup(void) +{ + int ret; + + syslog(LOG_INFO, "esp32s3_bringup(): start."); + +#if (defined(CONFIG_ESPRESSIF_I2S0) && !defined(CONFIG_AUDIO_CS4344)) || \ + defined(CONFIG_ESPRESSIF_I2S1) + bool i2s_enable_tx; + bool i2s_enable_rx; +#endif + +#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 + +#if defined(CONFIG_ESP32S3_SPI) && defined(CONFIG_SPI_DRIVER) + + #if defined(CONFIG_SPI_SLAVE_DRIVER) && defined(CONFIG_ESP32S3_SPI2) + ret = board_spislavedev_initialize(ESP32S3_SPI2); + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize SPI%d Slave driver: %d\n", + ESP32S3_SPI2, ret); + } + #endif + + #if defined(CONFIG_SPI_SLAVE_DRIVER) && defined(CONFIG_ESP32S3_SPI3) + ret = board_spislavedev_initialize(ESP32S3_SPI3); + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize SPI%d Slave driver: %d\n", + ESP32S3_SPI2, ret); + } + #endif + + #if defined(CONFIG_ESP32S3_SPI2) && !defined(CONFIG_SPI_SLAVE_DRIVER) + ret = board_spidev_initialize(ESP32S3_SPI2); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to init spidev 3: %d\n", ret); + } + #endif + + #if defined(CONFIG_ESP32S3_SPI3) && !defined(CONFIG_SPI_SLAVE_DRIVER) + ret = board_spidev_initialize(ESP32S3_SPI3); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to init spidev 3: %d\n", ret); + } + #endif + + #ifdef CONFIG_ESPRESSIF_SPI_BITBANG + ret = board_spidev_initialize(ESPRESSIF_SPI_BITBANG); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to init spidev 3: %d\n", ret); + } + #endif /* CONFIG_ESPRESSIF_SPI_BITBANG */ +#endif /* CONFIG_ESP32S3_SPI && CONFIG_SPI_DRIVER*/ + +#if defined(CONFIG_ESPRESSIF_EFUSE) + ret = esp_efuse_initialize("/dev/efuse"); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to init EFUSE: %d\n", ret); + } +#endif + +#if defined(CONFIG_ESPRESSIF_SHA_ACCELERATOR) && \ + !defined(CONFIG_CRYPTO_CRYPTODEV_HARDWARE) + ret = esp_sha_init(); + if (ret < 0) + { + syslog(LOG_ERR, + "ERROR: Failed to initialize SHA: %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_ESPRESSIF_LEDC + ret = esp32s3_pwm_setup(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: esp32s3_pwm_setup() failed: %d\n", ret); + } +#endif /* CONFIG_ESPRESSIF_LEDC */ + +#ifdef CONFIG_ESP32S3_TIMER + /* Configure general purpose timers */ + + ret = board_tim_init(); + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize timers: %d\n", ret); + } +#endif + +#ifdef CONFIG_ESP32S3_SPIFLASH + ret = board_spiflash_init(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to initialize SPI Flash\n"); + } +#endif + +#ifdef CONFIG_ESP32S3_PARTITION_TABLE + ret = esp32s3_partition_init(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to initialize partition error=%d\n", + ret); + } +#endif + +#ifdef CONFIG_ESP32S3_RT_TIMER + ret = esp32s3_rt_timer_init(); + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize RT timer: %d\n", ret); + } +#endif + +#ifdef CONFIG_ESP_RMT + ret = board_rmt_txinitialize(RMT_TXCHANNEL, RMT_OUTPUT_PIN); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: board_rmt_txinitialize() failed: %d\n", ret); + } + + ret = board_rmt_rxinitialize(RMT_RXCHANNEL, RMT_INPUT_PIN); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: board_rmt_txinitialize() failed: %d\n", ret); + } +#endif + +#ifdef CONFIG_ESPRESSIF_TEMP + struct esp_temp_sensor_config_t cfg = TEMPERATURE_SENSOR_CONFIG(10, 50); + ret = esp_temperature_sensor_initialize(cfg); + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize temperature sensor driver: %d\n", + ret); + } +#endif + +#ifdef CONFIG_RTC_DRIVER + /* Instantiate the ESP32-S3 RTC driver */ + + ret = esp32s3_rtc_driverinit(); + if (ret < 0) + { + syslog(LOG_ERR, + "ERROR: Failed to Instantiate the RTC driver: %d\n", ret); + } +#endif + +#ifdef CONFIG_WATCHDOG + /* Configure watchdog timer */ + + ret = board_wdt_init(); + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize watchdog timer: %d\n", ret); + } +#endif + +#ifdef CONFIG_I2C_DRIVER + /* Configure I2C peripheral interfaces */ + + ret = board_i2c_init(); + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize I2C driver: %d\n", ret); + } +#endif + +#ifdef CONFIG_ESP32S3_TWAI + + /* Initialize TWAI and register the TWAI driver. */ + + ret = esp32s3_twai_setup(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: esp32s3_twai_setup failed: %d\n", ret); + } +#endif + +#ifdef CONFIG_SENSORS_BMP180 + /* Try to register BMP180 device in I2C0 */ + + ret = board_bmp180_initialize(0, ESP32S3_I2C0); + if (ret < 0) + { + syslog(LOG_ERR, + "Failed to initialize BMP180 driver for I2C0: %d\n", ret); + } +#endif + +#if defined(CONFIG_ESPRESSIF_I2S) + +#ifdef CONFIG_AUDIO_CS4344 + + /* Configure CS4344 audio on I2S0 */ + + ret = esp32s3_cs4344_initialize(ESP32S3_I2S0); + if (ret != OK) + { + syslog(LOG_ERR, "Failed to initialize CS4344 audio: %d\n", ret); + } +#else + +#if defined(CONFIG_ESPRESSIF_I2S0_TX) + i2s_enable_tx = true; +#else + i2s_enable_tx = false; +#endif /* CONFIG_ESPRESSIF_I2S0_TX */ + +#if defined(CONFIG_ESPRESSIF_I2S0_RX) + i2s_enable_rx = true; +#else + i2s_enable_rx = false; +#endif /* CONFIG_ESPRESSIF_I2S0_RX */ + + /* Configure I2S generic audio on I2S0 */ + + ret = board_i2sdev_initialize(ESP32S3_I2S0, i2s_enable_tx, i2s_enable_rx); + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize I2S0 driver: %d\n", ret); + } +#endif /* CONFIG_AUDIO_CS4344 */ + +#if defined(CONFIG_ESPRESSIF_I2S1) + +#if defined(CONFIG_ESPRESSIF_I2S1_TX) + i2s_enable_tx = true; +#else + i2s_enable_tx = false; +#endif /* CONFIG_ESPRESSIF_I2S1_TX */ + +#if defined(CONFIG_ESPRESSIF_I2S1_RX) + i2s_enable_rx = true; +#else + i2s_enable_rx = false; +#endif /* CONFIG_ESPRESSIF_I2S1_RX */ + + /* Configure I2S generic audio on I2S1 */ + + ret = board_i2sdev_initialize(ESP32S3_I2S1, i2s_enable_tx, i2s_enable_rx); + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize I2S%d driver: %d\n", + ESP32S3_I2S1, ret); + } + +#endif /* CONFIG_ESPRESSIF_I2S1 */ + +#endif /* CONFIG_ESPRESSIF_I2S */ + +/*** +#ifdef CONFIG_INPUT_BUTTONS + * Register the BUTTON driver * + + ret = btn_lower_initialize("/dev/buttons"); + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize button driver: %d\n", ret); + } +#endif +***/ + +#ifdef CONFIG_INPUT_DJOYSTICK + ret = esp32s3_djoy_initialize(); + if (ret != OK) + { + syslog(LOG_ERR, "Failed to register djoystick driver: %d\n", ret); + } +#endif + +#ifdef CONFIG_ESPRESSIF_WIRELESS + +#ifdef CONFIG_ESPRESSIF_WIFI_BT_COEXIST + ret = esp_wifi_bt_coexist_init(); + if (ret) + { + syslog(LOG_ERR, "ERROR: Failed to initialize Wi-Fi and BT coexist\n"); + } +#endif + +#ifdef CONFIG_ESPRESSIF_BLE + ret = esp32s3_ble_initialize(); + if (ret) + { + syslog(LOG_ERR, "ERROR: Failed to initialize BLE\n"); + } +#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 + +#endif + +#ifdef CONFIG_ESP32S3_OPENETH + ret = esp_openeth_initialize(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to initialize Open ETH ethernet.\n"); + } +#endif + +#if defined(CONFIG_DEV_GPIO) && !defined(CONFIG_GPIO_LOWER_HALF) + ret = esp32s3_gpio_init(); + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize GPIO Driver: %d\n", ret); + } +#endif + +#if defined(CONFIG_VIDEO_FB) + ret = fb_register(0, 0); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to initialize Frame Buffer Driver.\n"); + } +#elif defined(CONFIG_LCD) + ret = board_lcd_initialize(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to initialize LCD.\n"); + } +#endif + +#ifdef CONFIG_LCD_DEV + ret = lcddev_register(0); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: lcddev_register() failed: %d\n", ret); + } +#endif + +#ifdef CONFIG_NET_LAN9250 + ret = esp32s3_lan9250_initialize(LAN9250_SPI); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to initialize SPI ethernet LAN9250.\n"); + } +#endif + +#ifdef CONFIG_ESP32S3_SDMMC + ret = board_sdmmc_initialize(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to initialize SDMMC: %d\n", ret); + } +#endif + +#ifdef CONFIG_MMCSD_SPI + ret = board_sdmmc_spi_initialize(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to initialize SDMMC: %d\n", ret); + } +#endif + +#ifdef CONFIG_ESP32S3_AES_ACCELERATOR + ret = esp32s3_aes_init(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to initialize AES: %d\n", ret); + } +#ifdef CONFIG_ESP32S3_AES_ACCELERATOR_TEST + else + { + esp32s3_aes_test(); + } +#endif +#endif + +#ifdef CONFIG_ESPRESSIF_ADC + /* Configure ADC */ + + ret = board_adc_init(); + if (ret) + { + syslog(LOG_ERR, "ERROR: board_adc_init() failed: %d\n", ret); + } +#endif + +#ifdef CONFIG_ESP_SDM + struct esp_sdm_chan_config_s config = + { + .gpio_num = 5, + .sample_rate_hz = 1000 * 1000, + .flags = 0, + }; + + struct dac_dev_s *dev = esp_sdminitialize(config); + ret = dac_register("/dev/dac0", dev); + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize DAC driver: %d\n", + ret); + } +#endif + +#ifdef CONFIG_ESP_MCPWM_CAPTURE + ret = board_capture_initialize(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: board_capture_initialize failed: %d\n", ret); + } +#endif + +#ifdef CONFIG_ESP_MCPWM_MOTOR_BDC + ret = board_motor_initialize(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: board_motor_initialize failed: %d\n", ret); + } +#endif + +#ifdef CONFIG_ESP_PCNT + ret = board_pcnt_initialize(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: board_pcnt_initialize failed: %d\n", ret); + } +#endif + +#ifdef CONFIG_SYSTEM_NXDIAG_ESPRESSIF_CHIP_WO_TOOL + ret = esp_nxdiag_initialize(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: esp_nxdiag_initialize failed: %d\n", ret); + } +#endif + +#ifdef CONFIG_ESPRESSIF_USE_ULP_RISCV_CORE + + /* ULP initialization should be the handled later than + * peripherals to use supported peripherals properly on ULP core + */ + + esp_ulp_init(); +# ifdef CONFIG_ESPRESSIF_ULP_USE_TEST_BIN + esp_ulp_load_bin((char *)esp_ulp_bin, esp_ulp_bin_len); +# endif +#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. + */ + + syslog(LOG_INFO, "esp32s3_bringup(): end."); + + UNUSED(ret); + return OK; +} diff --git a/boards/xtensa/esp32s3/esp32s3-ws-lcd128/src/esp32s3_buttons.c b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/src/esp32s3_buttons.c new file mode 100644 index 0000000000000..73fb8f2c57b5d --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/src/esp32s3_buttons.c @@ -0,0 +1,166 @@ +/**************************************************************************** + * boards/xtensa/esp32s3/esp32s3-ws-lcd128/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 + +#include +#include +#include + +#include +#include +#include + +#include "esp32s3_gpio.h" +#include "hardware/esp32s3_gpio_sigmap.h" + +#include "esp32s3-ws-lcd128.h" + +/**************************************************************************** + * 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) +{ + esp32s3_configgpio(BUTTON_BOOT, INPUT_FUNCTION_2 | PULLUP); + return 1; +} + +/**************************************************************************** + * 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 an + * 8-bit 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) +{ + uint8_t ret = 0; + int i = 0; + int n = 0; + + bool b0 = esp32s3_gpioread(BUTTON_BOOT); + + for (i = 0; i < 10; i++) + { + up_mdelay(1); + + bool b1 = esp32s3_gpioread(BUTTON_BOOT); + + if (b0 == b1) + { + n++; + } + else + { + n = 0; + } + + if (3 == n) + { + break; + } + + b0 = b1; + } + + iinfo("b=%d n=%d\n", b0, n); + + /* Low value means that the button is pressed */ + + if (!b0) + { + ret = 0x1; + } + + 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) +{ + int ret; + DEBUGASSERT(id == 0); + + int irq = ESP32S3_PIN2IRQ(BUTTON_BOOT); + + if (irqhandler != NULL) + { + /* Make sure the interrupt is disabled */ + + esp32s3_gpioirqdisable(irq); + + ret = irq_attach(irq, irqhandler, arg); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: irq_attach() failed: %d\n", ret); + return ret; + } + + gpioinfo("Attach %p\n", irqhandler); + + gpioinfo("Enabling the interrupt\n"); + + /* Configure the interrupt for rising and falling edges */ + + esp32s3_gpioirqenable(irq, CHANGE); + } + else + { + gpioinfo("Disable the interrupt\n"); + esp32s3_gpioirqdisable(irq); + } + + return OK; +} +#endif diff --git a/boards/xtensa/esp32s3/esp32s3-ws-lcd128/src/esp32s3_gpio.c b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/src/esp32s3_gpio.c new file mode 100644 index 0000000000000..2790688e124fd --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/src/esp32s3_gpio.c @@ -0,0 +1,537 @@ +/**************************************************************************** + * boards/xtensa/esp32s3/esp32s3-ws-lcd128/src/esp32s3_gpio.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 + +#include +#include +#include +#include +#include + +#include + +#include + +#include "esp32s3-ws-lcd128.h" +#include "esp32s3_gpio.h" +#include "hardware/esp32s3_gpio_sigmap.h" + +#ifdef CONFIG_ESPRESSIF_DEDICATED_GPIO +#include "espressif/esp_dedic_gpio.h" +#endif + +#ifdef CONFIG_ESPRESSIF_USE_ULP_RISCV_CORE +#include "esp32s3_rtc_gpio.h" +#endif + +#if defined(CONFIG_DEV_GPIO) && !defined(CONFIG_GPIO_LOWER_HALF) + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#if !defined(CONFIG_ESP32S3_GPIO_IRQ) && BOARD_NGPIOINT > 0 +# error "NGPIOINT is > 0 and GPIO interrupts aren't enabled" +#endif + +/* Output pins. GPIO15 is used as an example, any other outputs could be + * used. + */ + +#define GPIO_OUT1 15 + +/* Input pins. GPIO18 is used as an example, any other inputs could be + * used. + */ + +#define GPIO_IN1 18 + +/* Interrupt pins. GPIO21 is used as an example, any other inputs could be + * used. + */ + +#define GPIO_IRQPIN1 21 + +/* Dedicated GPIO pins. GPIO4 and GPIO5 is used as an example, any other + * GPIOs could be used. + */ + +#define GPIO_DEDIC1 4 +#define GPIO_DEDIC2 5 +#define GPIO_DEDIC_COUNT 2 + +#define GPIO_RTC1 0 +#define GPIO_RTC_COUNT 1 + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +struct esp32s3gpio_dev_s +{ + struct gpio_dev_s gpio; + uint8_t id; +}; + +struct esp32s3gpint_dev_s +{ + struct esp32s3gpio_dev_s esp32s3gpio; + pin_interrupt_t callback; +}; + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +#if BOARD_NGPIOOUT > 0 +static int gpout_read(struct gpio_dev_s *dev, bool *value); +static int gpout_write(struct gpio_dev_s *dev, bool value); +#endif + +#if BOARD_NGPIOIN > 0 +static int gpin_read(struct gpio_dev_s *dev, bool *value); +#endif + +#if BOARD_NGPIOINT > 0 +static int gpint_read(struct gpio_dev_s *dev, bool *value); +static int gpint_attach(struct gpio_dev_s *dev, + pin_interrupt_t callback); +static int gpint_enable(struct gpio_dev_s *dev, bool enable); +#endif +#ifdef CONFIG_ESPRESSIF_USE_ULP_RISCV_CORE +static int gprtc_read(struct gpio_dev_s *dev, bool *value); +static int gprtc_write(struct gpio_dev_s *dev, bool value); +#endif + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +#if BOARD_NGPIOOUT > 0 +static const struct gpio_operations_s gpout_ops = +{ + .go_read = gpout_read, + .go_write = gpout_write, + .go_attach = NULL, + .go_enable = NULL, +}; + +/* This array maps the GPIO pins used as OUTPUT */ + +static const uint32_t g_gpiooutputs[BOARD_NGPIOOUT] = +{ + GPIO_OUT1 +}; + +static struct esp32s3gpio_dev_s g_gpout[BOARD_NGPIOOUT]; +#endif + +#if BOARD_NGPIOIN > 0 +static const struct gpio_operations_s gpin_ops = +{ + .go_read = gpin_read, + .go_write = NULL, + .go_attach = NULL, + .go_enable = NULL, +}; + +/* This array maps the GPIO pins used as INTERRUPT INPUTS */ + +static const uint32_t g_gpioinputs[BOARD_NGPIOIN] = +{ + GPIO_IN1 +}; + +static struct esp32s3gpio_dev_s g_gpin[BOARD_NGPIOIN]; +#endif + +#if BOARD_NGPIOINT > 0 +static const struct gpio_operations_s gpint_ops = +{ + .go_read = gpint_read, + .go_write = NULL, + .go_attach = gpint_attach, + .go_enable = gpint_enable, +}; + +/* This array maps the GPIO pins used as INTERRUPT INPUTS */ + +static const uint32_t g_gpiointinputs[BOARD_NGPIOINT] = +{ + GPIO_IRQPIN1, +}; + +static struct esp32s3gpint_dev_s g_gpint[BOARD_NGPIOINT]; +#endif + +/* This array maps the GPIO pins used as Dedicated GPIO */ + +#ifdef CONFIG_ESPRESSIF_DEDICATED_GPIO +static const int g_gpioidedic[GPIO_DEDIC_COUNT] = +{ + GPIO_DEDIC1, GPIO_DEDIC2 +}; + +static struct esp_dedic_gpio_flags_s dedic_gpio_flags = +{ + .input_enable = 1, + .invert_input_enable = 0, + .output_enable = 1, + .invert_output_enable = 0 +}; + +struct esp_dedic_gpio_config_s dedic_gpio_conf = +{ + .gpio_array = g_gpioidedic, + .array_size = GPIO_DEDIC_COUNT, + .flags = &dedic_gpio_flags, + .path = "/dev/dedic_gpio0" +}; + +struct file *dedicated_gpio = NULL; +#endif + +#ifdef CONFIG_ESPRESSIF_USE_ULP_RISCV_CORE +static const struct gpio_operations_s gprtc_ops = +{ + .go_read = gprtc_read, + .go_write = gprtc_write, + .go_attach = NULL, + .go_enable = NULL, + .go_setpintype = NULL, +}; + +/* This array maps the GPIO pins used as OUTPUT */ + +static const uint32_t g_gpiortc[GPIO_RTC_COUNT] = +{ + GPIO_RTC1 +}; + +static struct esp32s3gpio_dev_s g_gprtc[GPIO_RTC_COUNT]; +#endif + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +#ifdef CONFIG_ESPRESSIF_USE_ULP_RISCV_CORE +/**************************************************************************** + * Name: gprtc_read + * + * Description: + * Read a RTC digital output pin. + * + * Parameters: + * dev - A pointer to the gpio driver struct. + * value - A pointer to store the state of the pin. + * + * Returned Value: + * Zero (OK). + * + ****************************************************************************/ + +static int gprtc_read(struct gpio_dev_s *dev, bool *value) +{ + struct esp32s3gpio_dev_s *espgpio = (struct esp32s3gpio_dev_s *)dev; + + DEBUGASSERT(espgpio != NULL && value != NULL); + gpioinfo("Reading...\n"); + + *value = esp32s3_rtcioread(g_gpiortc[espgpio->id]); + return OK; +} + +/**************************************************************************** + * Name: gprtc_write + * + * Description: + * Write to a RTC digital output pin. + * + * Parameters: + * dev - A pointer to the gpio driver struct. + * value - The value to be written. + * + * Returned Value: + * Zero (OK). + * + ****************************************************************************/ + +static int gprtc_write(struct gpio_dev_s *dev, bool value) +{ + struct esp32s3gpio_dev_s *espgpio = (struct esp32s3gpio_dev_s *)dev; + + DEBUGASSERT(espgpio != NULL); + gpioinfo("Writing %d\n", (int)value); + + esp32s3_rtciowrite(g_gpiortc[espgpio->id], value); + return OK; +} +#endif + +/**************************************************************************** + * Name: gpout_read + ****************************************************************************/ + +#if BOARD_NGPIOOUT > 0 +static int gpout_read(struct gpio_dev_s *dev, bool *value) +{ + struct esp32s3gpio_dev_s *esp32s3gpio = (struct esp32s3gpio_dev_s *)dev; + + DEBUGASSERT(esp32s3gpio != NULL && value != NULL); + DEBUGASSERT(esp32s3gpio->id < BOARD_NGPIOOUT); + gpioinfo("Reading...\n"); + + *value = esp32s3_gpioread(g_gpiooutputs[esp32s3gpio->id]); + return OK; +} + +/**************************************************************************** + * Name: gpout_write + ****************************************************************************/ + +static int gpout_write(struct gpio_dev_s *dev, bool value) +{ + struct esp32s3gpio_dev_s *esp32s3gpio = (struct esp32s3gpio_dev_s *)dev; + + DEBUGASSERT(esp32s3gpio != NULL); + DEBUGASSERT(esp32s3gpio->id < BOARD_NGPIOOUT); + gpioinfo("Writing %d\n", (int)value); + + esp32s3_gpiowrite(g_gpiooutputs[esp32s3gpio->id], value); + return OK; +} +#endif + +/**************************************************************************** + * Name: gpin_read + ****************************************************************************/ + +#if BOARD_NGPIOIN > 0 +static int gpin_read(struct gpio_dev_s *dev, bool *value) +{ + struct esp32s3gpio_dev_s *esp32s3gpio = (struct esp32s3gpio_dev_s *)dev; + + DEBUGASSERT(esp32s3gpio != NULL && value != NULL); + DEBUGASSERT(esp32s3gpio->id < BOARD_NGPIOIN); + gpioinfo("Reading... pin %" PRIu32 "\n", g_gpioinputs[esp32s3gpio->id]); + + *value = esp32s3_gpioread(g_gpioinputs[esp32s3gpio->id]); + return OK; +} +#endif + +/**************************************************************************** + * Name: esp32s3gpio_interrupt + ****************************************************************************/ + +#if BOARD_NGPIOINT > 0 +static int esp32s3gpio_interrupt(int irq, void *context, void *arg) +{ + struct esp32s3gpint_dev_s *esp32s3gpint = (struct esp32s3gpint_dev_s *)arg; + + DEBUGASSERT(esp32s3gpint != NULL && esp32s3gpint->callback != NULL); + gpioinfo("Interrupt! callback=%p\n", esp32s3gpint->callback); + + esp32s3gpint->callback(&esp32s3gpint->esp32s3gpio.gpio, + esp32s3gpint->esp32s3gpio.id); + return OK; +} + +/**************************************************************************** + * Name: gpint_read + ****************************************************************************/ + +static int gpint_read(struct gpio_dev_s *dev, bool *value) +{ + struct esp32s3gpint_dev_s *esp32s3gpint = (struct esp32s3gpint_dev_s *)dev; + + DEBUGASSERT(esp32s3gpint != NULL && value != NULL); + DEBUGASSERT(esp32s3gpint->esp32s3gpio.id < BOARD_NGPIOINT); + gpioinfo("Reading int pin...\n"); + + *value = esp32s3_gpioread(g_gpiointinputs[esp32s3gpint->esp32s3gpio.id]); + return OK; +} + +/**************************************************************************** + * Name: gpint_attach + ****************************************************************************/ + +static int gpint_attach(struct gpio_dev_s *dev, + pin_interrupt_t callback) +{ + struct esp32s3gpint_dev_s *esp32s3gpint = + (struct esp32s3gpint_dev_s *)dev; + int irq = ESP32S3_PIN2IRQ(g_gpiointinputs[esp32s3gpint->esp32s3gpio.id]); + int ret; + + gpioinfo("Attaching the callback\n"); + + /* Make sure the interrupt is disabled */ + + esp32s3_gpioirqdisable(irq); + ret = irq_attach(irq, + esp32s3gpio_interrupt, + &g_gpint[esp32s3gpint->esp32s3gpio.id]); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: gpint_attach() failed: %d\n", ret); + return ret; + } + + gpioinfo("Attach %p\n", callback); + esp32s3gpint->callback = callback; + return OK; +} + +/**************************************************************************** + * Name: gpint_enable + ****************************************************************************/ + +static int gpint_enable(struct gpio_dev_s *dev, bool enable) +{ + struct esp32s3gpint_dev_s *esp32s3gpint = (struct esp32s3gpint_dev_s *)dev; + int irq = ESP32S3_PIN2IRQ(g_gpiointinputs[esp32s3gpint->esp32s3gpio.id]); + + if (enable) + { + if (esp32s3gpint->callback != NULL) + { + gpioinfo("Enabling the interrupt\n"); + + /* Configure the interrupt for rising edge */ + + esp32s3_gpioirqenable(irq, RISING); + } + } + else + { + gpioinfo("Disable the interrupt\n"); + esp32s3_gpioirqdisable(irq); + } + + return OK; +} +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: esp32s3_gpio_init + ****************************************************************************/ + +int esp32s3_gpio_init(void) +{ + int pincount = 0; + int i; + +#if BOARD_NGPIOOUT > 0 + for (i = 0; i < BOARD_NGPIOOUT; i++) + { + /* Setup and register the GPIO pin */ + + g_gpout[i].gpio.gp_pintype = GPIO_OUTPUT_PIN; + g_gpout[i].gpio.gp_ops = &gpout_ops; + g_gpout[i].id = i; + gpio_pin_register(&g_gpout[i].gpio, pincount); + + /* Configure the pins that will be used as output */ + + esp32s3_gpio_matrix_out(g_gpiooutputs[i], SIG_GPIO_OUT_IDX, 0, 0); + esp32s3_configgpio(g_gpiooutputs[i], OUTPUT_FUNCTION_2 | + INPUT_FUNCTION_2); + esp32s3_gpiowrite(g_gpiooutputs[i], 0); + + pincount++; + } +#endif + +#if BOARD_NGPIOIN > 0 + for (i = 0; i < BOARD_NGPIOIN; i++) + { + /* Setup and register the GPIO pin */ + + g_gpin[i].gpio.gp_pintype = GPIO_INPUT_PIN; + g_gpin[i].gpio.gp_ops = &gpin_ops; + g_gpin[i].id = i; + gpio_pin_register(&g_gpin[i].gpio, pincount); + + /* Configure the pins that will be used as INPUT */ + + esp32s3_configgpio(g_gpioinputs[i], INPUT_FUNCTION_2); + + pincount++; + } +#endif + +#if BOARD_NGPIOINT > 0 + for (i = 0; i < BOARD_NGPIOINT; i++) + { + /* Setup and register the GPIO pin */ + + g_gpint[i].esp32s3gpio.gpio.gp_pintype = GPIO_INTERRUPT_PIN; + g_gpint[i].esp32s3gpio.gpio.gp_ops = &gpint_ops; + g_gpint[i].esp32s3gpio.id = i; + gpio_pin_register(&g_gpint[i].esp32s3gpio.gpio, pincount); + + /* Configure the pins that will be used as interrupt input */ + + esp32s3_configgpio(g_gpiointinputs[i], INPUT_FUNCTION_2 | PULLDOWN); + + pincount++; + } +#endif + +#ifdef CONFIG_ESPRESSIF_DEDICATED_GPIO + dedicated_gpio = esp_dedic_gpio_new_bundle(&dedic_gpio_conf); + + pincount++; +#endif + +#ifdef CONFIG_ESPRESSIF_USE_ULP_RISCV_CORE + for (i = 0; i < GPIO_RTC_COUNT; i++) + { + /* Setup and register the GPIO pin */ + + g_gprtc[i].gpio.gp_pintype = GPIO_OUTPUT_PIN; + g_gprtc[i].gpio.gp_ops = &gprtc_ops; + g_gprtc[i].id = i; + gpio_pin_register(&g_gprtc[i].gpio, pincount); + + /* Configure the pins that will be used as input/output */ + + esp32s3_configrtcio(g_gpiortc[i], RTC_INPUT | RTC_OUTPUT); + pincount++; + } +#endif + + return OK; +} +#endif /* CONFIG_DEV_GPIO && !CONFIG_GPIO_LOWER_HALF */ diff --git a/boards/xtensa/esp32s3/esp32s3-ws-lcd128/src/esp32s3_reset.c b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/src/esp32s3_reset.c new file mode 100644 index 0000000000000..460a2ff172fbc --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/src/esp32s3_reset.c @@ -0,0 +1,87 @@ +/**************************************************************************** + * boards/xtensa/esp32s3/esp32s3-ws-lcd128/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 + +#include +#include +#include +#include +#include + +#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 */