summaryrefslogtreecommitdiff
path: root/src/device/usbd.c
diff options
context:
space:
mode:
authorHa Thach <[email protected]>2021-09-01 20:18:01 +0700
committerGitHub <[email protected]>2021-09-01 20:18:01 +0700
commit831a45f14bcc833d536cab39bef61cc67533fa73 (patch)
treea06c49a362535f17174ce3058c867f4f21bf0df0 /src/device/usbd.c
parente2175f6ed1e9a42c76dacf345d51ba61eecd8a6a (diff)
parentd4c56c70a80a6df81f403627e897c50b0a94601e (diff)
Merge pull request #1065 from hathach/rp2040-compliance
Rp2040 compliance test
Diffstat (limited to 'src/device/usbd.c')
-rw-r--r--src/device/usbd.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/device/usbd.c b/src/device/usbd.c
index 7cd8fad42..a52ea9afe 100644
--- a/src/device/usbd.c
+++ b/src/device/usbd.c
@@ -1333,26 +1333,33 @@ bool usbd_edpt_busy(uint8_t rhport, uint8_t ep_addr)
void usbd_edpt_stall(uint8_t rhport, uint8_t ep_addr)
{
- TU_LOG(USBD_DBG, " Stall EP %02X\r\n", ep_addr);
uint8_t const epnum = tu_edpt_number(ep_addr);
uint8_t const dir = tu_edpt_dir(ep_addr);
- dcd_edpt_stall(rhport, ep_addr);
- _usbd_dev.ep_status[epnum][dir].stalled = true;
- _usbd_dev.ep_status[epnum][dir].busy = true;
+ // only stalled if currently cleared
+ if ( !_usbd_dev.ep_status[epnum][dir].stalled )
+ {
+ TU_LOG(USBD_DBG, " Stall EP %02X\r\n", ep_addr);
+ dcd_edpt_stall(rhport, ep_addr);
+ _usbd_dev.ep_status[epnum][dir].stalled = true;
+ _usbd_dev.ep_status[epnum][dir].busy = true;
+ }
}
void usbd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr)
{
- TU_LOG(USBD_DBG, " Clear Stall EP %02X\r\n", ep_addr);
-
uint8_t const epnum = tu_edpt_number(ep_addr);
uint8_t const dir = tu_edpt_dir(ep_addr);
- dcd_edpt_clear_stall(rhport, ep_addr);
- _usbd_dev.ep_status[epnum][dir].stalled = false;
- _usbd_dev.ep_status[epnum][dir].busy = false;
+ // only clear if currently stalled
+ if ( _usbd_dev.ep_status[epnum][dir].stalled )
+ {
+ TU_LOG(USBD_DBG, " Clear Stall EP %02X\r\n", ep_addr);
+ dcd_edpt_clear_stall(rhport, ep_addr);
+ _usbd_dev.ep_status[epnum][dir].stalled = false;
+ _usbd_dev.ep_status[epnum][dir].busy = false;
+ }
}
bool usbd_edpt_stalled(uint8_t rhport, uint8_t ep_addr)