add board_vbus_set() for samd21/d51 to enable usb host vbus

enable host example build for samd21/d51
This commit is contained in:
hathach
2025-07-09 15:06:26 +07:00
parent 386f551899
commit e598972438
29 changed files with 109 additions and 178 deletions

View File

@@ -30,7 +30,6 @@
#include "sam.h"
#include "bsp/board_api.h"
#include "board.h"
// Suppress warning caused by mcu driver
#ifdef __GNUC__
@@ -50,6 +49,9 @@
#pragma GCC diagnostic pop
#endif
static inline void board_vbus_set(uint8_t rhport, bool state) TU_ATTR_UNUSED;
#include "board.h"
//--------------------------------------------------------------------+
// MACRO TYPEDEF CONSTANT ENUM DECLARATION
//--------------------------------------------------------------------+
@@ -68,7 +70,7 @@ void USB_Handler(void) {
tud_int_handler(0);
#endif
#if CFG_TUH_ENABLED && !(defined(CFG_TUH_MAX3421) && CFG_TUH_MAX3421)
#if CFG_TUH_ENABLED && !CFG_TUH_MAX3421
tuh_int_handler(0);
#endif
}
@@ -78,11 +80,9 @@ void USB_Handler(void) {
//--------------------------------------------------------------------+
static void uart_init(void);
#if CFG_TUH_ENABLED && defined(CFG_TUH_MAX3421) && CFG_TUH_MAX3421
#if CFG_TUH_ENABLED && CFG_TUH_MAX3421
#define MAX3421_SERCOM TU_XSTRCAT(SERCOM, MAX3421_SERCOM_ID)
static void max3421_init(void);
#endif
void board_init(void) {
@@ -151,12 +151,11 @@ void board_init(void) {
_gclk_enable_channel(TCC0_GCLK_ID, GCLK_CLKCTRL_GEN_GCLK0_Val);
#if CFG_TUH_ENABLED
#if defined(CFG_TUH_MAX3421) && CFG_TUH_MAX3421
#if CFG_TUH_MAX3421
max3421_init();
#else
// VBUS Power
gpio_set_pin_direction(PIN_PA28, GPIO_DIRECTION_OUT);
gpio_set_pin_level(PIN_PA28, true);
board_vbus_set(0, true);
#endif
#endif
}