Skip to content

Commit 641c316

Browse files
author
Alrik Vidstrom
committed
Add short delay after request to disable channel
Adds a 50 us delay after the request to disable a channel, to give it time to actually disable.
1 parent a40f1ad commit 641c316

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/targets/TARGET_STM/USBEndpoint_STM.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,12 @@ void USBEndpoint::setState(USB_TYPE st)
118118
USBx_HC(hced->ch_num)->HCCHAR |= USB_OTG_HCCHAR_CHDIS;
119119
// Disable the channel
120120
USBx_HC(hced->ch_num)->HCCHAR |= USB_OTG_HCCHAR_CHDIS | USB_OTG_HCCHAR_CHENA;
121-
// <-- Notice the lack of error handling here - after testing a lot of
122-
// combinations, it seems that the USB host controller doesn't work fully
123-
// according to the reference manual in this aspect, which might also
124-
// be the reason for lacking error handling in the ST USB LL
121+
// Notice the lack of error handling here - after testing a lot of
122+
// combinations, it seems that the USB host controller doesn't work fully
123+
// according to the reference manual in this aspect, which might also
124+
// be the reason for lacking error handling in the ST USB LL - instead,
125+
// we use a 50 us delay to wait for the channel to disable
126+
wait_us(50);
125127

126128
HAL_HCD_DisableInt((HCD_HandleTypeDef *)hced->hhcd, hced->ch_num);
127129
*addr = 0;
@@ -132,10 +134,12 @@ void USBEndpoint::setState(USB_TYPE st)
132134
USBx_HC(hced->ch_num)->HCCHAR |= USB_OTG_HCCHAR_CHDIS;
133135
// Disable the channel
134136
USBx_HC(hced->ch_num)->HCCHAR |= USB_OTG_HCCHAR_CHDIS | USB_OTG_HCCHAR_CHENA;
135-
// <-- Notice the lack of error handling here - after testing a lot of
136-
// combinations, it seems that the USB host controller doesn't work fully
137-
// according to the reference manual in this aspect, which might also
138-
// be the reason for lacking error handling in the ST USB LL
137+
// Notice the lack of error handling here - after testing a lot of
138+
// combinations, it seems that the USB host controller doesn't work fully
139+
// according to the reference manual in this aspect, which might also
140+
// be the reason for lacking error handling in the ST USB LL - instead,
141+
// we use a 50 us delay to wait for the channel to disable
142+
wait_us(50);
139143

140144
HAL_HCD_DisableInt((HCD_HandleTypeDef *)hced->hhcd, hced->ch_num);
141145
uint8_t hcd_speed = HCD_SPEED_FULL;

0 commit comments

Comments
 (0)