forked from a1exdandy/checkm8-a5
-
-
Notifications
You must be signed in to change notification settings - Fork 76
/
usb_host_library.patch
73 lines (66 loc) · 3.2 KB
/
usb_host_library.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
diff --git a/Usb.cpp b/Usb.cpp
index 7843d49b..1736914b 100644
--- a/Usb.cpp
+++ b/Usb.cpp
@@ -201,6 +201,37 @@ uint8_t USB::ctrlReq(uint8_t addr, uint8_t ep, uint8_t bmReqType, uint8_t bReque
return dispatchPkt((direction) ? tokOUTHS : tokINHS, ep, nak_limit); //GET if direction
}
+uint8_t USB::ctrlReq_SETUP(uint8_t addr, uint8_t ep, uint8_t bmReqType, uint8_t bRequest, uint8_t wValLo, uint8_t wValHi,
+ uint16_t wInd, uint16_t total) {
+ bool direction = false; //request direction, IN or OUT
+ uint8_t rcode;
+ SETUP_PKT setup_pkt;
+
+ EpInfo *pep = NULL;
+ uint16_t nak_limit = 0;
+
+ rcode = SetAddress(addr, ep, &pep, &nak_limit);
+
+ if(rcode)
+ return rcode;
+
+ direction = ((bmReqType & 0x80) > 0);
+
+ /* fill in setup packet */
+ setup_pkt.ReqType_u.bmRequestType = bmReqType;
+ setup_pkt.bRequest = bRequest;
+ setup_pkt.wVal_u.wValueLo = wValLo;
+ setup_pkt.wVal_u.wValueHi = wValHi;
+ setup_pkt.wIndex = wInd;
+ setup_pkt.wLength = total;
+
+ bytesWr(rSUDFIFO, 8, (uint8_t*) & setup_pkt); //transfer to setup packet FIFO
+
+ rcode = dispatchPkt(tokSETUP, ep, nak_limit); //dispatch packet
+
+ return rcode;
+}
+
/* IN transfer to arbitrary endpoint. Assumes PERADDR is set. Handles multiple packets if necessary. Transfers 'nbytes' bytes. */
/* Keep sending INs and writes data to memory area pointed by 'data' */
@@ -540,7 +571,7 @@ void USB::Task(void) //USB state machine
//Serial.print("\r\nConf.LS: ");
//Serial.println(lowspeed, HEX);
- rcode = Configuring(0, 0, lowspeed);
+ rcode = 0; // Configuring(0, 0, lowspeed);
if(rcode) {
if(rcode != USB_DEV_CONFIG_ERROR_DEVICE_INIT_INCOMPLETE) {
diff --git a/UsbCore.h b/UsbCore.h
index 8574d29c..7c9cbef6 100644
--- a/UsbCore.h
+++ b/UsbCore.h
@@ -104,7 +104,7 @@ typedef MAX3421e<P10, P9> MAX3421E; // Official Arduinos (UNO, Duemilanove, Mega
#define USB_ERROR_FailGetConfDescr 0xE3
#define USB_ERROR_TRANSFER_TIMEOUT 0xFF
-#define USB_XFER_TIMEOUT 5000 // (5000) USB transfer timeout in milliseconds, per section 9.2.6.1 of USB 2.0 spec
+#define USB_XFER_TIMEOUT 12 // (5000) USB transfer timeout in milliseconds, per section 9.2.6.1 of USB 2.0 spec
//#define USB_NAK_LIMIT 32000 // NAK limit for a transfer. 0 means NAKs are not counted
#define USB_RETRY_LIMIT 3 // 3 retry limit for a transfer
#define USB_SETTLE_DELAY 200 // settle delay in milliseconds
@@ -270,6 +270,8 @@ public:
uint8_t ctrlReq(uint8_t addr, uint8_t ep, uint8_t bmReqType, uint8_t bRequest, uint8_t wValLo, uint8_t wValHi,
uint16_t wInd, uint16_t total, uint16_t nbytes, uint8_t* dataptr, USBReadParser *p);
+ uint8_t ctrlReq_SETUP(uint8_t addr, uint8_t ep, uint8_t bmReqType, uint8_t bRequest, uint8_t wValLo, uint8_t wValHi,
+ uint16_t wInd, uint16_t total);
private:
void init();