mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-17 05:32:45 +01:00
pkg/tinyusb: add ESP32-S2 and ESP32-S3 support
This commit is contained in:
parent
136827e6da
commit
21b3bcd0c0
@ -67,3 +67,6 @@ tinyusb_device:
|
||||
|
||||
tinyusb_host:
|
||||
$(QQ)"$(MAKE)" -C $(PSRC)/host -f $(RIOTBASE)/Makefile.base MODULE=$@
|
||||
|
||||
tinyusb_portable_espressif:
|
||||
$(QQ)"$(MAKE)" -C $(PSRC)/portable/espressif/esp32sx -f $(RIOTBASE)/Makefile.base MODULE=$@
|
||||
|
@ -55,6 +55,13 @@ ifneq (,$(filter tinyusb_class_video,$(USEMODULE)))
|
||||
FEATURES_REQUIRED += tinyusb_device
|
||||
endif
|
||||
|
||||
# tinyUSB hardware driver selection
|
||||
ifneq (,$(filter esp32s2 esp32s3,$(CPU_FAM)))
|
||||
USEMODULE += tinyusb_portable_espressif
|
||||
else
|
||||
$(error CPU family not supported)
|
||||
endif
|
||||
|
||||
# other module dependencies
|
||||
USEMODULE += periph_usbdev_clk
|
||||
USEMODULE += sema
|
||||
|
@ -6,6 +6,14 @@ INCLUDES += -I$(PKGDIRBASE)/tinyusb/src
|
||||
CFLAGS += -DCFG_TUSB_OS=OPT_OS_CUSTOM
|
||||
CFLAGS += -Wno-format-nonliteral
|
||||
|
||||
ifeq (esp32s2,$(CPU_FAM))
|
||||
CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_ESP32S2
|
||||
else ifeq (esp32s3,$(CPU_FAM))
|
||||
CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_ESP32S3
|
||||
else
|
||||
$(error CPU family not supported)
|
||||
endif
|
||||
|
||||
ifneq (,$(filter tinyusb_class_net_ecm_rndis,$(USEMODULE)))
|
||||
INCLUDES += -I$(PKGDIRBASE)/tinyusb/lib/networking
|
||||
endif
|
||||
|
41
pkg/tinyusb/hw/hw_esp32.c
Normal file
41
pkg/tinyusb/hw/hw_esp32.c
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup pkg_tinyusb
|
||||
* @brief
|
||||
* @{
|
||||
*
|
||||
* @brief tinyUSB hardware driver for ESP32x SoCs
|
||||
* @author Gunar Schorcht <gunar@schorcht.net>
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp_private/usb_phy.h"
|
||||
|
||||
#include "log.h"
|
||||
|
||||
static usb_phy_handle_t phy_hdl;
|
||||
|
||||
int tinyusb_hw_init(void)
|
||||
{
|
||||
usb_phy_config_t phy_conf = {
|
||||
.controller = USB_PHY_CTRL_OTG,
|
||||
.otg_mode = USB_OTG_MODE_DEVICE,
|
||||
.target = USB_PHY_TARGET_INT, /* only internal PHY supported */
|
||||
};
|
||||
|
||||
if (usb_new_phy(&phy_conf, &phy_hdl) != ESP_OK) {
|
||||
LOG_TAG_ERROR("usb", "Install USB PHY failed");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user