diff --git a/boards/Kconfig b/boards/Kconfig index c839947baba..65a8b19ea97 100644 --- a/boards/Kconfig +++ b/boards/Kconfig @@ -439,6 +439,24 @@ config ARCH_BOARD_ESP32S3_EYE featuring the ESP32-S3 CPU with a 2-Megapixel camera, an LCD display, a microphone, an 8 MB Octal PSRAM and an 8 MB flash. +config ARCH_BOARD_ESP32S3_LCD_EV + bool "Espressif ESP32-S3-LCD-EV Board" + depends on ARCH_CHIP_ESP32S3WROOM2 + select ARCH_HAVE_LEDS + select ARCH_HAVE_BUTTONS + select ARCH_HAVE_IRQBUTTONS if ESP32S3_GPIO_IRQ + ---help--- + ESP32-S3-LCD-EV is an ESP32-S3-based development board with a touchscreen. + Together with different subboards, ESP32-S3-LCD-EV-Board can drive LCDs with IIC, + SPI, 8080, and RGB interfaces. + It houses dual array microphones, supports voice recognition and near/far-field + voice wake-up, and features screen and voice interaction. + The board caters to development needs for touchscreen products with different resolutions + and interfaces. Currently, we have two boards available: + + 1. ESP32-S3-LCD-EV-Board with 480x480 LCD + 2. ESP32-S3-LCD-EV-Board with 800x480 LCD + config ARCH_BOARD_ESP32S3_MEADOW bool "WildernessLabs ESP32S3-Meadow Board" depends on ARCH_CHIP_ESP32S3WROOM1 @@ -2955,6 +2973,7 @@ config ARCH_BOARD default "esp32s3-devkit" if ARCH_BOARD_ESP32S3_DEVKIT default "esp32s3-eye" if ARCH_BOARD_ESP32S3_EYE default "esp32s3-meadow" if ARCH_BOARD_ESP32S3_MEADOW + default "esp32s3-lcd-ev" if ARCH_BOARD_ESP32S3_LCD_EV default "esp32c6-devkit" if ARCH_BOARD_ESP32C6_DEVKIT default "esp32c6-generic" if ARCH_BOARD_ESP32C6_GENERIC default "esp32h2-generic" if ARCH_BOARD_ESP32H2_GENERIC @@ -3995,6 +4014,9 @@ endif if ARCH_BOARD_ESP32S3_MEADOW source "boards/xtensa/esp32s3/esp32s3-meadow/Kconfig" endif +if ARCH_BOARD_ESP32S3_LCD_EV +source "boards/xtensa/esp32s3/esp32s3-lcd-ev/Kconfig" +endif if ARCH_BOARD_ESP32C6_DEVKIT source "boards/risc-v/esp32c6/esp32c6-devkit/Kconfig" endif diff --git a/boards/xtensa/esp32s3/esp32s3-lcd-ev/Kconfig b/boards/xtensa/esp32s3/esp32s3-lcd-ev/Kconfig new file mode 100644 index 00000000000..015a5a087ff --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-lcd-ev/Kconfig @@ -0,0 +1,52 @@ +# +# 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_LCD_EV + +config ESP32S3_STORAGE_MTD_OFFSET + hex "Storage MTD base address in SPI Flash" + default 0x180000 if !ESP32S3_HAVE_OTA_PARTITION + default 0x250000 if ESP32S3_HAVE_OTA_PARTITION + depends on ESP32S3_MTD + ---help--- + MTD base address in SPI Flash. + +config ESP32S3_STORAGE_MTD_SIZE + hex "Storage MTD size in SPI Flash" + default 0x100000 + depends on ESP32S3_MTD + ---help--- + MTD size in SPI Flash. + +choice ESP32S3_SPIFLASH_FS + prompt "Mount SPI Flash MTD on bring-up" + default ESP32S3_SPIFLASH_SMARTFS + depends on ESP32S3_MTD + optional + ---help--- + Mount the SPI Flash MTD with the selected File System format on board + bring-up. + If not selected, the MTD will be registered as a device node on /dev. + +config ESP32S3_SPIFLASH_SMARTFS + bool "SmartFS" + select FS_SMARTFS + select MTD_SMART + +config ESP32S3_SPIFLASH_NXFFS + bool "NXFFS" + select FS_NXFFS + +config ESP32S3_SPIFLASH_SPIFFS + bool "SPIFFS" + select FS_SPIFFS + +config ESP32S3_SPIFLASH_LITTLEFS + bool "LittleFS" + select FS_LITTLEFS + +endchoice # ESP32S3_SPIFLASH_FS + +endif # ARCH_BOARD_ESP32S3_LCD_EV diff --git a/boards/xtensa/esp32s3/esp32s3-lcd-ev/configs/buttons/defconfig b/boards/xtensa/esp32s3/esp32s3-lcd-ev/configs/buttons/defconfig new file mode 100644 index 00000000000..e10a973fe22 --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-lcd-ev/configs/buttons/defconfig @@ -0,0 +1,57 @@ +# +# 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-lcd-ev" +CONFIG_ARCH_BOARD_COMMON=y +CONFIG_ARCH_BOARD_ESP32S3_LCD_EV=y +CONFIG_ARCH_BUTTONS=y +CONFIG_ARCH_CHIP="esp32s3" +CONFIG_ARCH_CHIP_ESP32S3=y +CONFIG_ARCH_CHIP_ESP32S3WROOM2=y +CONFIG_ARCH_INTERRUPTSTACK=2048 +CONFIG_ARCH_IRQBUTTONS=y +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_GPIO_IRQ=y +CONFIG_ESP32S3_UART0=y +CONFIG_EXAMPLES_BUTTONS=y +CONFIG_EXAMPLES_BUTTONS_NAME0="BOOT" +CONFIG_EXAMPLES_BUTTONS_NAMES=y +CONFIG_EXAMPLES_BUTTONS_QTD=1 +CONFIG_FS_PROCFS=y +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +CONFIG_IDLETHREAD_STACKSIZE=3072 +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INPUT=y +CONFIG_INPUT_BUTTONS=y +CONFIG_INPUT_BUTTONS_LOWER=y +CONFIG_INTELHEX_BINARY=y +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_LINELEN=64 +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 diff --git a/boards/xtensa/esp32s3/esp32s3-lcd-ev/configs/nsh/defconfig b/boards/xtensa/esp32s3/esp32s3-lcd-ev/configs/nsh/defconfig new file mode 100644 index 00000000000..670a193ebdf --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-lcd-ev/configs/nsh/defconfig @@ -0,0 +1,47 @@ +# +# 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-lcd-ev" +CONFIG_ARCH_BOARD_COMMON=y +CONFIG_ARCH_BOARD_ESP32S3_LCD_EV=y +CONFIG_ARCH_CHIP="esp32s3" +CONFIG_ARCH_CHIP_ESP32S3=y +CONFIG_ARCH_CHIP_ESP32S3WROOM2=y +CONFIG_ARCH_INTERRUPTSTACK=2048 +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_UART0=y +CONFIG_FS_PROCFS=y +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +CONFIG_IDLETHREAD_STACKSIZE=3072 +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INTELHEX_BINARY=y +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_LINELEN=64 +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 diff --git a/boards/xtensa/esp32s3/esp32s3-lcd-ev/configs/ws2812/defconfig b/boards/xtensa/esp32s3/esp32s3-lcd-ev/configs/ws2812/defconfig new file mode 100644 index 00000000000..fee37ab2c32 --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-lcd-ev/configs/ws2812/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_NSH_ARGCAT is not set +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +CONFIG_ARCH="xtensa" +CONFIG_ARCH_BOARD="esp32s3-lcd-ev" +CONFIG_ARCH_BOARD_COMMON=y +CONFIG_ARCH_BOARD_ESP32S3_LCD_EV=y +CONFIG_ARCH_CHIP="esp32s3" +CONFIG_ARCH_CHIP_ESP32S3=y +CONFIG_ARCH_CHIP_ESP32S3WROOM2=y +CONFIG_ARCH_INTERRUPTSTACK=2048 +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_SPI2=y +CONFIG_ESP32S3_SPI2_MOSIPIN=4 +CONFIG_ESP32S3_UART0=y +CONFIG_EXAMPLES_WS2812=y +CONFIG_FS_PROCFS=y +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +CONFIG_IDLETHREAD_STACKSIZE=3072 +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INTELHEX_BINARY=y +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_LINELEN=64 +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_WS2812=y +CONFIG_WS2812_FREQUENCY=8000000 diff --git a/boards/xtensa/esp32s3/esp32s3-lcd-ev/include/board.h b/boards/xtensa/esp32s3/esp32s3-lcd-ev/include/board.h new file mode 100644 index 00000000000..80348f585db --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-lcd-ev/include/board.h @@ -0,0 +1,40 @@ +/**************************************************************************** + * boards/xtensa/esp32s3/esp32s3-lcd-ev/include/board.h + * + * 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_LCD_EV_INCLUDE_BOARD_H +#define __BOARDS_XTENSA_ESP32S3_ESP32S3_LCD_EV_INCLUDE_BOARD_H + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Clocking *****************************************************************/ + +/* The ESP32-S3-LCD-EV 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 + +#endif /* __BOARDS_XTENSA_ESP32S3_ESP32S3_LCD_EV_INCLUDE_BOARD_H */ diff --git a/boards/xtensa/esp32s3/esp32s3-lcd-ev/include/board_memorymap.h b/boards/xtensa/esp32s3/esp32s3-lcd-ev/include/board_memorymap.h new file mode 100644 index 00000000000..41113ac2385 --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-lcd-ev/include/board_memorymap.h @@ -0,0 +1,116 @@ +/**************************************************************************** + * boards/xtensa/esp32s3/esp32s3-lcd-ev/include/board_memorymap.h + * + * 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_LCD_EV_INCLUDE_BOARD_MEMORYMAP_H +#define __BOARDS_XTENSA_ESP32S3_ESP32S3_LCD_EV_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_LCD_EV_INCLUDE_BOARD_MEMORYMAP_H */ diff --git a/boards/xtensa/esp32s3/esp32s3-lcd-ev/scripts/Make.defs b/boards/xtensa/esp32s3/esp32s3-lcd-ev/scripts/Make.defs new file mode 100644 index 00000000000..e35a09b9996 --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-lcd-ev/scripts/Make.defs @@ -0,0 +1,72 @@ +############################################################################ +# boards/xtensa/esp32s3/esp32s3-lcd-ev/scripts/Make.defs +# +# 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.ld +ARCHSCRIPT += $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)esp32s3_rom_api.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) + ifeq ($(CONFIG_ESP32S3_APP_FORMAT_MCUBOOT),y) + ARCHSCRIPT += $(call FINDSCRIPT,mcuboot_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) -pipe +CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) +CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe +CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) +CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) +AFLAGS := $(CFLAGS) -D__ASSEMBLY__ + +# Loadable module definitions + +CMODULEFLAGS = $(CFLAGS) -mtext-section-literals + +LDMODULEFLAGS = -r -e module_initialize +LDMODULEFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld) + +# ELF module definitions + +CELFFLAGS = $(CFLAGS) -mtext-section-literals +CXXELFFLAGS = $(CXXFLAGS) -mtext-section-literals + +LDELFFLAGS = -r -e main +LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/libelf/gnu-elf.ld) diff --git a/boards/xtensa/esp32s3/esp32s3-lcd-ev/src/Make.defs b/boards/xtensa/esp32s3/esp32s3-lcd-ev/src/Make.defs new file mode 100644 index 00000000000..586a3324e18 --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-lcd-ev/src/Make.defs @@ -0,0 +1,47 @@ +############################################################################ +# boards/xtensa/esp32s3/esp32s3-lcd-ev/src/Make.defs +# +# 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)/Make.defs + +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_ESP32S3_SPI),y) +CSRCS += esp32s3_board_spi.c +endif + +ifeq ($(CONFIG_WS2812),y) +CSRCS += esp32s3_ws2812.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-lcd-ev/src/esp32s3-lcd-ev.h b/boards/xtensa/esp32s3/esp32s3-lcd-ev/src/esp32s3-lcd-ev.h new file mode 100644 index 00000000000..138cd63211b --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-lcd-ev/src/esp32s3-lcd-ev.h @@ -0,0 +1,98 @@ +/**************************************************************************** + * boards/xtensa/esp32s3/esp32s3-lcd-ev/src/esp32s3-lcd-ev.h + * + * 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_LCD_EV_SRC_ESP32S3_LCD_EV_H +#define __BOARDS_XTENSA_ESP32S3_ESP32S3_LCD_EV_SRC_ESP32S3_LCD_EV_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* ESP32-S3-LCD-EV GPIOs ****************************************************/ + +/* BOOT Button */ + +#define BUTTON_BOOT 0 + +/**************************************************************************** + * 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: board_spiflash_init + * + * Description: + * Initialize the SPIFLASH and register the MTD device. + * + ****************************************************************************/ + +#ifdef CONFIG_ESP32S3_SPIFLASH +int board_spiflash_init(void); +#endif + +/**************************************************************************** + * Name: board_ws2812_initialize + * + * Description: + * This function may called from application-specific logic during its + * to perform board-specific initialization of the ws2812 device + * + ****************************************************************************/ + +#if defined(CONFIG_WS2812) && !defined(CONFIG_WS2812_NON_SPI_DRIVER) +int board_ws2812_initialize(int devno, int spino, uint16_t nleds); +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __BOARDS_XTENSA_ESP32S3_ESP32S3_LCD_EV_SRC_ESP32S3_LCD_EV_H */ diff --git a/boards/xtensa/esp32s3/esp32s3-lcd-ev/src/esp32s3_appinit.c b/boards/xtensa/esp32s3/esp32s3-lcd-ev/src/esp32s3_appinit.c new file mode 100644 index 00000000000..8cc32d7b92d --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-lcd-ev/src/esp32s3_appinit.c @@ -0,0 +1,80 @@ +/**************************************************************************** + * boards/xtensa/esp32s3/esp32s3-lcd-ev/src/esp32s3_appinit.c + * + * 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-lcd-ev.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-lcd-ev/src/esp32s3_board_spi.c b/boards/xtensa/esp32s3/esp32s3-lcd-ev/src/esp32s3_board_spi.c new file mode 100644 index 00000000000..58dec78a3ec --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-lcd-ev/src/esp32s3_board_spi.c @@ -0,0 +1,126 @@ +/**************************************************************************** + * boards/xtensa/esp32s3/esp32s3-lcd-ev/src/esp32s3_board_spi.c + * + * 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_gpio.h" +#include "esp32s3-lcd-ev.h" + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: esp32s3_spi2_status + ****************************************************************************/ + +#ifdef CONFIG_ESP32S3_SPI2 + +uint8_t esp32s3_spi2_status(struct spi_dev_s *dev, uint32_t devid) +{ + uint8_t status = 0; + + return status; +} + +#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) +{ + if (devid == SPIDEV_DISPLAY(0)) + { + /* This is the Data/Command control pad which determines whether the + * data bits are data or a command. + */ + + esp32s3_gpiowrite(GPIO_LCD_DC, !cmd); + + return OK; + } + + spiinfo("devid: %" PRIu32 " CMD: %s\n", devid, cmd ? "command" : + "data"); + + return -ENODEV; +} + +#endif + +/**************************************************************************** + * Name: esp32s3_spi3_status + ****************************************************************************/ + +#ifdef CONFIG_ESP32S3_SPI3 + +uint8_t esp32s3_spi3_status(struct spi_dev_s *dev, uint32_t devid) +{ + uint8_t status = 0; + + return status; +} + +#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) +{ + if (devid == SPIDEV_DISPLAY(0)) + { + /* This is the Data/Command control pad which determines whether the + * data bits are data or a command. + */ + + esp32s3_gpiowrite(CONFIG_ESP32S3_SPI3_MISOPIN, !cmd); + + return OK; + } + + spiinfo("devid: %" PRIu32 " CMD: %s\n", devid, cmd ? "command" : + "data"); + + return -ENODEV; +} + +#endif diff --git a/boards/xtensa/esp32s3/esp32s3-lcd-ev/src/esp32s3_boot.c b/boards/xtensa/esp32s3/esp32s3-lcd-ev/src/esp32s3_boot.c new file mode 100644 index 00000000000..7e44fa9e45d --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-lcd-ev/src/esp32s3_boot.c @@ -0,0 +1,83 @@ +/**************************************************************************** + * boards/xtensa/esp32s3/esp32s3-lcd-ev/src/esp32s3_boot.c + * + * 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-lcd-ev.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-lcd-ev/src/esp32s3_bringup.c b/boards/xtensa/esp32s3/esp32s3-lcd-ev/src/esp32s3_bringup.c new file mode 100644 index 00000000000..a3427b897ce --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-lcd-ev/src/esp32s3_bringup.c @@ -0,0 +1,235 @@ +/**************************************************************************** + * boards/xtensa/esp32s3/esp32s3-lcd-ev/src/esp32s3_bringup.c + * + * 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 + +#ifdef CONFIG_ESP32S3_TIMER +# include "esp32s3_board_tim.h" +#endif + +#ifdef CONFIG_ESP32S3_WIFI +# include "esp32s3_board_wlan.h" +#endif + +#ifdef CONFIG_ESP32S3_BLE +# include "esp32s3_ble.h" +#endif + +#ifdef CONFIG_ESP32S3_WIFI_BT_COEXIST +# include "esp32s3_wifi_adapter.h" +#endif + +#ifdef CONFIG_ESP32S3_RT_TIMER +# include "esp32s3_rt_timer.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_ESP32S3_EFUSE +# include "esp32s3_efuse.h" +#endif + +#ifdef CONFIG_ESP32S3_SPI +# include "esp32s3_spi.h" +#endif + +#include "esp32s3-lcd-ev.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; + +#if defined(CONFIG_ESP32S3_EFUSE) + ret = esp32s3_efuse_initialize("/dev/efuse"); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to init EFUSE: %d\n", ret); + } +#endif + +#ifdef CONFIG_FS_PROCFS + /* Mount the procfs file system */ + + ret = nx_mount(NULL, "/proc", "procfs", 0, NULL); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret); + } +#endif + +#ifdef CONFIG_FS_TMPFS + /* Mount the tmpfs file system */ + + ret = nx_mount(NULL, CONFIG_LIBC_TMPDIR, "tmpfs", 0, NULL); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to mount tmpfs at %s: %d\n", + CONFIG_LIBC_TMPDIR, ret); + } +#endif + +#ifdef CONFIG_ESP32S3_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_RT_TIMER + ret = esp32s3_rt_timer_init(); + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize RT timer: %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_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_ESP32S3_SPIFLASH + ret = board_spiflash_init(); + if (ret) + { + syslog(LOG_ERR, "ERROR: Failed to initialize SPI Flash\n"); + } +#endif + +#ifdef CONFIG_ESP32S3_WIRELESS + +#ifdef CONFIG_ESP32S3_WIFI_BT_COEXIST + ret = esp32s3_wifi_bt_coexist_init(); + if (ret) + { + syslog(LOG_ERR, "ERROR: Failed to initialize Wi-Fi and BT coexist\n"); + } +#endif + +#ifdef CONFIG_ESP32S3_BLE + ret = esp32s3_ble_initialize(); + if (ret) + { + syslog(LOG_ERR, "ERROR: Failed to initialize BLE\n"); + } +#endif + +#ifdef CONFIG_ESP32S3_WIFI + ret = board_wlan_init(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to initialize wireless subsystem=%d\n", + ret); + } +#endif + +#endif + +#if defined(CONFIG_WS2812) && !defined(CONFIG_WS2812_NON_SPI_DRIVER) + ret = board_ws2812_initialize(0, ESP32S3_SPI2, CONFIG_WS2812_LED_COUNT); + if (ret < 0) + { + syslog(LOG_ERR, "Failed to initialize ws2812 driver\n"); + } +#endif + + /* If we got here then perhaps not all initialization was successful, but + * at least enough succeeded to bring-up NSH with perhaps reduced + * capabilities. + */ + + UNUSED(ret); + return OK; +} diff --git a/boards/xtensa/esp32s3/esp32s3-lcd-ev/src/esp32s3_buttons.c b/boards/xtensa/esp32s3/esp32s3-lcd-ev/src/esp32s3_buttons.c new file mode 100644 index 00000000000..40be204ba29 --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-lcd-ev/src/esp32s3_buttons.c @@ -0,0 +1,164 @@ +/**************************************************************************** + * boards/xtensa/esp32s3/esp32s3-lcd-ev/src/esp32s3_buttons.c + * + * 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-lcd-ev.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, GPIO_INTR_ANYEDGE); + } + else + { + gpioinfo("Disable the interrupt\n"); + esp32s3_gpioirqdisable(irq); + } + + return OK; +} +#endif diff --git a/boards/xtensa/esp32s3/esp32s3-lcd-ev/src/esp32s3_reset.c b/boards/xtensa/esp32s3/esp32s3-lcd-ev/src/esp32s3_reset.c new file mode 100644 index 00000000000..cc36f068c78 --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-lcd-ev/src/esp32s3_reset.c @@ -0,0 +1,85 @@ +/**************************************************************************** + * boards/xtensa/esp32s3/esp32s3-lcd-ev/src/esp32s3_reset.c + * + * 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 */ diff --git a/boards/xtensa/esp32s3/esp32s3-lcd-ev/src/esp32s3_ws2812.c b/boards/xtensa/esp32s3/esp32s3-lcd-ev/src/esp32s3_ws2812.c new file mode 100644 index 00000000000..66fe9eb1329 --- /dev/null +++ b/boards/xtensa/esp32s3/esp32s3-lcd-ev/src/esp32s3_ws2812.c @@ -0,0 +1,116 @@ +/**************************************************************************** + * boards/xtensa/esp32s3/esp32s3-lcd-ev/src/esp32s3_ws2812.c + * + * 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 "xtensa.h" +#include "esp32s3_spi.h" + +#include +#include +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define APB_PERIOD (12.5) + +#define T0H ((uint16_t)(350 / APB_PERIOD)) // ns +#define T0L ((uint16_t)(900 / APB_PERIOD)) // ns +#define T1H ((uint16_t)(900 / APB_PERIOD)) // ns +#define T1L ((uint16_t)(350 / APB_PERIOD)) // ns +#define RES ((uint16_t)(60000 / APB_PERIOD)) // ns + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +#ifndef CONFIG_WS2812_NON_SPI_DRIVER +/**************************************************************************** + * Name: board_ws2812_initialize + * + * Description: + * Initialize and register the WS2812 LED driver. + * + * Input Parameters: + * devno - The device number, used to build the device path as /dev/leddrvN + * spino - SPI port number + * nleds - number of LEDs + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +int board_ws2812_initialize(int devno, int spino, uint16_t nleds) +{ + struct spi_dev_s *spi; + char devpath[13]; + int ret; + + spi = esp32s3_spibus_initialize(spino); + if (spi == NULL) + { + return -ENODEV; + } + + /* Register the WS2812 driver at the specified location. */ + + snprintf(devpath, sizeof(devpath), "/dev/leds%d", devno); + ret = ws2812_leds_register(devpath, spi, nleds); + if (ret < 0) + { + lederr("ERROR: ws2812_leds_register(%s) failed: %d\n", + devpath, ret); + return ret; + } + + return OK; +} +#endif