mirror of
https://github.com/apache/nuttx.git
synced 2026-05-20 20:44:39 +08:00
boards/xtensa: Added support for the ESP32-S2-Kaluga-1 board
This commit is contained in:
committed by
Gustavo Henrique Nihei
parent
ac893ffcfe
commit
22ce6e8a9c
BIN
Binary file not shown.
|
After Width: | Height: | Size: 3.5 MiB |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 101 KiB |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 4.6 MiB |
@@ -0,0 +1,184 @@
|
||||
==========================
|
||||
ESP32-S2-Kaluga-1 Kit v1.3
|
||||
==========================
|
||||
|
||||
The `ESP32-S2-Kaluga-1 kit v1.3 <https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/hw-reference/esp32s2/user-guide-esp32-s2-kaluga-1-kit.html>`_
|
||||
is a development kit by Espressif that is mainly created to:
|
||||
|
||||
- Demonstrate the ESP32-S2's human-computer interaction functionalities
|
||||
- Provide the users with the tools for development of human-computer interaction applications based on the ESP32-S2
|
||||
|
||||
There are many ways of how the ESP32-S2's abundant functionalities can be used. For starters, the possible use cases may include:
|
||||
|
||||
- **Smart home**: From simplest smart lighting, smart door locks, smart sockets, to video streaming devices, security cameras, OTT devices, and home appliances
|
||||
- **Battery-powered equipment**: Wi-Fi mesh sensor networks, Wi-Fi-networked toys, wearable devices, health management equipment
|
||||
- **Industrial automation equipment**: Wireless control and robot technology, intelligent lighting, HVAC control equipment, etc.
|
||||
- **Retail and catering industry**: POS machines and service robots
|
||||
|
||||
.. Image of v1.2 is used as there are no visual changes
|
||||
|
||||
.. figure:: esp32-s2-kaluga-1-kit-v1.0-3d.png
|
||||
:align: center
|
||||
:width: 3452px
|
||||
:height: 1590px
|
||||
:scale: 20%
|
||||
:alt: ESP32-S2-Kaluga-1-Kit-Assembly
|
||||
:figclass: align-center
|
||||
|
||||
ESP32-S2-Kaluga-1-Kit Overview (click to enlarge)
|
||||
|
||||
|
||||
The ESP32-S2-Kaluga-1 kit consists of the following boards:
|
||||
|
||||
- Main board: *ESP32-S2-Kaluga-1*
|
||||
- Extension boards:
|
||||
|
||||
- `ESP-LyraT-8311A <https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/hw-reference/esp32s2/user-guide-esp-lyrat-8311a_v1.3.html>`_ - Audio player
|
||||
- `ESP-LyraP-TouchA <https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/hw-reference/esp32s2/user-guide-esp-lyrap-toucha-v1.1.html>`_ - Touch buttons
|
||||
- `ESP-LyraP-LCD32 <https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/hw-reference/esp32s2/user-guide-esp-lyrap-lcd32-v1.2.html>`_ - 3.2" LCD screen
|
||||
- `ESP-LyraP-CAM <https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/hw-reference/esp32s2/user-guide-esp-lyrap-cam-v1.1.html>`_ - Camera module
|
||||
|
||||
.. Image of v1.2 is used as there are no visual changes
|
||||
|
||||
A block diagram below shows the components of the ESP32-S2-Kaluga-1 and their interconnections.
|
||||
|
||||
.. figure:: esp32-s2-kaluga-1-v1.2-block-diagram.png
|
||||
:align: center
|
||||
:alt: ESP32-S2-Kaluga-1 block diagram
|
||||
:figclass: align-center
|
||||
|
||||
ESP32-S2-Kaluga-1 block diagram
|
||||
|
||||
Features
|
||||
========
|
||||
|
||||
The ESP32-S2-Kaluga-1 main board is the heart of the kit. It integrates the
|
||||
ESP32-S2-WROVER module and all the connectors for extension boards. This board
|
||||
is the key tool in prototyping human-computer interaction interfaces.
|
||||
|
||||
The ESP32-S2-Kaluga-1 board has connectors for boards with:
|
||||
|
||||
- Extension header (ESP-LyraT-8311A, ESP-LyraP-LCD32)
|
||||
- Camera header (ESP-LyraP-CAM)
|
||||
- Touch FPC coneector (ESP-LyraP-TouchA)
|
||||
- LCD FPC connector (no official extension boards yet)
|
||||
- I2C FPC connector (no official extension boards yet)
|
||||
|
||||
.. figure:: esp32s2-kaluga-1-v1.3-3d.png
|
||||
:align: center
|
||||
:width: 3089px
|
||||
:height: 2335px
|
||||
:scale: 25%
|
||||
:alt: ESP32-S2-Kaluga-1
|
||||
:figclass: align-center
|
||||
|
||||
ESP32-S2-Kaluga-1 (click to enlarge)
|
||||
|
||||
All the four extension boards are specially desgined to support the following
|
||||
features:
|
||||
|
||||
* Touch panel control
|
||||
* Six touch buttons
|
||||
* Supports acrylic panels up to 5 mm
|
||||
* Wet hand operation
|
||||
* Water rejection, ESP32-S2 can be configured to disable all touchpads
|
||||
automatically if multiple pads are simultaneously covered with water
|
||||
and to re-enable touchpads if the water is removed
|
||||
|
||||
* Audio playback
|
||||
* Connect speakers to play audio
|
||||
* Use together with the Touch panel to control audio playback and adjust volume
|
||||
|
||||
* LCD display
|
||||
* LCD interface (8-bit parallel RGB, 8080, and 6800 interface)
|
||||
|
||||
* Camera image acquisition
|
||||
* Supports OV2640 and OV3660 camera modules
|
||||
* 8-bit DVP image sensor interface (ESP32-S2 also supports 16-bit DVP image sensors, you can design it yourself)
|
||||
* Clock frequency up to 40 MHz
|
||||
* Optimized DMA transmission bandwidth for easier transmission of high-resolution images
|
||||
|
||||
Compatibility of Extension Boards
|
||||
---------------------------------
|
||||
|
||||
If you want to use more than one extension board at the same time, please check the table given below.
|
||||
|
||||
.. list-table::
|
||||
:widths: 20 15 33 32
|
||||
:header-rows: 1
|
||||
|
||||
* - Boards Used
|
||||
- HW Conflict
|
||||
- Limitations
|
||||
- Solution
|
||||
* - 8311A v1.3 + CAM v1.1
|
||||
- I2S Controller
|
||||
- ESP32-S2 has only one I2S interface. But both extension boards require connection via the ESP32-S2's I2S interface (LyraT-8311A in Standard mode, ESP-LyraP-CAM in Camera mode).
|
||||
- Utilize time division multiple access, or use a different audio module that can be connected via other GPIOs or DAC.
|
||||
* - TouchA v1.1 + LCD32 v1.2
|
||||
- IO11, IO6
|
||||
- Touch actions cannot be triggered because of the multiplexed pin IO11. ESP-LyraP-LCD32 will not be affected because its BLCT pin will be disconnected from IO6.
|
||||
- Do not initialize IO11 (NETWORK) for your ESP-LyraP-TouchA, or configure the BLCT pin to `-1` (= do not use BLCT) for your ESP-LyraP-LCD32.
|
||||
* - 8311A v1.3 + LCD32 v1.2
|
||||
- IO6
|
||||
- BLCT pin of ESP32-S2-Kaluga-1 will be disconnected from IO6.
|
||||
- Configure the BK pin to `-1` (= do not use BLCT) for your ESP-LyraP-LCD32.
|
||||
* - TouchA v1.1 + 8311A v1.3
|
||||
- Pin BT_ADC on ESP-LyraT-8311A
|
||||
- This pin is required for initialization of the six button on ESP-LyraT-8311A. At the same time, ESP-LyraP-TouchA needs this pin for its touch actions.
|
||||
- If you plan to use buttons on ESP-LyraT-8311A, do not initialize pin IO6 (PHOTO) for your ESP-LyraP-TouchA.
|
||||
* - TouchA v1.1 + CAM v1.1
|
||||
- IO1, IO2, IO3
|
||||
- Cannot be used simultaneously because of the mentioned multiplexed pins.
|
||||
- For ESP-LyraP-TouchA, do not initialize IO1 (VOL_UP), IO2 (PLAY), and IO3 (VOL_DOWN).
|
||||
* - TouchA v1.1 + LCD32 v1.2 + CAM v1.1
|
||||
- IO1, IO2, IO3, IO11
|
||||
- Conflicts on the mentioned multiplexed pins.
|
||||
- For ESP-LyraP-TouchA, do not initialize IO1 (VOL_UP), IO2 (PLAY), IO3 (VOL_DOWN), and IO11 (NETWORK).
|
||||
* - TouchA v1.1 + LCD32 v1.2 + 8311A v1.3
|
||||
- IO6, IO11
|
||||
- If ESP-LyraT-8311A's pin BT_ADC is used to initialize the board's six buttons, IO6 and IO11 will not be available for the other boards.
|
||||
- Do not initialize IO11 (NETWORK) for your ESP-LyraP-TouchA. Also, if you need to use BT_ADC, do not initialize IO6 (PHOTO).
|
||||
|
||||
Also, all extension boards and the JTAG interface share the same pins IO39, IO40, IO41 and IO42. For this reason, the following may disturb the JTAG operation:
|
||||
|
||||
* Plugging in any extension board
|
||||
* Debugging an application that is using an extension board
|
||||
|
||||
|
||||
Serial Console
|
||||
==============
|
||||
|
||||
UART0 is, by default, the serial console. It connects to the on-board
|
||||
CP2102 converter and is available on the micro-USB connector (J1).
|
||||
|
||||
It will show up as /dev/ttyUSB[n] where [n] will probably be 0.
|
||||
|
||||
Buttons and LEDs
|
||||
================
|
||||
|
||||
Buttons
|
||||
-------
|
||||
|
||||
There are two buttons labeled Boot and EN. The EN button is not available
|
||||
to the software. It pulls the chip enable line that doubles as a reset line.
|
||||
|
||||
The BOOT button is connected to IO0. On reset, it is used as a strapping
|
||||
pin to determine whether the chip boots normally or into the serial
|
||||
bootloader. After resetting, however, the BOOT button can be used for
|
||||
software input.
|
||||
|
||||
LEDs
|
||||
----
|
||||
|
||||
There are many on-board LEDs. The only one that can be controlled by software
|
||||
is a WS2812 RGB LED (U21) addressable LED and is driven by GPIO45.
|
||||
|
||||
Configurations
|
||||
==============
|
||||
|
||||
nsh
|
||||
---
|
||||
|
||||
Basic NuttShell configuration (console enabled in UART0, exposed via
|
||||
USB connection by means of CP2102 converter, at 115200 bps).
|
||||
@@ -326,6 +326,15 @@ config ARCH_BOARD_ESP32C3_DEVKIT_RUST1
|
||||
This board includes the ESP32-C3-MINI-1 module, a 6DoF IMU, a temperature
|
||||
and humidity sensor, a Li-Ion battery charger, and a Type-C USB.
|
||||
|
||||
config ARCH_BOARD_ESP32S2_KALUGA_1
|
||||
bool "Espressif ESP32-S2-Kaluga-1 V1.3"
|
||||
depends on ARCH_CHIP_ESP32S2WROVER
|
||||
select ARCH_HAVE_LEDS
|
||||
select ARCH_HAVE_BUTTONS
|
||||
select ARCH_HAVE_IRQBUTTONS if ESP32S2_GPIO_IRQ
|
||||
---help---
|
||||
This is the ESP32-S2-Kaluga-1 board
|
||||
|
||||
config ARCH_BOARD_ESP32S2_SAOLA_1
|
||||
bool "Espressif ESP32-S2-Saola-1 V1.2"
|
||||
depends on ARCH_CHIP_ESP32S2WROVER
|
||||
@@ -2653,6 +2662,7 @@ config ARCH_BOARD
|
||||
default "esp32-wrover-kit" if ARCH_BOARD_ESP32_WROVERKIT
|
||||
default "esp32c3-devkit" if ARCH_BOARD_ESP32C3_DEVKIT
|
||||
default "esp32c3-devkit-rust-1" if ARCH_BOARD_ESP32C3_DEVKIT_RUST1
|
||||
default "esp32s2-kaluga-1" if ARCH_BOARD_ESP32S2_KALUGA_1
|
||||
default "esp32s2-saola-1" if ARCH_BOARD_ESP32S2_SAOLA_1
|
||||
default "esp32s3-devkit" if ARCH_BOARD_ESP32S3_DEVKIT
|
||||
default "esp32s3-eye" if ARCH_BOARD_ESP32S3_EYE
|
||||
@@ -3606,6 +3616,9 @@ endif
|
||||
if ARCH_BOARD_ESP32C3_DEVKIT_RUST1
|
||||
source "boards/risc-v/esp32c3/esp32c3-devkit-rust-1/Kconfig"
|
||||
endif
|
||||
if ARCH_BOARD_ESP32S2_KALUGA_1
|
||||
source "boards/xtensa/esp32s2/esp32s2-kaluga-1/Kconfig"
|
||||
endif
|
||||
if ARCH_BOARD_ESP32S2_SAOLA_1
|
||||
source "boards/xtensa/esp32s2/esp32s2-saola-1/Kconfig"
|
||||
endif
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||
#
|
||||
|
||||
if ARCH_BOARD_ESP32S2_KALUGA_1
|
||||
|
||||
endif # ARCH_BOARD_ESP32S2_KALUGA_1
|
||||
@@ -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_NSH_ARGCAT is not set
|
||||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||
# CONFIG_NSH_CMDPARMS is not set
|
||||
CONFIG_ARCH="xtensa"
|
||||
CONFIG_ARCH_BOARD="esp32s2-kaluga-1"
|
||||
CONFIG_ARCH_BOARD_COMMON=y
|
||||
CONFIG_ARCH_BOARD_ESP32S2_KALUGA_1=y
|
||||
CONFIG_ARCH_CHIP="esp32s2"
|
||||
CONFIG_ARCH_CHIP_ESP32S2=y
|
||||
CONFIG_ARCH_CHIP_ESP32S2WROVER=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_ARCH_XTENSA=y
|
||||
CONFIG_BOARD_LOOPSPERMSEC=16717
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_ESP32S2_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_SYSTEM_NSH=y
|
||||
CONFIG_UART0_SERIAL_CONSOLE=y
|
||||
@@ -0,0 +1,58 @@
|
||||
/****************************************************************************
|
||||
* boards/xtensa/esp32s2/esp32s2-kaluga-1/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_ESP32S2_ESP32S2_KALUGA_1_INCLUDE_BOARD_H
|
||||
#define __BOARDS_XTENSA_ESP32S2_ESP32S2_KALUGA_1_INCLUDE_BOARD_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Clocking *****************************************************************/
|
||||
|
||||
/* The ESP32-S2-Kaluga-1 is fitted with a 40MHz crystal */
|
||||
|
||||
#define BOARD_XTAL_FREQUENCY 40000000
|
||||
|
||||
#ifdef CONFIG_ESP32S2_DEFAULT_CPU_FREQ_MHZ
|
||||
# define BOARD_CLOCK_FREQUENCY (CONFIG_ESP32S2_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 1
|
||||
|
||||
/* GPIO pins used by the GPIO Subsystem */
|
||||
|
||||
#define BOARD_NGPIOOUT 2 /* 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_ESP32S2_ESP32S2_KALUGA_1_INCLUDE_BOARD_H */
|
||||
@@ -0,0 +1,74 @@
|
||||
############################################################################
|
||||
# boards/xtensa/esp32s2/esp32s2-kaluga-1/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/esp32s2/Config.mk
|
||||
include $(TOPDIR)/arch/xtensa/src/lx7/Toolchain.defs
|
||||
|
||||
# Pick the linker scripts from the board level if they exist, if not
|
||||
# pick the common linker scripts.
|
||||
|
||||
ARCHSCRIPT += $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)esp32s2_rom.ld
|
||||
ARCHSCRIPT += $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)esp32s2_peripherals.ld
|
||||
|
||||
ifneq ($(wildcard $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32s2_memory.ld),)
|
||||
ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32s2_memory.ld
|
||||
else
|
||||
ARCHSCRIPT += $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)esp32s2_memory.ld
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ESP32S2_APP_FORMAT_MCUBOOT),y)
|
||||
ifneq ($(wildcard $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32s2_mcuboot.ld),)
|
||||
ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32s2_mcuboot.ld
|
||||
else
|
||||
ARCHSCRIPT += $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)esp32s2_mcuboot.ld
|
||||
endif
|
||||
else
|
||||
ifneq ($(wildcard $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32s2_sections.ld),)
|
||||
ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)esp32s2_sections.ld
|
||||
else
|
||||
ARCHSCRIPT += $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)esp32s2_sections.ld
|
||||
endif
|
||||
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)
|
||||
@@ -0,0 +1,51 @@
|
||||
############################################################################
|
||||
# boards/xtensa/esp32s2/esp32s2-kaluga-1/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 = esp32s2_boot.c esp32s2_bringup.c
|
||||
|
||||
ifeq ($(CONFIG_BOARDCTL),y)
|
||||
CSRCS += esp32s2_appinit.c
|
||||
ifeq ($(CONFIG_BOARDCTL_RESET),y)
|
||||
CSRCS += esp32s2_reset.c
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_DEV_GPIO),y)
|
||||
CSRCS += esp32s2_gpio.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ONESHOT),y)
|
||||
CSRCS += esp32s2_oneshot.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_I2C_DRIVER),y)
|
||||
CSRCS += esp32s2_board_i2c.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ESP32S2_SPI),y)
|
||||
CSRCS += esp32s2_board_spi.c
|
||||
endif
|
||||
|
||||
DEPPATH += --dep-path board
|
||||
VPATH += :board
|
||||
CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board)
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
/****************************************************************************
|
||||
* boards/xtensa/esp32s2/esp32s2-kaluga-1/src/esp32s2-kaluga-1.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_ESP32S2_ESP32S2_KALUGA_1_SRC_ESP32S2_KALUGA_1_H
|
||||
#define __BOARDS_XTENSA_ESP32S2_ESP32S2_KALUGA_1_SRC_ESP32S2_KALUGA_1_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/compiler.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* ESP32S2-DevKitC GPIOs ****************************************************/
|
||||
|
||||
/* BOOT Button */
|
||||
|
||||
#define BUTTON_BOOT 0
|
||||
|
||||
/* TIMERS */
|
||||
|
||||
#define TIMER0 0
|
||||
#define TIMER1 1
|
||||
#define TIMER2 2
|
||||
#define TIMER3 3
|
||||
|
||||
/* ONESHOT */
|
||||
|
||||
#define ONESHOT_TIMER TIMER0
|
||||
#define ONESHOT_RESOLUTION_US 1
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32s2_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 esp32s2_bringup(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32s2_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 esp32s2_gpio_init(void);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_oneshot_init
|
||||
*
|
||||
* Description:
|
||||
* Configure the oneshot timer driver.
|
||||
*
|
||||
* Input Parameters:
|
||||
* timer - Timer instance to be used as oneshot timer.
|
||||
* resolution - Oneshot timer resolution.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success; A negated errno value is returned
|
||||
* to indicate the nature of any failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ONESHOT
|
||||
int board_oneshot_init(int timer, uint16_t resolution);
|
||||
#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:
|
||||
* None.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero is returned on success. Otherwise, a negated errno value is
|
||||
* returned to indicate the nature of the failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_ESP32S2_I2S) && !defined(CONFIG_AUDIO_CS4344)
|
||||
int board_i2sdev_initialize(void);
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __BOARDS_XTENSA_ESP32S2_ESP32S2_KALUGA_1_SRC_ESP32S2_KALUGA_1_H */
|
||||
@@ -0,0 +1,80 @@
|
||||
/****************************************************************************
|
||||
* boards/xtensa/esp32s2/esp32s2-kaluga-1/src/esp32s2_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 <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <nuttx/board.h>
|
||||
|
||||
#include "esp32s2-kaluga-1.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 esp32s2_bringup();
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BOARDCTL */
|
||||
@@ -0,0 +1,93 @@
|
||||
/****************************************************************************
|
||||
* boards/xtensa/esp32s2/esp32s2-kaluga-1/src/esp32s2_board_i2c.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 <nuttx/config.h>
|
||||
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <nuttx/i2c/i2c_master.h>
|
||||
|
||||
#include "esp32s2_i2c.h"
|
||||
#include "esp32s2-kaluga-1.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
static int i2c_driver_init(int bus)
|
||||
{
|
||||
struct i2c_master_s *i2c;
|
||||
int ret;
|
||||
|
||||
i2c = esp32s2_i2cbus_initialize(bus);
|
||||
if (i2c == NULL)
|
||||
{
|
||||
i2cerr("Failed to get I2C%d interface\n", bus);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
ret = i2c_register(i2c, bus);
|
||||
if (ret < 0)
|
||||
{
|
||||
i2cerr("Failed to register I2C%d driver: %d\n", bus, ret);
|
||||
esp32s2_i2cbus_uninitialize(i2c);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int board_i2c_init(void)
|
||||
{
|
||||
int ret = OK;
|
||||
|
||||
#ifdef CONFIG_ESP32S2_I2C0
|
||||
ret = i2c_driver_init(ESP32S2_I2C0);
|
||||
if (ret != OK)
|
||||
{
|
||||
goto done;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP32S2_I2C1
|
||||
ret = i2c_driver_init(ESP32S2_I2C1);
|
||||
#endif
|
||||
|
||||
done:
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
/****************************************************************************
|
||||
* boards/xtensa/esp32s2/esp32s2-kaluga-1/src/esp32s2_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 <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/spi/spi.h>
|
||||
|
||||
#include "esp32s2_gpio.h"
|
||||
#include "esp32s2-kaluga-1.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32s2_spi2_status
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ESP32S2_SPI2
|
||||
|
||||
uint8_t esp32s2_spi2_status(struct spi_dev_s *dev, uint32_t devid)
|
||||
{
|
||||
uint8_t status = 0;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32s2_spi2_cmddata
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_ESP32S2_SPI2) && defined(CONFIG_SPI_CMDDATA)
|
||||
|
||||
int esp32s2_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.
|
||||
*/
|
||||
|
||||
esp32s2_gpiowrite(GPIO_LCD_DC, !cmd);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
spiinfo("devid: %" PRIu32 " CMD: %s\n", devid, cmd ? "command" :
|
||||
"data");
|
||||
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32s2_spi3_status
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ESP32S2_SPI3
|
||||
|
||||
uint8_t esp32s2_spi3_status(struct spi_dev_s *dev, uint32_t devid)
|
||||
{
|
||||
uint8_t status = 0;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32s2_spi3_cmddata
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_ESP32S2_SPI3) && defined(CONFIG_SPI_CMDDATA)
|
||||
|
||||
int esp32s2_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.
|
||||
*/
|
||||
|
||||
esp32s2_gpiowrite(CONFIG_ESP32S2_SPI3_MISOPIN, !cmd);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
spiinfo("devid: %" PRIu32 " CMD: %s\n", devid, cmd ? "command" :
|
||||
"data");
|
||||
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,83 @@
|
||||
/****************************************************************************
|
||||
* boards/xtensa/esp32s2/esp32s2-kaluga-1/src/esp32s2_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 <nuttx/config.h>
|
||||
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/mm/mm.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "esp32s2-kaluga-1.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32s2_board_initialize
|
||||
*
|
||||
* Description:
|
||||
* All ESP32 architectures 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 esp32s2_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 */
|
||||
|
||||
esp32s2_bringup();
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,216 @@
|
||||
/****************************************************************************
|
||||
* boards/xtensa/esp32s2/esp32s2-kaluga-1/src/esp32s2_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 <nuttx/config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <syslog.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/types.h>
|
||||
#include <syslog.h>
|
||||
#include <debug.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <nuttx/fs/fs.h>
|
||||
|
||||
#ifdef CONFIG_USERLED
|
||||
# include <nuttx/leds/userled.h>
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_INPUT_BUTTONS
|
||||
# include <nuttx/input/buttons.h>
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_TIMER
|
||||
# include "esp32s2_tim_lowerhalf.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP32S2_I2C
|
||||
# include "esp32s2_i2c.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP32S2_RT_TIMER
|
||||
# include "esp32s2_rt_timer.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_WATCHDOG
|
||||
# include "esp32s2_board_wdt.h"
|
||||
#endif
|
||||
|
||||
#include "esp32s2-kaluga-1.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32s2_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 esp32s2_bringup(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
#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_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_DEV_GPIO
|
||||
ret = esp32s2_gpio_init();
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "Failed to initialize GPIO Driver: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Register the timer drivers */
|
||||
|
||||
#ifdef CONFIG_TIMER
|
||||
|
||||
#if defined(CONFIG_ESP32S2_TIMER0) && !defined(CONFIG_ONESHOT)
|
||||
ret = esp32s2_timer_initialize("/dev/timer0", TIMER0);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR,
|
||||
"ERROR: Failed to initialize timer driver: %d\n",
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP32S2_TIMER1
|
||||
ret = esp32s2_timer_initialize("/dev/timer1", TIMER1);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR,
|
||||
"ERROR: Failed to initialize timer driver: %d\n",
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP32S2_TIMER2
|
||||
ret = esp32s2_timer_initialize("/dev/timer2", TIMER2);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR,
|
||||
"ERROR: Failed to initialize timer driver: %d\n",
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP32S2_TIMER3
|
||||
ret = esp32s2_timer_initialize("/dev/timer3", TIMER3);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR,
|
||||
"ERROR: Failed to initialize timer driver: %d\n",
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_TIMER */
|
||||
|
||||
#ifdef CONFIG_ESP32S2_RT_TIMER
|
||||
ret = esp32s2_rt_timer_init();
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "Failed to initialize RT timer: %d\n", ret);
|
||||
}
|
||||
|
||||
#endif
|
||||
/* Now register one oneshot driver */
|
||||
|
||||
#if defined(CONFIG_ONESHOT) && defined(CONFIG_ESP32S2_TIMER0)
|
||||
|
||||
ret = board_oneshot_init(ONESHOT_TIMER, ONESHOT_RESOLUTION_US);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: board_oneshot_init() failed: %d\n", ret);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_ONESHOT */
|
||||
|
||||
#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
|
||||
|
||||
/* 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;
|
||||
}
|
||||
@@ -0,0 +1,468 @@
|
||||
/****************************************************************************
|
||||
* boards/xtensa/esp32s2/esp32s2-kaluga-1/src/esp32s2_gpio.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 <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <syslog.h>
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <arch/irq.h>
|
||||
|
||||
#include <nuttx/ioexpander/gpio.h>
|
||||
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "esp32s2-kaluga-1.h"
|
||||
#include "esp32s2_gpio.h"
|
||||
#include "hardware/esp32s2_gpio_sigmap.h"
|
||||
|
||||
#if defined(CONFIG_DEV_GPIO) && !defined(CONFIG_GPIO_LOWER_HALF)
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Pin 1 and 2 are used for this example as GPIO outputs. */
|
||||
|
||||
#define GPIO_OUT1 1
|
||||
#define GPIO_OUT2 2
|
||||
#define GPIO_IN1 4
|
||||
|
||||
#if !defined(CONFIG_ESP32S2_GPIO_IRQ) && BOARD_NGPIOINT > 0
|
||||
# error "NGPIOINT is > 0 and GPIO interrupts aren't enabled"
|
||||
#endif
|
||||
|
||||
/* Interrupt pins. GPIO9 is used as an example, any other inputs could be
|
||||
* used.
|
||||
*/
|
||||
|
||||
#define GPIO_IRQPIN 9
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
struct esp32s2gpio_dev_s
|
||||
{
|
||||
struct gpio_dev_s gpio;
|
||||
uint8_t id;
|
||||
};
|
||||
|
||||
struct esp32s2gpint_dev_s
|
||||
{
|
||||
struct esp32s2gpio_dev_s esp32s2gpio;
|
||||
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
|
||||
|
||||
/****************************************************************************
|
||||
* 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, GPIO_OUT2
|
||||
};
|
||||
|
||||
static struct esp32s2gpio_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 OUTPUT */
|
||||
|
||||
static const uint32_t g_gpioinputs[BOARD_NGPIOIN] =
|
||||
{
|
||||
GPIO_IN1
|
||||
};
|
||||
|
||||
static struct esp32s2gpio_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_IRQPIN,
|
||||
};
|
||||
|
||||
static struct esp32s2gpint_dev_s g_gpint[BOARD_NGPIOINT];
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: gpout_read
|
||||
*
|
||||
* Description:
|
||||
* Read a 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).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if BOARD_NGPIOOUT > 0
|
||||
static int gpout_read(struct gpio_dev_s *dev, bool *value)
|
||||
{
|
||||
struct esp32s2gpio_dev_s *esp32s2gpio =
|
||||
(struct esp32s2gpio_dev_s *)dev;
|
||||
|
||||
DEBUGASSERT(esp32s2gpio != NULL && value != NULL);
|
||||
DEBUGASSERT(esp32s2gpio->id < BOARD_NGPIOOUT);
|
||||
gpioinfo("Reading...\n");
|
||||
|
||||
*value = esp32s2_gpioread(g_gpiooutputs[esp32s2gpio->id]);
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: gpout_write
|
||||
*
|
||||
* Description:
|
||||
* Write to a digital output pin.
|
||||
*
|
||||
* Parameters:
|
||||
* dev - A pointer to the gpio driver struct.
|
||||
* value - The value to be written.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int gpout_write(struct gpio_dev_s *dev, bool value)
|
||||
{
|
||||
struct esp32s2gpio_dev_s *esp32s2gpio =
|
||||
(struct esp32s2gpio_dev_s *)dev;
|
||||
|
||||
DEBUGASSERT(esp32s2gpio != NULL);
|
||||
DEBUGASSERT(esp32s2gpio->id < BOARD_NGPIOOUT);
|
||||
gpioinfo("Writing %d\n", (int)value);
|
||||
|
||||
esp32s2_gpiowrite(g_gpiooutputs[esp32s2gpio->id], value);
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: gpin_read
|
||||
*
|
||||
* Description:
|
||||
* Read a digital input pin.
|
||||
*
|
||||
* Parameters:
|
||||
* dev - A pointer to the gpio driver struct.
|
||||
* value - A pointer to store the state of the pin.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if BOARD_NGPIOIN > 0
|
||||
static int gpin_read(struct gpio_dev_s *dev, bool *value)
|
||||
{
|
||||
struct esp32s2gpio_dev_s *esp32s2gpio =
|
||||
(struct esp32s2gpio_dev_s *)dev;
|
||||
|
||||
DEBUGASSERT(esp32s2gpio != NULL && value != NULL);
|
||||
DEBUGASSERT(esp32s2gpio->id < BOARD_NGPIOIN);
|
||||
gpioinfo("Reading...\n");
|
||||
|
||||
*value = esp32s2_gpioread(g_gpioinputs[esp32s2gpio->id]);
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32s2gpio_interrupt
|
||||
*
|
||||
* Description:
|
||||
* Digital Input ISR.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if BOARD_NGPIOINT > 0
|
||||
static int esp32s2gpio_interrupt(int irq, void *context, void *arg)
|
||||
{
|
||||
struct esp32s2gpint_dev_s *esp32s2gpint =
|
||||
(struct esp32s2gpint_dev_s *)arg;
|
||||
|
||||
DEBUGASSERT(esp32s2gpint != NULL && esp32s2gpint->callback != NULL);
|
||||
gpioinfo("Interrupt! callback=%p\n", esp32s2gpint->callback);
|
||||
|
||||
esp32s2gpint->callback(&esp32s2gpint->esp32s2gpio.gpio,
|
||||
esp32s2gpint->esp32s2gpio.id);
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: gpint_read
|
||||
*
|
||||
* Description:
|
||||
* Read a digital input 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 gpint_read(struct gpio_dev_s *dev, bool *value)
|
||||
{
|
||||
struct esp32s2gpint_dev_s *esp32s2gpint =
|
||||
(struct esp32s2gpint_dev_s *)dev;
|
||||
|
||||
DEBUGASSERT(esp32s2gpint != NULL && value != NULL);
|
||||
DEBUGASSERT(esp32s2gpint->esp32s2gpio.id < BOARD_NGPIOINT);
|
||||
gpioinfo("Reading int pin...\n");
|
||||
|
||||
*value = esp32s2_gpioread(g_gpiointinputs[esp32s2gpint->esp32s2gpio.id]);
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: gpint_attach
|
||||
*
|
||||
* Description:
|
||||
* Attach the ISR to IRQ and register the callback. But it still doesn't
|
||||
* enable interrupt yet.
|
||||
*
|
||||
* Parameters:
|
||||
* dev - A pointer to the gpio driver struct.
|
||||
* callback - User callback function.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success; A negated errno value is returned
|
||||
* to indicate the nature of any failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int gpint_attach(struct gpio_dev_s *dev,
|
||||
pin_interrupt_t callback)
|
||||
{
|
||||
struct esp32s2gpint_dev_s *esp32s2gpint =
|
||||
(struct esp32s2gpint_dev_s *)dev;
|
||||
int irq = ESP32S2_PIN2IRQ(g_gpiointinputs[esp32s2gpint->esp32s2gpio.id]);
|
||||
int ret;
|
||||
|
||||
gpioinfo("Attaching the callback\n");
|
||||
|
||||
/* Make sure the interrupt is disabled */
|
||||
|
||||
esp32s2_gpioirqdisable(irq);
|
||||
ret = irq_attach(irq,
|
||||
esp32s2gpio_interrupt,
|
||||
&g_gpint[esp32s2gpint->esp32s2gpio.id]);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: gpint_attach() failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
gpioinfo("Attach %p\n", callback);
|
||||
esp32s2gpint->callback = callback;
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: gpint_enable
|
||||
*
|
||||
* Description:
|
||||
* Enable/Disable interrupt.
|
||||
*
|
||||
* Parameters:
|
||||
* dev - A pointer to the gpio driver struct.
|
||||
* enable - True to enable, false to disable.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int gpint_enable(struct gpio_dev_s *dev, bool enable)
|
||||
{
|
||||
struct esp32s2gpint_dev_s *esp32s2gpint =
|
||||
(struct esp32s2gpint_dev_s *)dev;
|
||||
int irq = ESP32S2_PIN2IRQ(g_gpiointinputs[esp32s2gpint->esp32s2gpio.id]);
|
||||
|
||||
if (enable)
|
||||
{
|
||||
if (esp32s2gpint->callback != NULL)
|
||||
{
|
||||
gpioinfo("Enabling the interrupt\n");
|
||||
|
||||
/* Configure the interrupt for rising edge */
|
||||
|
||||
esp32s2_gpioirqenable(irq, GPIO_INTR_POSEDGE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gpioinfo("Disable the interrupt\n");
|
||||
esp32s2_gpioirqdisable(irq);
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: esp32s2_gpio_init
|
||||
*
|
||||
* Description:
|
||||
* Initialize all pins. Function should be called from the bringup.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int esp32s2_gpio_init(void)
|
||||
{
|
||||
int pincount = 0;
|
||||
|
||||
#if BOARD_NGPIOOUT > 0
|
||||
for (int 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 */
|
||||
|
||||
esp32s2_gpio_matrix_out(g_gpiooutputs[i], SIG_GPIO_OUT_IDX, 0, 0);
|
||||
esp32s2_configgpio(g_gpiooutputs[i], OUTPUT_FUNCTION_1 |
|
||||
INPUT_FUNCTION_1);
|
||||
esp32s2_gpiowrite(g_gpiooutputs[i], 0);
|
||||
|
||||
pincount++;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BOARD_NGPIOIN > 0
|
||||
for (int i = 0; i < BOARD_NGPIOIN; i++)
|
||||
{
|
||||
/* Setup and register the GPIO pin */
|
||||
|
||||
g_gpin[i].gpio.gp_pintype = GPIO_INPUT_PIN_PULLDOWN;
|
||||
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 interrupt input */
|
||||
|
||||
esp32s2_configgpio(g_gpioinputs[i], INPUT_FUNCTION_1 | PULLDOWN);
|
||||
|
||||
pincount++;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BOARD_NGPIOINT > 0
|
||||
for (int i = 0; i < BOARD_NGPIOINT; i++)
|
||||
{
|
||||
/* Setup and register the GPIO pin */
|
||||
|
||||
g_gpint[i].esp32s2gpio.gpio.gp_pintype = GPIO_INTERRUPT_PIN;
|
||||
g_gpint[i].esp32s2gpio.gpio.gp_ops = &gpint_ops;
|
||||
g_gpint[i].esp32s2gpio.id = i;
|
||||
gpio_pin_register(&g_gpint[i].esp32s2gpio.gpio, pincount);
|
||||
|
||||
/* Configure the pins that will be used as interrupt input */
|
||||
|
||||
esp32s2_configgpio(g_gpiointinputs[i], INPUT_FUNCTION_1 | PULLDOWN);
|
||||
|
||||
pincount++;
|
||||
}
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
||||
#endif /* CONFIG_DEV_GPIO && !CONFIG_GPIO_LOWER_HALF */
|
||||
@@ -0,0 +1,83 @@
|
||||
/****************************************************************************
|
||||
* boards/xtensa/esp32s2/esp32s2-kaluga-1/src/esp32s2_oneshot.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 <nuttx/config.h>
|
||||
|
||||
#include <debug.h>
|
||||
#include <sys/types.h>
|
||||
#include <nuttx/timers/timer.h>
|
||||
#include <nuttx/clock.h>
|
||||
#include <nuttx/timers/oneshot.h>
|
||||
#include "esp32s2-kaluga-1.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_oneshot_init
|
||||
*
|
||||
* Description:
|
||||
* Configure the oneshot timer driver.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) is returned on success; A negated errno value is returned
|
||||
* to indicate the nature of any failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int board_oneshot_init(int timer, uint16_t resolution)
|
||||
{
|
||||
int ret = OK;
|
||||
struct oneshot_lowerhalf_s *os_lower = NULL;
|
||||
|
||||
os_lower = oneshot_initialize(timer, resolution);
|
||||
if (os_lower != NULL)
|
||||
{
|
||||
#if defined(CONFIG_CPULOAD_ONESHOT)
|
||||
/* Configure the oneshot timer to support CPU load measurement */
|
||||
|
||||
nxsched_oneshot_extclk(os_lower);
|
||||
|
||||
#else
|
||||
ret = oneshot_register("/dev/oneshot", os_lower);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR,
|
||||
"ERROR: Failed to register oneshot at /dev/oneshot: %d\n", ret);
|
||||
}
|
||||
#endif /* CONFIG_CPULOAD_ONESHOT */
|
||||
}
|
||||
else
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: oneshot_initialize failed\n");
|
||||
ret = -EBUSY;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/****************************************************************************
|
||||
* boards/xtensa/esp32s2/esp32s2-kaluga-1/src/esp32s2_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 <nuttx/config.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/board.h>
|
||||
|
||||
#ifdef CONFIG_BOARDCTL_RESET
|
||||
|
||||
/****************************************************************************
|
||||
* 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)
|
||||
{
|
||||
up_systemreset();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BOARDCTL_RESET */
|
||||
Reference in New Issue
Block a user