mirror of
https://github.com/hathach/tinyusb.git
synced 2026-03-14 19:44:44 +00:00
use CFG_TUD_CONFIGURE_DWC2_DEFAULT to make it easier to add more value
This commit is contained in:
@ -106,10 +106,8 @@ void board_init(void) {
|
||||
|
||||
#if CFG_TUD_ENABLED
|
||||
// Enable VBUS sense (B device) via pin PA9
|
||||
tud_configure_dwc2_t cfg = {
|
||||
.bm_double_buffered = 0,
|
||||
.vbus_sensing = true
|
||||
};
|
||||
tud_configure_dwc2_t cfg = CFG_TUD_CONFIGURE_DWC2_DEFAULT;
|
||||
cfg.vbus_sensing = true;
|
||||
tud_configure(0, TUD_CFGID_DWC2, &cfg);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -180,10 +180,8 @@ void board_init(void) {
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_ENABLED
|
||||
tud_configure_dwc2_t cfg = {
|
||||
.bm_double_buffered = 0,
|
||||
.vbus_sensing = VBUS_SENSE_EN
|
||||
};
|
||||
tud_configure_dwc2_t cfg = CFG_TUD_CONFIGURE_DWC2_DEFAULT;
|
||||
cfg.vbus_sensing = VBUS_SENSE_EN;
|
||||
tud_configure(BOARD_TUD_RHPORT, TUD_CFGID_DWC2, &cfg);
|
||||
board_vbus_set(BOARD_TUD_RHPORT, false);
|
||||
#endif
|
||||
|
||||
@ -157,10 +157,8 @@ void board_init(void) {
|
||||
#endif // vbus sense
|
||||
|
||||
#if CFG_TUD_ENABLED && BOARD_TUD_RHPORT == 0
|
||||
tud_configure_dwc2_t cfg = {
|
||||
.bm_double_buffered = 0,
|
||||
.vbus_sensing = OTG_FS_VBUS_SENSE
|
||||
};
|
||||
tud_configure_dwc2_t cfg = CFG_TUD_CONFIGURE_DWC2_DEFAULT;
|
||||
cfg.vbus_sensing = OTG_FS_VBUS_SENSE;
|
||||
tud_configure(0, TUD_CFGID_DWC2, &cfg);
|
||||
#endif
|
||||
|
||||
@ -239,10 +237,8 @@ void board_init(void) {
|
||||
__HAL_RCC_USB_OTG_HS_CLK_ENABLE();
|
||||
|
||||
#if CFG_TUD_ENABLED && BOARD_TUD_RHPORT == 1
|
||||
tud_configure_dwc2_t cfg = {
|
||||
.bm_double_buffered = 0,
|
||||
.vbus_sensing = OTG_HS_VBUS_SENSE
|
||||
};
|
||||
tud_configure_dwc2_t cfg = CFG_TUD_CONFIGURE_DWC2_DEFAULT;
|
||||
cfg.vbus_sensing = OTG_HS_VBUS_SENSE;
|
||||
tud_configure(1, TUD_CFGID_DWC2, &cfg);
|
||||
#endif
|
||||
|
||||
|
||||
@ -183,10 +183,8 @@ void board_init(void) {
|
||||
#endif // vbus sense
|
||||
|
||||
#if CFG_TUD_ENABLED && BOARD_TUD_RHPORT == 0
|
||||
tud_configure_dwc2_t cfg = {
|
||||
.bm_double_buffered = 0,
|
||||
.vbus_sensing = OTG_FS_VBUS_SENSE
|
||||
};
|
||||
tud_configure_dwc2_t cfg = CFG_TUD_CONFIGURE_DWC2_DEFAULT;
|
||||
cfg.vbus_sensing = OTG_FS_VBUS_SENSE;
|
||||
tud_configure(0, TUD_CFGID_DWC2, &cfg);
|
||||
#endif
|
||||
|
||||
@ -215,10 +213,8 @@ void board_init(void) {
|
||||
__HAL_RCC_USB1_OTG_HS_CLK_ENABLE();
|
||||
|
||||
#if CFG_TUD_ENABLED && BOARD_TUD_RHPORT == 1
|
||||
tud_configure_dwc2_t cfg = {
|
||||
.bm_double_buffered = 0,
|
||||
.vbus_sensing = OTG_HS_VBUS_SENSE
|
||||
};
|
||||
tud_configure_dwc2_t cfg = CFG_TUD_CONFIGURE_DWC2_DEFAULT;
|
||||
cfg.vbus_sensing = OTG_HS_VBUS_SENSE;
|
||||
tud_configure(1, TUD_CFGID_DWC2, &cfg);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -359,10 +359,8 @@ void board_init(void) {
|
||||
#endif // vbus sense
|
||||
|
||||
#if CFG_TUD_ENABLED && BOARD_TUD_RHPORT == 0
|
||||
tud_configure_dwc2_t cfg = {
|
||||
.bm_double_buffered = 0,
|
||||
.vbus_sensing = OTG_FS_VBUS_SENSE
|
||||
};
|
||||
tud_configure_dwc2_t cfg = CFG_TUD_CONFIGURE_DWC2_DEFAULT;
|
||||
cfg.vbus_sensing = OTG_FS_VBUS_SENSE;
|
||||
tud_configure(0, TUD_CFGID_DWC2, &cfg);
|
||||
#endif
|
||||
|
||||
@ -390,10 +388,8 @@ void board_init(void) {
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_ENABLED && BOARD_TUD_RHPORT == 1
|
||||
tud_configure_dwc2_t cfg = {
|
||||
.bm_double_buffered = 0,
|
||||
.vbus_sensing = OTG_HS_VBUS_SENSE
|
||||
};
|
||||
tud_configure_dwc2_t cfg = CFG_TUD_CONFIGURE_DWC2_DEFAULT;
|
||||
cfg.vbus_sensing = OTG_HS_VBUS_SENSE;
|
||||
tud_configure(1, TUD_CFGID_DWC2, &cfg);
|
||||
#endif
|
||||
|
||||
|
||||
@ -176,10 +176,8 @@ void board_init(void) {
|
||||
|
||||
#if CFG_TUD_ENABLED
|
||||
/* Set Vbus sense */
|
||||
tud_configure_dwc2_t cfg = {
|
||||
.bm_double_buffered = 0,
|
||||
.vbus_sensing = VBUS_SENSE_EN
|
||||
};
|
||||
tud_configure_dwc2_t cfg = CFG_TUD_CONFIGURE_DWC2_DEFAULT;
|
||||
cfg.vbus_sensing = VBUS_SENSE_EN;
|
||||
tud_configure(0, TUD_CFGID_DWC2, &cfg);
|
||||
#endif
|
||||
#else
|
||||
|
||||
@ -182,10 +182,8 @@ void board_init(void) {
|
||||
#endif // vbus sense
|
||||
|
||||
#if CFG_TUD_ENABLED
|
||||
tud_configure_dwc2_t cfg = {
|
||||
.bm_double_buffered = 0,
|
||||
.vbus_sensing = VBUS_SENSE_EN
|
||||
};
|
||||
tud_configure_dwc2_t cfg = CFG_TUD_CONFIGURE_DWC2_DEFAULT;
|
||||
cfg.vbus_sensing = VBUS_SENSE_EN;
|
||||
tud_configure(0, TUD_CFGID_DWC2, &cfg);
|
||||
#endif
|
||||
|
||||
@ -217,10 +215,8 @@ void board_init(void) {
|
||||
HAL_SYSCFG_EnableOTGPHY(SYSCFG_OTG_HS_PHY_ENABLE);
|
||||
|
||||
#if CFG_TUD_ENABLED
|
||||
tud_configure_dwc2_t cfg = {
|
||||
.bm_double_buffered = 0,
|
||||
.vbus_sensing = VBUS_SENSE_EN
|
||||
};
|
||||
tud_configure_dwc2_t cfg = CFG_TUD_CONFIGURE_DWC2_DEFAULT;
|
||||
cfg.vbus_sensing = VBUS_SENSE_EN;
|
||||
tud_configure(0, TUD_CFGID_DWC2, &cfg);
|
||||
#endif
|
||||
#endif // USB_OTG_FS
|
||||
|
||||
@ -44,7 +44,9 @@ typedef struct {
|
||||
bool vbus_sensing; // Vbus pin is used for device connection detection, mandatory for tud_umount_cb()
|
||||
} tud_configure_dwc2_t;
|
||||
|
||||
#define TUD_CONFIGURE_DWC2_DEFAULT { .bm_double_buffered = 0, .vbus_sensing = CFG_TUD_VBUS_SENSE }
|
||||
#ifndef CFG_TUD_CONFIGURE_DWC2_DEFAULT
|
||||
#define CFG_TUD_CONFIGURE_DWC2_DEFAULT {.bm_double_buffered = 0, .vbus_sensing = CFG_TUD_VBUS_DETECT_HW}
|
||||
#endif
|
||||
|
||||
typedef union {
|
||||
tud_configure_dwc2_t dwc2;
|
||||
|
||||
@ -77,7 +77,7 @@ CFG_TUD_MEM_SECTION static struct {
|
||||
TUD_EPBUF_DEF(setup_packet, 8);
|
||||
} _dcd_usbbuf;
|
||||
|
||||
static tud_configure_dwc2_t _tud_cfg = TUD_CONFIGURE_DWC2_DEFAULT;
|
||||
static tud_configure_dwc2_t _tud_cfg = CFG_TUD_CONFIGURE_DWC2_DEFAULT;
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint8_t dwc2_ep_count(const dwc2_regs_t* dwc2) {
|
||||
#if TU_CHECK_MCU(OPT_MCU_GD32VF103)
|
||||
|
||||
@ -579,13 +579,13 @@
|
||||
#define CFG_TUD_TEST_MODE 0
|
||||
#endif
|
||||
|
||||
#ifndef CFG_TUD_VBUS_SENSE_DEFAULT
|
||||
#define CFG_TUD_VBUS_SENSE_DEFAULT 0
|
||||
#ifndef CFG_TUD_VBUS_DETECT_HW_DEFAULT
|
||||
#define CFG_TUD_VBUS_DETECT_HW_DEFAULT 0
|
||||
#endif
|
||||
|
||||
// Enable VBUS Sensing
|
||||
#ifndef CFG_TUD_VBUS_SENSE
|
||||
#define CFG_TUD_VBUS_SENSE CFG_TUD_VBUS_SENSE_DEFAULT
|
||||
// Enable VBUS Detect hardware, usually via functional GPIO
|
||||
#ifndef CFG_TUD_VBUS_DETECT_HW
|
||||
#define CFG_TUD_VBUS_DETECT_HW CFG_TUD_VBUS_DETECT_HW_DEFAULT
|
||||
#endif
|
||||
|
||||
//------------- Device Class Driver -------------//
|
||||
|
||||
Reference in New Issue
Block a user