Skip to content

Commit 8f077f9

Browse files
authored
Merge pull request #3111 from hathach/ci_vbus
2 parents d3a9fee + 1a13bd8 commit 8f077f9

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/portable/chipidea/ci_hs/dcd_ci_hs.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,11 @@ bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
239239
usbmode |= USBMODE_CM_DEVICE;
240240
dcd_reg->USBMODE = usbmode;
241241

242+
#ifdef CFG_TUD_CI_HS_VBUS_CHARGE
243+
dcd_reg->OTGSC = OTGSC_VBUS_CHARGE | OTGSC_OTG_TERMINATION;
244+
#else
242245
dcd_reg->OTGSC = OTGSC_VBUS_DISCHARGE | OTGSC_OTG_TERMINATION;
246+
#endif
243247

244248
#if !TUD_OPT_HIGH_SPEED
245249
dcd_reg->PORTSC1 = PORTSC1_FORCE_FULL_SPEED;

src/tusb_option.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,15 @@
267267
#define CFG_TUD_DWC2_DMA_ENABLE CFG_TUD_DWC2_DMA_ENABLE_DEFAULT
268268
#endif
269269

270+
// Enable CI_HS VBUS Charge. Set this to 1 if the USB_VBUS pin is not connected to 5V VBUS (note: 3.3V is insufficient).
271+
#ifndef CFG_TUD_CI_HS_VBUS_CHARGE
272+
#ifndef CFG_TUD_CI_HS_VBUS_CHARGE_DEFAULT
273+
#define CFG_TUD_CI_HS_VBUS_CHARGE_DEFAULT 0
274+
#endif
275+
276+
#define CFG_TUD_CI_HS_VBUS_CHARGE CFG_TUD_CI_HS_VBUS_CHARGE_DEFAULT
277+
#endif
278+
270279
// Enable DWC2 Slave mode for host
271280
#ifndef CFG_TUH_DWC2_SLAVE_ENABLE
272281
#ifndef CFG_TUH_DWC2_SLAVE_ENABLE_DEFAULT

0 commit comments

Comments
 (0)