Skip to content

Commit 13c5129

Browse files
committed
Fix everything
1 parent 21befbb commit 13c5129

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

src/USBHost/USBHostTypes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ enum ENDPOINT_TYPE {
119119

120120
#else
121121

122-
#define TD_TIMEOUT_CTRL 100
122+
#define TD_TIMEOUT_CTRL 400
123123
#define TD_TIMEOUT 2000
124124
#define TD_SETUP (uint32_t)(0) // Direction of Setup Packet
125125
#define TD_IN (uint32_t)(0x00100000) // Direction In

src/USBHost/dbg.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
#define USB_DEBUG_H
1919

2020
//Debug is disabled by default
21-
#define DEBUG 2 /*INFO,ERR,WARN*/
21+
#define DEBUG 0 /*INFO,ERR,WARN*/
2222
#define DEBUG_TRANSFER 0
2323
#define DEBUG_EP_STATE 0
24-
#define DEBUG_EVENT 1
24+
#define DEBUG_EVENT 0
2525

2626
#if (DEBUG > 3)
2727
#define USB_DBG(x, ...) if (rtos::ThisThread::get_id() != 0) { printf("[USB_DBG: %s:%d]" x "\r\n", __FILE__, __LINE__, ##__VA_ARGS__); }

src/targets/TARGET_STM/USBHALHost_STM.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,19 @@ void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd, uint8_t chnum,
127127
HAL_HCD_DisableInt(hhcd, chnum);
128128

129129
} else {
130-
td->state = (urb_state == URB_DONE) ? USB_TYPE_IDLE : USB_TYPE_ERROR;
130+
if (urb_state == URB_DONE) {
131+
td->state = USB_TYPE_IDLE;
132+
}
133+
else if (urb_state == URB_ERROR) {
134+
td->state = USB_TYPE_ERROR;
135+
} else {
136+
td->state = USB_TYPE_PROCESSING;
137+
}
138+
}
139+
if (td->state == USB_TYPE_IDLE) {
140+
td->currBufPtr += HAL_HCD_HC_GetXferCount(hhcd, chnum);
141+
(obj->*func)(addr);
131142
}
132-
td->currBufPtr += HAL_HCD_HC_GetXferCount(hhcd, chnum);
133-
(obj->*func)(addr);
134143
} else {
135144
if (urb_state != 0) {
136145
//USB_DBG_EVENT("spurious %d %d", chnum, urb_state);

0 commit comments

Comments
 (0)