Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpu/esp32: add periph_usbdev for ESP32-S2 and ESP32S3 #18624

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cpu/esp32/Kconfig.esp32s2
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ config CPU_FAM_ESP32S2
select HAS_PERIPH_GPIO_LL_IRQ
select HAS_PERIPH_GPIO_LL_IRQ_LEVEL_TRIGGERED_HIGH
select HAS_PERIPH_GPIO_LL_IRQ_LEVEL_TRIGGERED_LOW
select HAS_PERIPH_USBDEV
select HAS_PUF_SRAM

select PACKAGE_ESP32_SDK if TEST_KCONFIG
Expand Down
1 change: 1 addition & 0 deletions cpu/esp32/Kconfig.esp32s3
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ config CPU_FAM_ESP32S3
select HAS_PERIPH_GPIO_LL_IRQ
select HAS_PERIPH_GPIO_LL_IRQ_LEVEL_TRIGGERED_HIGH
select HAS_PERIPH_GPIO_LL_IRQ_LEVEL_TRIGGERED_LOW
select HAS_PERIPH_USBDEV
select HAS_PUF_SRAM

select PACKAGE_ESP32_SDK if TEST_KCONFIG
Expand Down
5 changes: 5 additions & 0 deletions cpu/esp32/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ ifneq (,$(filter periph_rtt,$(USEMODULE)))
USEMODULE += periph_rtt_hw_rtc
endif

ifneq (,$(filter periph_usbdev,$(USEMODULE)))
USEMODULE += esp_idf_usb
USEMODULE += ztimer_msec
endif

ifneq (,$(filter shell,$(USEMODULE)))
USEMODULE += ps
endif
Expand Down
4 changes: 4 additions & 0 deletions cpu/esp32/Makefile.features
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ else ifneq (,$(filter esp32c3 esp32s3,$(CPU_FAM)))
FEATURES_PROVIDED += esp_ble_esp32c3
endif

ifneq (,$(filter esp32s2 esp32s3,$(CPU_FAM)))
FEATURES_PROVIDED += periph_usbdev
endif

ifneq (,$(filter esp32-wrover% esp32s2%r2 esp32s3%r2 esp32s3%r8 esp32s3%r8v,$(CPU_MODEL)))
FEATURES_PROVIDED += esp_spi_ram
ifneq (,$(filter esp32s3%r8 esp32s3%r8v,$(CPU_MODEL)))
Expand Down
5 changes: 5 additions & 0 deletions cpu/esp32/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ PSEUDOMODULES += esp_wifi_enterprise

INCLUDES += -I$(RIOTCPU)/$(CPU)/esp-idf/include
INCLUDES += -I$(RIOTCPU)/$(CPU)/esp-idf/include/log
INCLUDES += -I$(RIOTCPU)/$(CPU)/vendor/include

INCLUDES += -I$(ESP32_SDK_DIR)/components
INCLUDES += -I$(ESP32_SDK_DIR)/components/bootloader_support/include
Expand Down Expand Up @@ -98,6 +99,10 @@ ifneq (,$(filter esp_idf_spi_flash,$(USEMODULE)))
INCLUDES += -I$(ESP32_SDK_DIR)/components/spi_flash/include
endif

ifneq (,$(filter esp_idf_usb,$(USEMODULE)))
INCLUDES += -I$(ESP32_SDK_DIR)/components/usb/include
endif

ifneq (,$(filter esp_wifi_any,$(USEMODULE)))
INCLUDES += -I$(ESP32_SDK_DIR)/components/bootloader_support/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_eth/include
Expand Down
1 change: 1 addition & 0 deletions cpu/esp32/esp-idf/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ rsource "heap/Kconfig"
rsource "nvs_flash/Kconfig"
rsource "spi_flash/Kconfig"
rsource "spi_ram/Kconfig"
rsource "usb/Kconfig"
rsource "wifi/Kconfig"
rsource "wpa_supplicant/Kconfig"
4 changes: 4 additions & 0 deletions cpu/esp32/esp-idf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ ifneq (,$(filter esp_idf_spi_ram,$(USEMODULE)))
DIRS += spi_ram
endif

ifneq (,$(filter esp_idf_usb,$(USEMODULE)))
DIRS += usb
endif

ifneq (,$(filter esp_idf_wifi,$(USEMODULE)))
DIRS += wifi
endif
Expand Down
13 changes: 13 additions & 0 deletions cpu/esp32/esp-idf/usb/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (c) 2022 Gunar Schorcht
#
# This file is subject to the terms and conditions of the GNU Lesser
# General Public License v2.1. See the file LICENSE in the top level
# directory for more details.
#

config MODULE_ESP_IDF_USB
bool
depends on TEST_KCONFIG
depends on MODULE_ESP_IDF
help
ESP-IDF code for USB.
17 changes: 17 additions & 0 deletions cpu/esp32/esp-idf/usb/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
MODULE = esp_idf_usb

# source files to be compiled for this module
ESP32_SDK_SRC = \
components/hal/usb_hal.c \
components/hal/usb_phy_hal.c \
components/soc/$(CPU_FAM)/usb_periph.c \
components/soc/$(CPU_FAM)/usb_phy_periph.c \
components/usb/usb_phy.c \
#

include $(RIOTBASE)/Makefile.base

ESP32_SDK_BIN = $(BINDIR)/$(MODULE)

include ../esp_idf.mk
include ../esp_idf_cflags.mk
1 change: 1 addition & 0 deletions cpu/esp32/include/irq_arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ extern "C" {
#define CPU_INUM_GPIO 2 /**< Level interrupt with low priority 1 */
#define CPU_INUM_CAN 3 /**< Level interrupt with low priority 1 */
#define CPU_INUM_UART 4 /**< Level interrupt with low priority 1 */
#define CPU_INUM_USB 8 /**< Level interrupt with low priority 1 */
#define CPU_INUM_RTT 9 /**< Level interrupt with low priority 1 */
#define CPU_INUM_I2C 12 /**< Level interrupt with low priority 1 */
#define CPU_INUM_WDT 13 /**< Level interrupt with low priority 1 */
Expand Down
4 changes: 1 addition & 3 deletions cpu/esp32/include/sdkconfig_esp32s2.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,7 @@ extern "C" {
/**
* ESP32-S2 specific PHY configuration
*/
#define CONFIG_USB_OTG_SUPPORTED 0
#define CONFIG_USB_HOST_CONTROL_TRANSFER_MAX_SIZE 256
#define CONFIG_USB_HOST_HW_BUFFER_BIAS_BALANCED 1
#define CONFIG_USB_OTG_SUPPORTED 1

/**
* ESP32-S2 specific SPI RAM configuration
Expand Down
4 changes: 1 addition & 3 deletions cpu/esp32/include/sdkconfig_esp32s3.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,7 @@ extern "C" {
* ESP32-S3 specific PHY configuration
*/
#define CONFIG_ESP_PHY_ENABLE_USB 1
#define CONFIG_USB_OTG_SUPPORTED 0
#define CONFIG_USB_HOST_CONTROL_TRANSFER_MAX_SIZE 256
#define CONFIG_USB_HOST_HW_BUFFER_BIAS_BALANCED 1
#define CONFIG_USB_OTG_SUPPORTED 1

/**
* ESP32-S3 specific SPI RAM configuration
Expand Down
5 changes: 4 additions & 1 deletion cpu/esp32/irq_arch.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ static const struct intr_handle_data_t _irq_data_table[] = {
#if !defined(CPU_FAM_ESP32)
{ ETS_SYSTIMER_TARGET2_EDGE_INTR_SOURCE, CPU_INUM_SYSTIMER, 2 },
#endif
{ ETS_INTERNAL_SW1_INTR_SOURCE, CPU_INUM_BLE, 2 }
{ ETS_INTERNAL_SW1_INTR_SOURCE, CPU_INUM_BLE, 2 },
#if defined(CPU_FAM_ESP32S2) || defined(CPU_FAM_ESP32S3)
{ ETS_USB_INTR_SOURCE, CPU_INUM_USB, 1 },
#endif
};

#define IRQ_DATA_TABLE_SIZE ARRAY_SIZE(_irq_data_table)
Expand Down
Loading