@@ -66,7 +66,7 @@ struct dwc2_hcd {
66
66
#define DWC2_EP0_STATE_INSTATUS 3
67
67
#define DWC2_EP0_STATE_OUTSTATUS 4
68
68
69
- static inline int dwc2_reset (uint8_t busid )
69
+ static inline int dwc2_reset (struct usbh_bus * bus )
70
70
{
71
71
volatile uint32_t count = 0U ;
72
72
@@ -81,7 +81,7 @@ static inline int dwc2_reset(uint8_t busid)
81
81
count = 0U ;
82
82
USB_OTG_GLB -> GRSTCTL |= USB_OTG_GRSTCTL_CSRST ;
83
83
84
- if (g_dwc2_udc [ busid ].GSNPSID < 0x4F54420AU ) {
84
+ if (g_dwc2_hcd [ bus -> hcd . hcd_id ].GSNPSID < 0x4F54420AU ) {
85
85
do {
86
86
if (++ count > 200000U ) {
87
87
USB_LOG_ERR ("DWC2 reset timeout\r\n" );
@@ -326,19 +326,24 @@ static inline void dwc2_chan_transfer(struct usbh_bus *bus, uint8_t ch_num, uint
326
326
static void dwc2_halt (struct usbh_bus * bus , uint8_t ch_num )
327
327
{
328
328
volatile uint32_t ChannelEna = (USB_OTG_HC (ch_num )-> HCCHAR & USB_OTG_HCCHAR_CHENA ) >> 31 ;
329
+ volatile uint32_t HcEpType = (USB_OTG_HC (ch_num )-> HCCHAR & USB_OTG_HCCHAR_EPTYP ) >> 18 ;
330
+ volatile uint32_t SplitEna = (USB_OTG_HC (ch_num )-> HCSPLT & USB_OTG_HCSPLT_SPLITEN ) >> 31 ;
329
331
volatile uint32_t count = 0U ;
330
- __IO uint32_t value ;
332
+ volatile uint32_t value ;
331
333
332
- if (((USB_OTG_GLB -> GAHBCFG & USB_OTG_GAHBCFG_DMAEN ) == USB_OTG_GAHBCFG_DMAEN ) &&
333
- (ChannelEna == 0U )) {
334
+ /* In buffer DMA, Channel disable must not be programmed for non-split periodic channels.
335
+ At the end of the next uframe/frame (in the worst case), the core generates a channel halted
336
+ and disables the channel automatically. */
337
+ if ((((USB_OTG_GLB -> GAHBCFG & USB_OTG_GAHBCFG_DMAEN ) == USB_OTG_GAHBCFG_DMAEN ) && (SplitEna == 0U )) &&
338
+ ((ChannelEna == 0U ) || (((HcEpType == HCCHAR_ISOC ) || (HcEpType == HCCHAR_INTR ))))) {
334
339
return ;
335
340
}
336
341
337
342
USB_OTG_HC (ch_num )-> HCINTMSK = 0 ;
338
343
339
344
value = USB_OTG_HC (ch_num )-> HCCHAR ;
340
345
value |= USB_OTG_HCCHAR_CHDIS ;
341
- value &= ~ USB_OTG_HCCHAR_CHENA ;
346
+ value |= USB_OTG_HCCHAR_CHENA ;
342
347
value &= ~USB_OTG_HCCHAR_EPDIR ;
343
348
USB_OTG_HC (ch_num )-> HCCHAR = value ;
344
349
do {
@@ -360,7 +365,7 @@ static int usbh_reset_port(struct usbh_bus *bus, const uint8_t port)
360
365
USB_OTG_HPRT_PENCHNG | USB_OTG_HPRT_POCCHNG );
361
366
362
367
USB_OTG_HPRT = (USB_OTG_HPRT_PRST | hprt0 );
363
- usb_osal_msleep (100U ); /* See Note #1 */
368
+ usb_osal_msleep (100U );
364
369
USB_OTG_HPRT = ((~USB_OTG_HPRT_PRST ) & hprt0 );
365
370
usb_osal_msleep (10U );
366
371
@@ -388,7 +393,7 @@ static inline uint16_t dwc2_get_full_frame_num(struct usbh_bus *bus)
388
393
{
389
394
uint16_t frame = usbh_get_frame_number (bus );
390
395
391
- /* USB_OTG_HFNUM_FRNUM_Msk is 0xFFFF�� but max frame num is 0x3FFF */
396
+ /* USB_OTG_HFNUM_FRNUM_Msk is 0xFFFF but max frame num is 0x3FFF */
392
397
return ((frame & 0x3FFF ) >> 3 );
393
398
}
394
399
0 commit comments