Skip to content

Commit

Permalink
fix cdcacm: need to force a valid OTG session if BOARD_USB_VBUS_SENSE…
Browse files Browse the repository at this point in the history
…_DISABLED

Required for example on STM32F745 boards.
  • Loading branch information
bkueng committed Jul 10, 2019
1 parent 0dd6547 commit cb6c054
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions stm32/cdcacm.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@
#if INTERFACE_USB != 0
#define USB_CDC_REQ_GET_LINE_CODING 0x21 // Not defined in libopencm3

#ifndef OTG_GOTGCTL_BVALOVAL
#define OTG_GOTGCTL_BVALOVAL (1 << 7)
#endif
#ifndef OTG_GOTGCTL_BVALOEN
#define OTG_GOTGCTL_BVALOEN (1 << 6)
#endif

/*
* ST changed the meaning and sense of a few critical bits
* in the USB IP block identified as 0x00002000
Expand Down Expand Up @@ -316,6 +323,9 @@ usb_cinit(void)

#if defined(BOARD_USB_VBUS_SENSE_DISABLED)
OTG_FS_GCCFG |= OTG_GCCFG_NOVBUSSENS;

/* Force valid B-peripheral session */
OTG_FS_GOTGCTL |= OTG_GOTGCTL_BVALOEN | OTG_GOTGCTL_BVALOVAL;
#endif

usbd_dev = usbd_init(&otgfs_usb_driver, &dev, &config, usb_strings, NUM_USB_STRINGS,
Expand Down

0 comments on commit cb6c054

Please sign in to comment.