add support for native SAMD HCD

This commit is contained in:
Deadman
2024-02-28 00:00:55 +01:00
parent 8b1e40c3e2
commit 965e26de1d
7 changed files with 806 additions and 14 deletions

View File

@@ -60,7 +60,13 @@
// Forward USB interrupt events to TinyUSB IRQ Handler
//--------------------------------------------------------------------+
void USB_Handler(void) {
#if CFG_TUD_ENABLED
tud_int_handler(0);
#endif
#if CFG_TUH_ENABLED && !(defined(CFG_TUH_MAX3421) && CFG_TUH_MAX3421)
tuh_int_handler(0);
#endif
}
//--------------------------------------------------------------------+
@@ -140,8 +146,14 @@ void board_init(void) {
gpio_set_pin_function(PIN_PA19, PINMUX_PA19F_TCC0_WO3);
_gclk_enable_channel(TCC0_GCLK_ID, GCLK_CLKCTRL_GEN_GCLK0_Val);
#if CFG_TUH_ENABLED && defined(CFG_TUH_MAX3421) && CFG_TUH_MAX3421
max3421_init();
#if CFG_TUH_ENABLED
#if defined(CFG_TUH_MAX3421) && CFG_TUH_MAX3421
max3421_init();
#else
// VBUS Power
gpio_set_pin_direction(PIN_PA28, GPIO_DIRECTION_OUT);
gpio_set_pin_level(PIN_PA28, true);
#endif
#endif
}

View File

@@ -99,6 +99,7 @@ function(family_configure_example TARGET RTOS)
family_add_tinyusb(${TARGET} OPT_MCU_SAMD21 ${RTOS})
target_sources(${TARGET}-tinyusb PUBLIC
${TOP}/src/portable/microchip/samd/dcd_samd.c
${TOP}/src/portable/microchip/samd/hcd_samd.c
)
target_link_libraries(${TARGET}-tinyusb PUBLIC board_${BOARD})

View File

@@ -23,6 +23,7 @@ LDFLAGS_CLANG +=
SRC_C += \
src/portable/microchip/samd/dcd_samd.c \
src/portable/microchip/samd/hcd_samd.c \
${SDK_DIR}/gcc/gcc/startup_samd21.c \
${SDK_DIR}/gcc/system_samd21.c \
${SDK_DIR}/hal/src/hal_atomic.c \

View File

@@ -56,21 +56,24 @@
//--------------------------------------------------------------------+
// Forward USB interrupt events to TinyUSB IRQ Handler
//--------------------------------------------------------------------+
void USB_0_Handler(void) {
TU_ATTR_ALWAYS_INLINE inline void USB_Any_Handler(void)
{
#if CFG_TUD_ENABLED
tud_int_handler(0);
#endif
#if CFG_TUH_ENABLED && !CFG_TUH_MAX3421
tuh_int_handler(0);
#endif
}
void USB_1_Handler(void) {
tud_int_handler(0);
}
void USB_0_Handler(void) { USB_Any_Handler(); }
void USB_2_Handler(void) {
tud_int_handler(0);
}
void USB_1_Handler(void) { USB_Any_Handler(); }
void USB_3_Handler(void) {
tud_int_handler(0);
}
void USB_2_Handler(void) { USB_Any_Handler(); }
void USB_3_Handler(void) { USB_Any_Handler(); }
//--------------------------------------------------------------------+
// Implementation
@@ -138,8 +141,14 @@ void board_init(void) {
gpio_set_pin_function(PIN_PA24, PINMUX_PA24H_USB_DM);
gpio_set_pin_function(PIN_PA25, PINMUX_PA25H_USB_DP);
#if CFG_TUH_ENABLED && CFG_TUH_MAX3421
max3421_init();
#if CFG_TUH_ENABLED
#if defined(CFG_TUH_MAX3421) && CFG_TUH_MAX3421
max3421_init();
#else
// VBUS Power
gpio_set_pin_direction(PIN_PA28, GPIO_DIRECTION_OUT);
gpio_set_pin_level(PIN_PA28, true);
#endif
#endif
}

View File

@@ -96,6 +96,7 @@ function(family_configure_example TARGET RTOS)
family_add_tinyusb(${TARGET} OPT_MCU_SAMD51 ${RTOS})
target_sources(${TARGET}-tinyusb PUBLIC
${TOP}/src/portable/microchip/samd/dcd_samd.c
${TOP}/src/portable/microchip/samd/hcd_samd.c
)
target_link_libraries(${TARGET}-tinyusb PUBLIC board_${BOARD})

View File

@@ -18,6 +18,7 @@ LDFLAGS_GCC += \
SRC_C += \
src/portable/microchip/samd/dcd_samd.c \
src/portable/microchip/samd/hcd_samd.c \
${SDK_DIR}/gcc/gcc/startup_${SAM_FAMILY}.c \
${SDK_DIR}/gcc/system_${SAM_FAMILY}.c \
${SDK_DIR}/hpl/gclk/hpl_gclk.c \