From 8336c18ac2aa390c9888f6a469ef9d1f34a79d3f Mon Sep 17 00:00:00 2001 From: "Deployment Bot (from Travis CI)" Date: Sun, 18 Nov 2018 09:53:17 +0000 Subject: [PATCH] Deploy felis/USB_Host_Shield_2.0 to github.com/felis/USB_Host_Shield_2.0.git:gh-pages --- _b_t_d_8cpp_source.html | 16 +- _p_s3_u_s_b_8cpp_source.html | 14 +- _p_s4_u_s_b_8h_source.html | 2 +- _p_s_buzz_8cpp_source.html | 2 +- _u_h_s2__gpio_8cpp_source.html | 6 +- _usb_8cpp_source.html | 1649 ++++++++++++++-------------- _usb_core_8h_source.html | 36 +- _x_b_o_x_o_l_d_8cpp_source.html | 12 +- _x_b_o_x_o_n_e_8cpp_source.html | 14 +- _x_b_o_x_r_e_c_v_8cpp_source.html | 12 +- _x_b_o_x_u_s_b_8cpp_source.html | 12 +- adk_8cpp_source.html | 14 +- adk_8h_source.html | 2 +- cdc___x_r21_b1411_8cpp_source.html | 10 +- cdc___x_r21_b1411_8h_source.html | 2 +- cdcacm_8cpp_source.html | 16 +- cdcftdi_8cpp_source.html | 617 ++++++----- cdcftdi_8h.html | 118 +- cdcftdi_8h_source.html | 260 ++--- cdcprolific_8cpp_source.html | 10 +- cdcprolific_8h_source.html | 2 +- class_f_t_d_i-members.html | 20 +- class_f_t_d_i.html | 66 +- class_f_t_d_i_async_oper.html | 6 +- class_m_a_x3421e.html | 22 +- class_u_s_b.html | 38 +- functions_func_g.html | 3 + functions_func_s.html | 5 +- functions_g.html | 3 + functions_s.html | 7 +- globals_defs_f.html | 6 + globals_f.html | 6 + hidcomposite_8cpp_source.html | 14 +- hiduniversal_8cpp_source.html | 14 +- masstorage_8cpp_source.html | 16 +- search/all_10.js | 2 +- search/all_12.js | 2 +- search/all_13.js | 1 + search/all_15.js | 2 +- search/all_16.js | 2 +- search/all_6.js | 2 + search/all_7.js | 1 + search/defines_6.js | 2 + search/functions_10.js | 1 + search/functions_6.js | 1 + search/functions_f.js | 2 +- search/variables_15.js | 2 +- search/variables_f.js | 2 +- usbh__midi_8cpp_source.html | 14 +- usbh__midi_8h_source.html | 2 +- usbhid_8cpp_source.html | 2 +- usbhost_8h_source.html | 676 ++++++------ usbhub_8cpp_source.html | 16 +- usbhub_8h_source.html | 2 +- 54 files changed, 1979 insertions(+), 1807 deletions(-) diff --git a/_b_t_d_8cpp_source.html b/_b_t_d_8cpp_source.html index e5a24558..75d85d94 100644 --- a/_b_t_d_8cpp_source.html +++ b/_b_t_d_8cpp_source.html @@ -1470,7 +1470,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
1383  pUsb->ctrlReq(bAddress, epInfo[BTD_CONTROL_PIPE].epAddr, bmREQ_HID_OUT, HID_REQUEST_SET_REPORT, 0x05, 0x03, 0x00, 11, 11, buf, NULL);
1384 }
static const uint8_t BTD_DATAOUT_PIPE
Definition: BTD.h:525
-
uint8_t getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t conf, uint8_t *dataptr)
Definition: Usb.cpp:784
+
uint8_t getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t conf, uint8_t *dataptr)
Definition: Usb.cpp:801
uint8_t bmRcvToggle
Definition: address.h:48
bool incomingWii
Definition: BTD.h:474
Definition: address.h:90
@@ -1515,7 +1515,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
#define HCI_DISCONNECT_STATE
Definition: BTD.h:61
#define HCI_FLAG_CONNECT_COMPLETE
Definition: BTD.h:65
#define EV_PIN_CODE_REQUEST
Definition: BTD.h:91
-
uint8_t setConf(uint8_t addr, uint8_t ep, uint8_t conf_value)
Definition: Usb.cpp:823
+
uint8_t setConf(uint8_t addr, uint8_t ep, uint8_t conf_value)
Definition: Usb.cpp:840
const char * btdPin
Definition: BTD.h:449
bool motionPlusInside
Definition: BTD.h:478
#define EV_AUTHENTICATION_COMPLETE
Definition: BTD.h:85
@@ -1533,7 +1533,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
BTD(USB *p)
Definition: BTD.cpp:27
char remote_name[30]
Definition: BTD.h:458
#define hrJERR
Definition: max3421e.h:227
-
uint8_t setEpInfoEntry(uint8_t addr, uint8_t epcount, EpInfo *eprecord_ptr)
Definition: Usb.cpp:71
+
uint8_t setEpInfoEntry(uint8_t addr, uint8_t epcount, EpInfo *eprecord_ptr)
Definition: Usb.cpp:64
virtual void Reset()=0
#define EV_MAX_SLOTS_CHANGE
Definition: BTD.h:95
static const uint8_t BTD_DATAIN_PIPE
Definition: BTD.h:523
@@ -1543,7 +1543,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
uint8_t Release()
Definition: BTD.cpp:376
virtual void FreeAddress(uint8_t addr)=0
void l2cap_disconnection_response(uint16_t handle, uint8_t rxid, uint8_t *dcid, uint8_t *scid)
Definition: BTD.cpp:1326
-
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)
Definition: Usb.cpp:133
+
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)
Definition: Usb.cpp:126
virtual UsbDevice * GetUsbDevicePtr(uint8_t addr)=0
#define HCI_BDADDR_STATE
Definition: BTD.h:46
#define HCI_CONNECT_DEVICE_STATE
Definition: BTD.h:52
@@ -1551,7 +1551,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
bool connectToHIDDevice
Definition: BTD.h:487
uint8_t bmAttributes
Definition: usb_ch9.h:152
-
uint8_t setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr)
Definition: Usb.cpp:814
+
uint8_t setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr)
Definition: Usb.cpp:831
uint8_t bAddress
Definition: BTD.h:507
#define NotifyFailGetConfDescr(...)
Definition: message.h:59
uint8_t epAddr
Definition: address.h:40
@@ -1576,7 +1576,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
Definition: address.h:39
void hci_disconnect(uint16_t handle)
Definition: BTD.cpp:1171
#define HCI_RESET_STATE
Definition: BTD.h:44
-
uint8_t outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *data)
Definition: Usb.cpp:300
+
uint8_t outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *data)
Definition: Usb.cpp:303
#define hrNAK
Definition: max3421e.h:218
void hci_read_bdaddr()
Definition: BTD.cpp:984
void hci_inquiry_cancel()
Definition: BTD.cpp:1063
@@ -1626,7 +1626,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
#define hci_set_flag(flag)
Definition: BTD.h:76
void hci_write_class_of_device()
Definition: BTD.cpp:1183
#define HCI_CONNECTED_DEVICE_STATE
Definition: BTD.h:53
-
uint8_t inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t *data, uint8_t bInterval=0)
Definition: Usb.cpp:213
+
uint8_t inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t *data, uint8_t bInterval=0)
Definition: Usb.cpp:209
#define HCI_INIT_STATE
Definition: BTD.h:43
void hci_pin_code_negative_request_reply()
Definition: BTD.cpp:1133
#define EV_CHANGE_CONNECTION_LINK
Definition: BTD.h:88
@@ -1664,7 +1664,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
#define EV_PAGE_SCAN_REP_MODE
Definition: BTD.h:101
#define HCI_FLAG_DEVICE_FOUND
Definition: BTD.h:71
#define HCI_CLASS_STATE
Definition: BTD.h:45
-
uint8_t getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *dataptr)
defined(USB_METHODS_INLINE)
Definition: Usb.cpp:779
+
uint8_t getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *dataptr)
defined(USB_METHODS_INLINE)
Definition: Usb.cpp:796
#define NotifyFailSetDevTblEntry(...)
Definition: message.h:58
#define USB_ERROR_CONFIG_REQUIRES_ADDITIONAL_RESET
Definition: UsbCore.h:101
void HCI_Command(uint8_t *data, uint16_t nbytes)
Definition: BTD.cpp:948
diff --git a/_p_s3_u_s_b_8cpp_source.html b/_p_s3_u_s_b_8cpp_source.html index 0f7a4fc4..fae90355 100644 --- a/_p_s3_u_s_b_8cpp_source.html +++ b/_p_s3_u_s_b_8cpp_source.html @@ -688,7 +688,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
bool PS3MoveConnected
Definition: PS3USB.h:262
AnalogHatEnum
-
uint8_t setConf(uint8_t addr, uint8_t ep, uint8_t conf_value)
Definition: Usb.cpp:823
+
uint8_t setConf(uint8_t addr, uint8_t ep, uint8_t conf_value)
Definition: Usb.cpp:840
Definition: PS3Enums.h:121
Definition: PS3Enums.h:119
#define USB_TRANSFER_TYPE_INTERRUPT
Definition: usb_ch9.h:93
@@ -701,7 +701,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
uint8_t getAnalogButton(ButtonEnum a)
Definition: PS3USB.cpp:327
uint16_t getSensor(SensorEnum a)
Definition: PS3USB.cpp:335
-
uint8_t setEpInfoEntry(uint8_t addr, uint8_t epcount, EpInfo *eprecord_ptr)
Definition: Usb.cpp:71
+
uint8_t setEpInfoEntry(uint8_t addr, uint8_t epcount, EpInfo *eprecord_ptr)
Definition: Usb.cpp:64
void setRumbleOff()
Definition: PS3USB.cpp:410
const uint32_t PS3_BUTTONS[]
Definition: PS3Enums.h:62
#define EP_MAXPKTSIZE
Definition: PS3USB.h:26
@@ -709,12 +709,12 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
virtual void FreeAddress(uint8_t addr)=0
LEDEnum
uint8_t epAttribs
Definition: address.h:44
-
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)
Definition: Usb.cpp:133
+
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)
Definition: Usb.cpp:126
virtual UsbDevice * GetUsbDevicePtr(uint8_t addr)=0
#define Notify(...)
Definition: message.h:51
#define PS3_CONTROL_PIPE
Definition: PS3USB.h:29
RumbleEnum
-
uint8_t setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr)
Definition: Usb.cpp:814
+
uint8_t setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr)
Definition: Usb.cpp:831
#define USB_HOST_SERIAL
Definition: settings.h:49
void setLedToggle(LEDEnum a)
Definition: PS3USB.cpp:460
uint8_t epAddr
Definition: address.h:40
@@ -728,7 +728,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
#define MOVE_REPORT_BUFFER_SIZE
Definition: PS3Enums.h:40
void printStatusString()
Definition: PS3USB.cpp:364
void setAllOff()
Definition: PS3USB.cpp:403
-
uint8_t outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *data)
Definition: Usb.cpp:300
+
uint8_t outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *data)
Definition: Usb.cpp:303
ButtonEnum
const uint8_t PS3_LEDS[]
Definition: PS3Enums.h:43
@@ -755,7 +755,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
EpInfo epInfo[PS3_MAX_ENDPOINTS]
Definition: PS3USB.h:272
void setRumbleOn(RumbleEnum mode)
Definition: PS3USB.cpp:420
Definition: PS3Enums.h:137
-
uint8_t inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t *data, uint8_t bInterval=0)
Definition: Usb.cpp:213
+
uint8_t inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t *data, uint8_t bInterval=0)
Definition: Usb.cpp:209
Definition: PS3Enums.h:120
#define USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL
Definition: UsbCore.h:93
@@ -780,7 +780,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
void getMoveCalibration(uint8_t *data)
Definition: PS3USB.cpp:553
Definition: PS3Enums.h:125
bool getStatus(StatusEnum c)
Definition: PS3USB.cpp:360
-
uint8_t getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *dataptr)
defined(USB_METHODS_INLINE)
Definition: Usb.cpp:779
+
uint8_t getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *dataptr)
defined(USB_METHODS_INLINE)
Definition: Usb.cpp:796
#define NotifyFailSetDevTblEntry(...)
Definition: message.h:58
const uint8_t PS3_REPORT_BUFFER[PS3_REPORT_BUFFER_SIZE]
Definition: PS3Enums.h:27
bool getButtonClick(ButtonEnum b)
Definition: PS3USB.cpp:320
diff --git a/_p_s4_u_s_b_8h_source.html b/_p_s4_u_s_b_8h_source.html index db93c74f..c3edaee2 100644 --- a/_p_s4_u_s_b_8h_source.html +++ b/_p_s4_u_s_b_8h_source.html @@ -191,7 +191,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
uint8_t g
Definition: PS4Parser.h:118
bool reportChanged
Definition: PS4Parser.h:120
void Parse(uint8_t len, uint8_t *buf)
Definition: PS4Parser.cpp:76
-
uint8_t outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *data)
Definition: Usb.cpp:300
+
uint8_t outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *data)
Definition: Usb.cpp:303
static const uint8_t epInterruptOutIndex
Definition: usbhid.h:150
uint8_t bAddress
Definition: usbhid.h:146
uint8_t r
Definition: PS4Parser.h:118
diff --git a/_p_s_buzz_8cpp_source.html b/_p_s_buzz_8cpp_source.html index 4c082b6e..ede35247 100644 --- a/_p_s_buzz_8cpp_source.html +++ b/_p_s_buzz_8cpp_source.html @@ -175,7 +175,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
bool getButtonClick(ButtonEnum b, uint8_t controller=0)
Definition: PSBuzz.cpp:56
#define bmREQ_HID_OUT
Definition: usbhid.h:63
uint16_t VID
Definition: hiduniversal.h:69
-
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)
Definition: Usb.cpp:133
+
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)
Definition: Usb.cpp:126
#define Notify(...)
Definition: message.h:51
bool getButtonPress(ButtonEnum b, uint8_t controller=0)
Definition: PSBuzz.cpp:52
diff --git a/_u_h_s2__gpio_8cpp_source.html b/_u_h_s2__gpio_8cpp_source.html index 0f4d8919..3080c6d0 100644 --- a/_u_h_s2__gpio_8cpp_source.html +++ b/_u_h_s2__gpio_8cpp_source.html @@ -146,9 +146,9 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
int digitalReadOutput(uint8_t pin)
Read the value from a GPIO output pin.
Definition: UHS2_gpio.cpp:68
int digitalRead(uint8_t pin)
Read the value from a GPIO input pin.
Definition: UHS2_gpio.cpp:55
-
uint8_t gpioRdOutput()
Reads the current GPI output values.
Definition: usbhost.h:401
-
void gpioWr(uint8_t data)
Definition: usbhost.h:274
-
uint8_t gpioRd()
Reads the current GPI input values.
Definition: usbhost.h:388
+
uint8_t gpioRdOutput()
Reads the current GPI output values.
Definition: usbhost.h:403
+
void gpioWr(uint8_t data)
Definition: usbhost.h:275
+
uint8_t gpioRd()
Reads the current GPI input values.
Definition: usbhost.h:390
void digitalWrite(uint8_t pin, uint8_t val)
Set a GPIO output value.
Definition: UHS2_gpio.cpp:40
UHS2_GPIO(USB *pUsb)
Implement an instance of a UHS2_GPIO object.
Definition: UHS2_gpio.cpp:32
Definition: UsbCore.h:210
diff --git a/_usb_8cpp_source.html b/_usb_8cpp_source.html index f03eec4d..7b185e1f 100644 --- a/_usb_8cpp_source.html +++ b/_usb_8cpp_source.html @@ -87,832 +87,849 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
Go to the documentation of this file.
1 /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
2 
-
3 This program is free software; you can redistribute it and/or modify
-
4 it under the terms of the GNU General Public License as published by
-
5 the Free Software Foundation; either version 2 of the License, or
-
6 (at your option) any later version.
-
7 
-
8 This program is distributed in the hope that it will be useful,
-
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
-
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-
11 GNU General Public License for more details.
+
3 This software may be distributed and modified under the terms of the GNU
+
4 General Public License version 2 (GPL2) as published by the Free Software
+
5 Foundation and appearing in the file GPL2.TXT included in the packaging of
+
6 this file. Please note that GPL2 Section 2[b] requires that all works based
+
7 on this software must also be made publicly available under the terms of
+
8 the GPL2 ("Copyleft").
+
9 
+
10 Contact information
+
11 -------------------
12 
-
13 You should have received a copy of the GNU General Public License
-
14 along with this program; if not, write to the Free Software
-
15 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
16 
-
17 Contact information
-
18 -------------------
-
19 
-
20 Circuits At Home, LTD
-
21 Web : http://www.circuitsathome.com
-
22 e-mail : support@circuitsathome.com
-
23  */
-
24 /* USB functions */
-
25 
-
26 #include "Usb.h"
-
27 
-
28 static uint8_t usb_error = 0;
-
29 static uint8_t usb_task_state;
-
30 
-
31 /* constructor */
-
32 USB::USB() : bmHubPre(0) {
-
33  usb_task_state = USB_DETACHED_SUBSTATE_INITIALIZE; //set up state machine
-
34  init();
-
35 }
-
36 
-
37 /* Initialize data structures */
-
38 void USB::init() {
-
39  //devConfigIndex = 0;
-
40  bmHubPre = 0;
-
41 }
-
42 
-
43 uint8_t USB::getUsbTaskState(void) {
-
44  return ( usb_task_state);
-
45 }
+
13 Circuits At Home, LTD
+
14 Web : http://www.circuitsathome.com
+
15 e-mail : support@circuitsathome.com
+
16  */
+
17 /* USB functions */
+
18 
+
19 #include "Usb.h"
+
20 
+
21 static uint8_t usb_error = 0;
+
22 static uint8_t usb_task_state;
+
23 
+
24 /* constructor */
+
25 USB::USB() : bmHubPre(0) {
+
26  usb_task_state = USB_DETACHED_SUBSTATE_INITIALIZE; //set up state machine
+
27  init();
+
28 }
+
29 
+
30 /* Initialize data structures */
+
31 void USB::init() {
+
32  //devConfigIndex = 0;
+
33  bmHubPre = 0;
+
34 }
+
35 
+
36 uint8_t USB::getUsbTaskState(void) {
+
37  return ( usb_task_state);
+
38 }
+
39 
+
40 void USB::setUsbTaskState(uint8_t state) {
+
41  usb_task_state = state;
+
42 }
+
43 
+
44 EpInfo* USB::getEpInfoEntry(uint8_t addr, uint8_t ep) {
+
45  UsbDevice *p = addrPool.GetUsbDevicePtr(addr);
46 
-
47 void USB::setUsbTaskState(uint8_t state) {
-
48  usb_task_state = state;
-
49 }
-
50 
-
51 EpInfo* USB::getEpInfoEntry(uint8_t addr, uint8_t ep) {
-
52  UsbDevice *p = addrPool.GetUsbDevicePtr(addr);
-
53 
-
54  if(!p || !p->epinfo)
-
55  return NULL;
-
56 
-
57  EpInfo *pep = p->epinfo;
-
58 
-
59  for(uint8_t i = 0; i < p->epcount; i++) {
-
60  if((pep)->epAddr == ep)
-
61  return pep;
+
47  if(!p || !p->epinfo)
+
48  return NULL;
+
49 
+
50  EpInfo *pep = p->epinfo;
+
51 
+
52  for(uint8_t i = 0; i < p->epcount; i++) {
+
53  if((pep)->epAddr == ep)
+
54  return pep;
+
55 
+
56  pep++;
+
57  }
+
58  return NULL;
+
59 }
+
60 
+
61 /* set device table entry */
62 
-
63  pep++;
-
64  }
-
65  return NULL;
-
66 }
+
63 /* each device is different and has different number of endpoints. This function plugs endpoint record structure, defined in application, to devtable */
+
64 uint8_t USB::setEpInfoEntry(uint8_t addr, uint8_t epcount, EpInfo* eprecord_ptr) {
+
65  if(!eprecord_ptr)
+
67 
-
68 /* set device table entry */
+
68  UsbDevice *p = addrPool.GetUsbDevicePtr(addr);
69 
-
70 /* each device is different and has different number of endpoints. This function plugs endpoint record structure, defined in application, to devtable */
-
71 uint8_t USB::setEpInfoEntry(uint8_t addr, uint8_t epcount, EpInfo* eprecord_ptr) {
-
72  if(!eprecord_ptr)
- -
74 
-
75  UsbDevice *p = addrPool.GetUsbDevicePtr(addr);
+
70  if(!p)
+ +
72 
+
73  p->address.devAddress = addr;
+
74  p->epinfo = eprecord_ptr;
+
75  p->epcount = epcount;
76 
-
77  if(!p)
- +
77  return 0;
+
78 }
79 
-
80  p->address.devAddress = addr;
-
81  p->epinfo = eprecord_ptr;
-
82  p->epcount = epcount;
-
83 
-
84  return 0;
-
85 }
-
86 
-
87 uint8_t USB::SetAddress(uint8_t addr, uint8_t ep, EpInfo **ppep, uint16_t *nak_limit) {
-
88  UsbDevice *p = addrPool.GetUsbDevicePtr(addr);
-
89 
-
90  if(!p)
- -
92 
-
93  if(!p->epinfo)
- -
95 
-
96  *ppep = getEpInfoEntry(addr, ep);
-
97 
-
98  if(!*ppep)
- -
100 
-
101  *nak_limit = (0x0001UL << (((*ppep)->bmNakPower > USB_NAK_MAX_POWER) ? USB_NAK_MAX_POWER : (*ppep)->bmNakPower));
-
102  (*nak_limit)--;
-
103  /*
-
104  USBTRACE2("\r\nAddress: ", addr);
-
105  USBTRACE2(" EP: ", ep);
-
106  USBTRACE2(" NAK Power: ",(*ppep)->bmNakPower);
-
107  USBTRACE2(" NAK Limit: ", nak_limit);
-
108  USBTRACE("\r\n");
-
109  */
-
110  regWr(rPERADDR, addr); //set peripheral address
+
80 uint8_t USB::SetAddress(uint8_t addr, uint8_t ep, EpInfo **ppep, uint16_t *nak_limit) {
+
81  UsbDevice *p = addrPool.GetUsbDevicePtr(addr);
+
82 
+
83  if(!p)
+ +
85 
+
86  if(!p->epinfo)
+ +
88 
+
89  *ppep = getEpInfoEntry(addr, ep);
+
90 
+
91  if(!*ppep)
+ +
93 
+
94  *nak_limit = (0x0001UL << (((*ppep)->bmNakPower > USB_NAK_MAX_POWER) ? USB_NAK_MAX_POWER : (*ppep)->bmNakPower));
+
95  (*nak_limit)--;
+
96  /*
+
97  USBTRACE2("\r\nAddress: ", addr);
+
98  USBTRACE2(" EP: ", ep);
+
99  USBTRACE2(" NAK Power: ",(*ppep)->bmNakPower);
+
100  USBTRACE2(" NAK Limit: ", nak_limit);
+
101  USBTRACE("\r\n");
+
102  */
+
103  regWr(rPERADDR, addr); //set peripheral address
+
104 
+
105  uint8_t mode = regRd(rMODE);
+
106 
+
107  //Serial.print("\r\nMode: ");
+
108  //Serial.println( mode, HEX);
+
109  //Serial.print("\r\nLS: ");
+
110  //Serial.println(p->lowspeed, HEX);
111 
-
112  uint8_t mode = regRd(rMODE);
+
112 
113 
-
114  //Serial.print("\r\nMode: ");
-
115  //Serial.println( mode, HEX);
-
116  //Serial.print("\r\nLS: ");
-
117  //Serial.println(p->lowspeed, HEX);
-
118 
+
114  // Set bmLOWSPEED and bmHUBPRE in case of low-speed device, reset them otherwise
+
115  regWr(rMODE, (p->lowspeed) ? mode | bmLOWSPEED | bmHubPre : mode & ~(bmHUBPRE | bmLOWSPEED));
+
116 
+
117  return 0;
+
118 }
119 
-
120 
-
121  // Set bmLOWSPEED and bmHUBPRE in case of low-speed device, reset them otherwise
-
122  regWr(rMODE, (p->lowspeed) ? mode | bmLOWSPEED | bmHubPre : mode & ~(bmHUBPRE | bmLOWSPEED));
-
123 
-
124  return 0;
-
125 }
-
126 
-
127 /* Control transfer. Sets address, endpoint, fills control packet with necessary data, dispatches control packet, and initiates bulk IN transfer, */
-
128 /* depending on request. Actual requests are defined as inlines */
-
129 /* return codes: */
-
130 /* 00 = success */
+
120 /* Control transfer. Sets address, endpoint, fills control packet with necessary data, dispatches control packet, and initiates bulk IN transfer, */
+
121 /* depending on request. Actual requests are defined as inlines */
+
122 /* return codes: */
+
123 /* 00 = success */
+
124 
+
125 /* 01-0f = non-zero HRSLT */
+
126 uint8_t USB::ctrlReq(uint8_t addr, uint8_t ep, uint8_t bmReqType, uint8_t bRequest, uint8_t wValLo, uint8_t wValHi,
+
127  uint16_t wInd, uint16_t total, uint16_t nbytes, uint8_t* dataptr, USBReadParser *p) {
+
128  bool direction = false; //request direction, IN or OUT
+
129  uint8_t rcode;
+
130  SETUP_PKT setup_pkt;
131 
-
132 /* 01-0f = non-zero HRSLT */
-
133 uint8_t USB::ctrlReq(uint8_t addr, uint8_t ep, uint8_t bmReqType, uint8_t bRequest, uint8_t wValLo, uint8_t wValHi,
-
134  uint16_t wInd, uint16_t total, uint16_t nbytes, uint8_t* dataptr, USBReadParser *p) {
-
135  bool direction = false; //request direction, IN or OUT
-
136  uint8_t rcode;
-
137  SETUP_PKT setup_pkt;
-
138 
-
139  EpInfo *pep = NULL;
-
140  uint16_t nak_limit = 0;
+
132  EpInfo *pep = NULL;
+
133  uint16_t nak_limit = 0;
+
134 
+
135  rcode = SetAddress(addr, ep, &pep, &nak_limit);
+
136 
+
137  if(rcode)
+
138  return rcode;
+
139 
+
140  direction = ((bmReqType & 0x80) > 0);
141 
-
142  rcode = SetAddress(addr, ep, &pep, &nak_limit);
-
143 
-
144  if(rcode)
-
145  return rcode;
-
146 
-
147  direction = ((bmReqType & 0x80) > 0);
-
148 
-
149  /* fill in setup packet */
-
150  setup_pkt.ReqType_u.bmRequestType = bmReqType;
-
151  setup_pkt.bRequest = bRequest;
-
152  setup_pkt.wVal_u.wValueLo = wValLo;
-
153  setup_pkt.wVal_u.wValueHi = wValHi;
-
154  setup_pkt.wIndex = wInd;
-
155  setup_pkt.wLength = total;
+
142  /* fill in setup packet */
+
143  setup_pkt.ReqType_u.bmRequestType = bmReqType;
+
144  setup_pkt.bRequest = bRequest;
+
145  setup_pkt.wVal_u.wValueLo = wValLo;
+
146  setup_pkt.wVal_u.wValueHi = wValHi;
+
147  setup_pkt.wIndex = wInd;
+
148  setup_pkt.wLength = total;
+
149 
+
150  bytesWr(rSUDFIFO, 8, (uint8_t*) & setup_pkt); //transfer to setup packet FIFO
+
151 
+
152  rcode = dispatchPkt(tokSETUP, ep, nak_limit); //dispatch packet
+
153 
+
154  if(rcode) //return HRSLT if not zero
+
155  return ( rcode);
156 
-
157  bytesWr(rSUDFIFO, 8, (uint8_t*) & setup_pkt); //transfer to setup packet FIFO
-
158 
-
159  rcode = dispatchPkt(tokSETUP, ep, nak_limit); //dispatch packet
-
160 
-
161  if(rcode) //return HRSLT if not zero
-
162  return ( rcode);
-
163 
-
164  if(dataptr != NULL) //data stage, if present
-
165  {
-
166  if(direction) //IN transfer
-
167  {
-
168  uint16_t left = total;
-
169 
-
170  pep->bmRcvToggle = 1; //bmRCVTOG1;
-
171 
-
172  while(left) {
-
173  // Bytes read into buffer
-
174  uint16_t read = nbytes;
-
175  //uint16_t read = (left<nbytes) ? left : nbytes;
-
176 
-
177  rcode = InTransfer(pep, nak_limit, &read, dataptr);
-
178  if(rcode == hrTOGERR) {
-
179  // yes, we flip it wrong here so that next time it is actually correct!
-
180  pep->bmRcvToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 0 : 1;
-
181  continue;
-
182  }
-
183 
-
184  if(rcode)
-
185  return rcode;
+
157  if(dataptr != NULL) //data stage, if present
+
158  {
+
159  if(direction) //IN transfer
+
160  {
+
161  uint16_t left = total;
+
162 
+
163  pep->bmRcvToggle = 1; //bmRCVTOG1;
+
164 
+
165  while(left) {
+
166  // Bytes read into buffer
+
167 #if defined(ESP8266) || defined(ESP32)
+
168  yield(); // needed in order to reset the watchdog timer on the ESP8266
+
169 #endif
+
170  uint16_t read = nbytes;
+
171  //uint16_t read = (left<nbytes) ? left : nbytes;
+
172 
+
173  rcode = InTransfer(pep, nak_limit, &read, dataptr);
+
174  if(rcode == hrTOGERR) {
+
175  // yes, we flip it wrong here so that next time it is actually correct!
+
176  pep->bmRcvToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 0 : 1;
+
177  continue;
+
178  }
+
179 
+
180  if(rcode)
+
181  return rcode;
+
182 
+
183  // Invoke callback function if inTransfer completed successfully and callback function pointer is specified
+
184  if(!rcode && p)
+
185  ((USBReadParser*)p)->Parse(read, dataptr, total - left);
186 
-
187  // Invoke callback function if inTransfer completed successfully and callback function pointer is specified
-
188  if(!rcode && p)
-
189  ((USBReadParser*)p)->Parse(read, dataptr, total - left);
-
190 
-
191  left -= read;
-
192 
-
193  if(read < nbytes)
-
194  break;
-
195  }
-
196  } else //OUT transfer
-
197  {
-
198  pep->bmSndToggle = 1; //bmSNDTOG1;
-
199  rcode = OutTransfer(pep, nak_limit, nbytes, dataptr);
-
200  }
-
201  if(rcode) //return error
-
202  return ( rcode);
-
203  }
-
204  // Status stage
-
205  return dispatchPkt((direction) ? tokOUTHS : tokINHS, ep, nak_limit); //GET if direction
-
206 }
-
207 
-
208 /* IN transfer to arbitrary endpoint. Assumes PERADDR is set. Handles multiple packets if necessary. Transfers 'nbytes' bytes. */
-
209 /* Keep sending INs and writes data to memory area pointed by 'data' */
-
210 
-
211 /* rcode 0 if no errors. rcode 01-0f is relayed from dispatchPkt(). Rcode f0 means RCVDAVIRQ error,
-
212  fe USB xfer timeout */
-
213 uint8_t USB::inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t* data, uint8_t bInterval /*= 0*/) {
-
214  EpInfo *pep = NULL;
-
215  uint16_t nak_limit = 0;
-
216 
-
217  uint8_t rcode = SetAddress(addr, ep, &pep, &nak_limit);
-
218 
-
219  if(rcode) {
-
220  USBTRACE3("(USB::InTransfer) SetAddress Failed ", rcode, 0x81);
-
221  USBTRACE3("(USB::InTransfer) addr requested ", addr, 0x81);
-
222  USBTRACE3("(USB::InTransfer) ep requested ", ep, 0x81);
-
223  return rcode;
-
224  }
-
225  return InTransfer(pep, nak_limit, nbytesptr, data, bInterval);
-
226 }
+
187  left -= read;
+
188 
+
189  if(read < nbytes)
+
190  break;
+
191  }
+
192  } else //OUT transfer
+
193  {
+
194  pep->bmSndToggle = 1; //bmSNDTOG1;
+
195  rcode = OutTransfer(pep, nak_limit, nbytes, dataptr);
+
196  }
+
197  if(rcode) //return error
+
198  return ( rcode);
+
199  }
+
200  // Status stage
+
201  return dispatchPkt((direction) ? tokOUTHS : tokINHS, ep, nak_limit); //GET if direction
+
202 }
+
203 
+
204 /* IN transfer to arbitrary endpoint. Assumes PERADDR is set. Handles multiple packets if necessary. Transfers 'nbytes' bytes. */
+
205 /* Keep sending INs and writes data to memory area pointed by 'data' */
+
206 
+
207 /* rcode 0 if no errors. rcode 01-0f is relayed from dispatchPkt(). Rcode f0 means RCVDAVIRQ error,
+
208  fe USB xfer timeout */
+
209 uint8_t USB::inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t* data, uint8_t bInterval /*= 0*/) {
+
210  EpInfo *pep = NULL;
+
211  uint16_t nak_limit = 0;
+
212 
+
213  uint8_t rcode = SetAddress(addr, ep, &pep, &nak_limit);
+
214 
+
215  if(rcode) {
+
216  USBTRACE3("(USB::InTransfer) SetAddress Failed ", rcode, 0x81);
+
217  USBTRACE3("(USB::InTransfer) addr requested ", addr, 0x81);
+
218  USBTRACE3("(USB::InTransfer) ep requested ", ep, 0x81);
+
219  return rcode;
+
220  }
+
221  return InTransfer(pep, nak_limit, nbytesptr, data, bInterval);
+
222 }
+
223 
+
224 uint8_t USB::InTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t *nbytesptr, uint8_t* data, uint8_t bInterval /*= 0*/) {
+
225  uint8_t rcode = 0;
+
226  uint8_t pktsize;
227 
-
228 uint8_t USB::InTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t *nbytesptr, uint8_t* data, uint8_t bInterval /*= 0*/) {
-
229  uint8_t rcode = 0;
-
230  uint8_t pktsize;
+
228  uint16_t nbytes = *nbytesptr;
+
229  //printf("Requesting %i bytes ", nbytes);
+
230  uint8_t maxpktsize = pep->maxPktSize;
231 
-
232  uint16_t nbytes = *nbytesptr;
-
233  //printf("Requesting %i bytes ", nbytes);
-
234  uint8_t maxpktsize = pep->maxPktSize;
-
235 
-
236  *nbytesptr = 0;
-
237  regWr(rHCTL, (pep->bmRcvToggle) ? bmRCVTOG1 : bmRCVTOG0); //set toggle value
-
238 
-
239  // use a 'break' to exit this loop
-
240  while(1) {
-
241  rcode = dispatchPkt(tokIN, pep->epAddr, nak_limit); //IN packet to EP-'endpoint'. Function takes care of NAKS.
-
242  if(rcode == hrTOGERR) {
-
243  // yes, we flip it wrong here so that next time it is actually correct!
-
244  pep->bmRcvToggle = (regRd(rHRSL) & bmRCVTOGRD) ? 0 : 1;
-
245  regWr(rHCTL, (pep->bmRcvToggle) ? bmRCVTOG1 : bmRCVTOG0); //set toggle value
-
246  continue;
-
247  }
-
248  if(rcode) {
-
249  //printf(">>>>>>>> Problem! dispatchPkt %2.2x\r\n", rcode);
-
250  break; //should be 0, indicating ACK. Else return error code.
-
251  }
-
252  /* check for RCVDAVIRQ and generate error if not present */
-
253  /* the only case when absence of RCVDAVIRQ makes sense is when toggle error occurred. Need to add handling for that */
-
254  if((regRd(rHIRQ) & bmRCVDAVIRQ) == 0) {
-
255  //printf(">>>>>>>> Problem! NO RCVDAVIRQ!\r\n");
-
256  rcode = 0xf0; //receive error
-
257  break;
-
258  }
-
259  pktsize = regRd(rRCVBC); //number of received bytes
-
260  //printf("Got %i bytes \r\n", pktsize);
-
261  // This would be OK, but...
-
262  //assert(pktsize <= nbytes);
-
263  if(pktsize > nbytes) {
-
264  // This can happen. Use of assert on Arduino locks up the Arduino.
-
265  // So I will trim the value, and hope for the best.
-
266  //printf(">>>>>>>> Problem! Wanted %i bytes but got %i.\r\n", nbytes, pktsize);
-
267  pktsize = nbytes;
-
268  }
-
269 
-
270  int16_t mem_left = (int16_t)nbytes - *((int16_t*)nbytesptr);
-
271 
-
272  if(mem_left < 0)
-
273  mem_left = 0;
+
232  *nbytesptr = 0;
+
233  regWr(rHCTL, (pep->bmRcvToggle) ? bmRCVTOG1 : bmRCVTOG0); //set toggle value
+
234 
+
235  // use a 'break' to exit this loop
+
236  while(1) {
+
237 #if defined(ESP8266) || defined(ESP32)
+
238  yield(); // needed in order to reset the watchdog timer on the ESP8266
+
239 #endif
+
240  rcode = dispatchPkt(tokIN, pep->epAddr, nak_limit); //IN packet to EP-'endpoint'. Function takes care of NAKS.
+
241  if(rcode == hrTOGERR) {
+
242  // yes, we flip it wrong here so that next time it is actually correct!
+
243  pep->bmRcvToggle = (regRd(rHRSL) & bmRCVTOGRD) ? 0 : 1;
+
244  regWr(rHCTL, (pep->bmRcvToggle) ? bmRCVTOG1 : bmRCVTOG0); //set toggle value
+
245  continue;
+
246  }
+
247  if(rcode) {
+
248  //printf(">>>>>>>> Problem! dispatchPkt %2.2x\r\n", rcode);
+
249  break; //should be 0, indicating ACK. Else return error code.
+
250  }
+
251  /* check for RCVDAVIRQ and generate error if not present
+
252  * the only case when absence of RCVDAVIRQ makes sense is when toggle error occurred.
+
253  * Need to add handling for that
+
254  *
+
255  * NOTE: I've seen this happen with SPI corruption -- xxxajk
+
256  */
+
257  if((regRd(rHIRQ) & bmRCVDAVIRQ) == 0) {
+
258  //printf(">>>>>>>> Problem! NO RCVDAVIRQ!\r\n");
+
259  rcode = 0xf0; //receive error
+
260  break;
+
261  }
+
262  pktsize = regRd(rRCVBC); //number of received bytes
+
263  //printf("Got %i bytes \r\n", pktsize);
+
264  // This would be OK, but...
+
265  //assert(pktsize <= nbytes);
+
266  if(pktsize > nbytes) {
+
267  // This can happen. Use of assert on Arduino locks up the Arduino.
+
268  // So I will trim the value, and hope for the best.
+
269  //printf(">>>>>>>> Problem! Wanted %i bytes but got %i.\r\n", nbytes, pktsize);
+
270  pktsize = nbytes;
+
271  }
+
272 
+
273  int16_t mem_left = (int16_t)nbytes - *((int16_t*)nbytesptr);
274 
-
275  data = bytesRd(rRCVFIFO, ((pktsize > mem_left) ? mem_left : pktsize), data);
-
276 
-
277  regWr(rHIRQ, bmRCVDAVIRQ); // Clear the IRQ & free the buffer
-
278  *nbytesptr += pktsize; // add this packet's byte count to total transfer length
+
275  if(mem_left < 0)
+
276  mem_left = 0;
+
277 
+
278  data = bytesRd(rRCVFIFO, ((pktsize > mem_left) ? mem_left : pktsize), data);
279 
-
280  /* The transfer is complete under two conditions: */
-
281  /* 1. The device sent a short packet (L.T. maxPacketSize) */
-
282  /* 2. 'nbytes' have been transferred. */
-
283  if((pktsize < maxpktsize) || (*nbytesptr >= nbytes)) // have we transferred 'nbytes' bytes?
-
284  {
-
285  // Save toggle value
-
286  pep->bmRcvToggle = ((regRd(rHRSL) & bmRCVTOGRD)) ? 1 : 0;
-
287  //printf("\r\n");
-
288  rcode = 0;
-
289  break;
-
290  } else if(bInterval > 0)
-
291  delay(bInterval); // Delay according to polling interval
-
292  } //while( 1 )
-
293  return ( rcode);
-
294 }
-
295 
-
296 /* OUT transfer to arbitrary endpoint. Handles multiple packets if necessary. Transfers 'nbytes' bytes. */
-
297 /* Handles NAK bug per Maxim Application Note 4000 for single buffer transfer */
+
280  regWr(rHIRQ, bmRCVDAVIRQ); // Clear the IRQ & free the buffer
+
281  *nbytesptr += pktsize; // add this packet's byte count to total transfer length
+
282 
+
283  /* The transfer is complete under two conditions: */
+
284  /* 1. The device sent a short packet (L.T. maxPacketSize) */
+
285  /* 2. 'nbytes' have been transferred. */
+
286  if((pktsize < maxpktsize) || (*nbytesptr >= nbytes)) // have we transferred 'nbytes' bytes?
+
287  {
+
288  // Save toggle value
+
289  pep->bmRcvToggle = ((regRd(rHRSL) & bmRCVTOGRD)) ? 1 : 0;
+
290  //printf("\r\n");
+
291  rcode = 0;
+
292  break;
+
293  } else if(bInterval > 0)
+
294  delay(bInterval); // Delay according to polling interval
+
295  } //while( 1 )
+
296  return ( rcode);
+
297 }
298 
-
299 /* rcode 0 if no errors. rcode 01-0f is relayed from HRSL */
-
300 uint8_t USB::outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* data) {
-
301  EpInfo *pep = NULL;
-
302  uint16_t nak_limit = 0;
-
303 
-
304  uint8_t rcode = SetAddress(addr, ep, &pep, &nak_limit);
-
305 
-
306  if(rcode)
-
307  return rcode;
+
299 /* OUT transfer to arbitrary endpoint. Handles multiple packets if necessary. Transfers 'nbytes' bytes. */
+
300 /* Handles NAK bug per Maxim Application Note 4000 for single buffer transfer */
+
301 
+
302 /* rcode 0 if no errors. rcode 01-0f is relayed from HRSL */
+
303 uint8_t USB::outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* data) {
+
304  EpInfo *pep = NULL;
+
305  uint16_t nak_limit = 0;
+
306 
+
307  uint8_t rcode = SetAddress(addr, ep, &pep, &nak_limit);
308 
-
309  return OutTransfer(pep, nak_limit, nbytes, data);
-
310 }
+
309  if(rcode)
+
310  return rcode;
311 
-
312 uint8_t USB::OutTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t nbytes, uint8_t *data) {
-
313  uint8_t rcode = hrSUCCESS, retry_count;
-
314  uint8_t *data_p = data; //local copy of the data pointer
-
315  uint16_t bytes_tosend, nak_count;
-
316  uint16_t bytes_left = nbytes;
-
317 
-
318  uint8_t maxpktsize = pep->maxPktSize;
-
319 
-
320  if(maxpktsize < 1 || maxpktsize > 64)
- +
312  return OutTransfer(pep, nak_limit, nbytes, data);
+
313 }
+
314 
+
315 uint8_t USB::OutTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t nbytes, uint8_t *data) {
+
316  uint8_t rcode = hrSUCCESS, retry_count;
+
317  uint8_t *data_p = data; //local copy of the data pointer
+
318  uint16_t bytes_tosend, nak_count;
+
319  uint16_t bytes_left = nbytes;
+
320 
+
321  uint8_t maxpktsize = pep->maxPktSize;
322 
-
323  uint32_t timeout = (uint32_t)millis() + USB_XFER_TIMEOUT;
-
324 
-
325  regWr(rHCTL, (pep->bmSndToggle) ? bmSNDTOG1 : bmSNDTOG0); //set toggle value
-
326 
-
327  while(bytes_left) {
-
328  retry_count = 0;
-
329  nak_count = 0;
-
330  bytes_tosend = (bytes_left >= maxpktsize) ? maxpktsize : bytes_left;
-
331  bytesWr(rSNDFIFO, bytes_tosend, data_p); //filling output FIFO
-
332  regWr(rSNDBC, bytes_tosend); //set number of bytes
-
333  regWr(rHXFR, (tokOUT | pep->epAddr)); //dispatch packet
-
334  while(!(regRd(rHIRQ) & bmHXFRDNIRQ)); //wait for the completion IRQ
-
335  regWr(rHIRQ, bmHXFRDNIRQ); //clear IRQ
-
336  rcode = (regRd(rHRSL) & 0x0f);
-
337 
-
338  while(rcode && ((int32_t)((uint32_t)millis() - timeout) < 0L)) {
-
339  switch(rcode) {
-
340  case hrNAK:
-
341  nak_count++;
-
342  if(nak_limit && (nak_count == nak_limit))
-
343  goto breakout;
-
344  //return ( rcode);
-
345  break;
-
346  case hrTIMEOUT:
-
347  retry_count++;
-
348  if(retry_count == USB_RETRY_LIMIT)
-
349  goto breakout;
-
350  //return ( rcode);
-
351  break;
-
352  case hrTOGERR:
-
353  // yes, we flip it wrong here so that next time it is actually correct!
-
354  pep->bmSndToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 0 : 1;
-
355  regWr(rHCTL, (pep->bmSndToggle) ? bmSNDTOG1 : bmSNDTOG0); //set toggle value
-
356  break;
-
357  default:
-
358  goto breakout;
-
359  }//switch( rcode
-
360 
-
361  /* process NAK according to Host out NAK bug */
-
362  regWr(rSNDBC, 0);
-
363  regWr(rSNDFIFO, *data_p);
-
364  regWr(rSNDBC, bytes_tosend);
-
365  regWr(rHXFR, (tokOUT | pep->epAddr)); //dispatch packet
-
366  while(!(regRd(rHIRQ) & bmHXFRDNIRQ)); //wait for the completion IRQ
-
367  regWr(rHIRQ, bmHXFRDNIRQ); //clear IRQ
-
368  rcode = (regRd(rHRSL) & 0x0f);
-
369  }//while( rcode && ....
-
370  bytes_left -= bytes_tosend;
-
371  data_p += bytes_tosend;
-
372  }//while( bytes_left...
-
373 breakout:
-
374 
-
375  pep->bmSndToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 1 : 0; //bmSNDTOG1 : bmSNDTOG0; //update toggle
-
376  return ( rcode); //should be 0 in all cases
-
377 }
-
378 /* dispatch USB packet. Assumes peripheral address is set and relevant buffer is loaded/empty */
-
379 /* If NAK, tries to re-send up to nak_limit times */
-
380 /* If nak_limit == 0, do not count NAKs, exit after timeout */
-
381 /* If bus timeout, re-sends up to USB_RETRY_LIMIT times */
-
382 
-
383 /* return codes 0x00-0x0f are HRSLT( 0x00 being success ), 0xff means timeout */
-
384 uint8_t USB::dispatchPkt(uint8_t token, uint8_t ep, uint16_t nak_limit) {
-
385  uint32_t timeout = (uint32_t)millis() + USB_XFER_TIMEOUT;
-
386  uint8_t tmpdata;
-
387  uint8_t rcode = hrSUCCESS;
-
388  uint8_t retry_count = 0;
-
389  uint16_t nak_count = 0;
-
390 
-
391  while((int32_t)((uint32_t)millis() - timeout) < 0L) {
-
392 #if defined(ESP8266) || defined(ESP32)
-
393  yield(); // needed in order to reset the watchdog timer on the ESP8266
-
394 #endif
-
395  regWr(rHXFR, (token | ep)); //launch the transfer
- -
397 
-
398  while((int32_t)((uint32_t)millis() - timeout) < 0L) //wait for transfer completion
-
399  {
-
400 #if defined(ESP8266) || defined(ESP32)
-
401  yield(); // needed in order to reset the watchdog timer on the ESP8266
-
402 #endif
-
403  tmpdata = regRd(rHIRQ);
-
404 
-
405  if(tmpdata & bmHXFRDNIRQ) {
-
406  regWr(rHIRQ, bmHXFRDNIRQ); //clear the interrupt
-
407  rcode = 0x00;
-
408  break;
-
409  }//if( tmpdata & bmHXFRDNIRQ
-
410 
-
411  }//while ( millis() < timeout
-
412 
-
413  //if (rcode != 0x00) //exit if timeout
-
414  // return ( rcode);
-
415 
-
416  rcode = (regRd(rHRSL) & 0x0f); //analyze transfer result
-
417 
-
418  switch(rcode) {
-
419  case hrNAK:
-
420  nak_count++;
-
421  if(nak_limit && (nak_count == nak_limit))
-
422  return (rcode);
-
423  break;
-
424  case hrTIMEOUT:
-
425  retry_count++;
-
426  if(retry_count == USB_RETRY_LIMIT)
-
427  return (rcode);
-
428  break;
-
429  default:
-
430  return (rcode);
-
431  }//switch( rcode
+
323  if(maxpktsize < 1 || maxpktsize > 64)
+ +
325 
+
326  uint32_t timeout = (uint32_t)millis() + USB_XFER_TIMEOUT;
+
327 
+
328  regWr(rHCTL, (pep->bmSndToggle) ? bmSNDTOG1 : bmSNDTOG0); //set toggle value
+
329 
+
330  while(bytes_left) {
+
331 #if defined(ESP8266) || defined(ESP32)
+
332  yield(); // needed in order to reset the watchdog timer on the ESP8266
+
333 #endif
+
334  retry_count = 0;
+
335  nak_count = 0;
+
336  bytes_tosend = (bytes_left >= maxpktsize) ? maxpktsize : bytes_left;
+
337  bytesWr(rSNDFIFO, bytes_tosend, data_p); //filling output FIFO
+
338  regWr(rSNDBC, bytes_tosend); //set number of bytes
+
339  regWr(rHXFR, (tokOUT | pep->epAddr)); //dispatch packet
+
340  while(!(regRd(rHIRQ) & bmHXFRDNIRQ)){
+
341 #if defined(ESP8266) || defined(ESP32)
+
342  yield(); // needed in order to reset the watchdog timer on the ESP8266
+
343 #endif
+
344  } //wait for the completion IRQ
+
345  regWr(rHIRQ, bmHXFRDNIRQ); //clear IRQ
+
346  rcode = (regRd(rHRSL) & 0x0f);
+
347 
+
348  while(rcode && ((int32_t)((uint32_t)millis() - timeout) < 0L)) {
+
349 #if defined(ESP8266) || defined(ESP32)
+
350  yield(); // needed in order to reset the watchdog timer on the ESP8266
+
351 #endif
+
352  switch(rcode) {
+
353  case hrNAK:
+
354  nak_count++;
+
355  if(nak_limit && (nak_count == nak_limit))
+
356  goto breakout;
+
357  //return ( rcode);
+
358  break;
+
359  case hrTIMEOUT:
+
360  retry_count++;
+
361  if(retry_count == USB_RETRY_LIMIT)
+
362  goto breakout;
+
363  //return ( rcode);
+
364  break;
+
365  case hrTOGERR:
+
366  // yes, we flip it wrong here so that next time it is actually correct!
+
367  pep->bmSndToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 0 : 1;
+
368  regWr(rHCTL, (pep->bmSndToggle) ? bmSNDTOG1 : bmSNDTOG0); //set toggle value
+
369  break;
+
370  default:
+
371  goto breakout;
+
372  }//switch( rcode
+
373 
+
374  /* process NAK according to Host out NAK bug */
+
375  regWr(rSNDBC, 0);
+
376  regWr(rSNDFIFO, *data_p);
+
377  regWr(rSNDBC, bytes_tosend);
+
378  regWr(rHXFR, (tokOUT | pep->epAddr)); //dispatch packet
+
379  while(!(regRd(rHIRQ) & bmHXFRDNIRQ)){
+
380 #if defined(ESP8266) || defined(ESP32)
+
381  yield(); // needed in order to reset the watchdog timer on the ESP8266
+
382 #endif
+
383  } //wait for the completion IRQ
+
384  regWr(rHIRQ, bmHXFRDNIRQ); //clear IRQ
+
385  rcode = (regRd(rHRSL) & 0x0f);
+
386  }//while( rcode && ....
+
387  bytes_left -= bytes_tosend;
+
388  data_p += bytes_tosend;
+
389  }//while( bytes_left...
+
390 breakout:
+
391 
+
392  pep->bmSndToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 1 : 0; //bmSNDTOG1 : bmSNDTOG0; //update toggle
+
393  return ( rcode); //should be 0 in all cases
+
394 }
+
395 /* dispatch USB packet. Assumes peripheral address is set and relevant buffer is loaded/empty */
+
396 /* If NAK, tries to re-send up to nak_limit times */
+
397 /* If nak_limit == 0, do not count NAKs, exit after timeout */
+
398 /* If bus timeout, re-sends up to USB_RETRY_LIMIT times */
+
399 
+
400 /* return codes 0x00-0x0f are HRSLT( 0x00 being success ), 0xff means timeout */
+
401 uint8_t USB::dispatchPkt(uint8_t token, uint8_t ep, uint16_t nak_limit) {
+
402  uint32_t timeout = (uint32_t)millis() + USB_XFER_TIMEOUT;
+
403  uint8_t tmpdata;
+
404  uint8_t rcode = hrSUCCESS;
+
405  uint8_t retry_count = 0;
+
406  uint16_t nak_count = 0;
+
407 
+
408  while((int32_t)((uint32_t)millis() - timeout) < 0L) {
+
409 #if defined(ESP8266) || defined(ESP32)
+
410  yield(); // needed in order to reset the watchdog timer on the ESP8266
+
411 #endif
+
412  regWr(rHXFR, (token | ep)); //launch the transfer
+ +
414 
+
415  while((int32_t)((uint32_t)millis() - timeout) < 0L) //wait for transfer completion
+
416  {
+
417 #if defined(ESP8266) || defined(ESP32)
+
418  yield(); // needed in order to reset the watchdog timer on the ESP8266
+
419 #endif
+
420  tmpdata = regRd(rHIRQ);
+
421 
+
422  if(tmpdata & bmHXFRDNIRQ) {
+
423  regWr(rHIRQ, bmHXFRDNIRQ); //clear the interrupt
+
424  rcode = 0x00;
+
425  break;
+
426  }//if( tmpdata & bmHXFRDNIRQ
+
427 
+
428  }//while ( millis() < timeout
+
429 
+
430  //if (rcode != 0x00) //exit if timeout
+
431  // return ( rcode);
432 
-
433  }//while( timeout > millis()
-
434  return ( rcode);
-
435 }
-
436 
-
437 /* USB main task. Performs enumeration/cleanup */
-
438 void USB::Task(void) //USB state machine
-
439 {
-
440  uint8_t rcode;
-
441  uint8_t tmpdata;
-
442  static uint32_t delay = 0;
-
443  //USB_DEVICE_DESCRIPTOR buf;
-
444  bool lowspeed = false;
-
445 
-
446  MAX3421E::Task();
-
447 
-
448  tmpdata = getVbusState();
+
433  rcode = (regRd(rHRSL) & 0x0f); //analyze transfer result
+
434 
+
435  switch(rcode) {
+
436  case hrNAK:
+
437  nak_count++;
+
438  if(nak_limit && (nak_count == nak_limit))
+
439  return (rcode);
+
440  break;
+
441  case hrTIMEOUT:
+
442  retry_count++;
+
443  if(retry_count == USB_RETRY_LIMIT)
+
444  return (rcode);
+
445  break;
+
446  default:
+
447  return (rcode);
+
448  }//switch( rcode
449 
-
450  /* modify USB task state if Vbus changed */
-
451  switch(tmpdata) {
-
452  case SE1: //illegal state
-
453  usb_task_state = USB_DETACHED_SUBSTATE_ILLEGAL;
-
454  lowspeed = false;
-
455  break;
-
456  case SE0: //disconnected
-
457  if((usb_task_state & USB_STATE_MASK) != USB_STATE_DETACHED)
-
458  usb_task_state = USB_DETACHED_SUBSTATE_INITIALIZE;
-
459  lowspeed = false;
-
460  break;
-
461  case LSHOST:
+
450  }//while( timeout > millis()
+
451  return ( rcode);
+
452 }
+
453 
+
454 /* USB main task. Performs enumeration/cleanup */
+
455 void USB::Task(void) //USB state machine
+
456 {
+
457  uint8_t rcode;
+
458  uint8_t tmpdata;
+
459  static uint32_t delay = 0;
+
460  //USB_DEVICE_DESCRIPTOR buf;
+
461  bool lowspeed = false;
462 
-
463  lowspeed = true;
-
464  //intentional fallthrough
-
465  case FSHOST: //attached
-
466  if((usb_task_state & USB_STATE_MASK) == USB_STATE_DETACHED) {
-
467  delay = (uint32_t)millis() + USB_SETTLE_DELAY;
-
468  usb_task_state = USB_ATTACHED_SUBSTATE_SETTLE;
-
469  }
-
470  break;
-
471  }// switch( tmpdata
-
472 
-
473  for(uint8_t i = 0; i < USB_NUMDEVICES; i++)
-
474  if(devConfig[i])
-
475  rcode = devConfig[i]->Poll();
-
476 
-
477  switch(usb_task_state) {
- -
479  init();
-
480 
-
481  for(uint8_t i = 0; i < USB_NUMDEVICES; i++)
-
482  if(devConfig[i])
-
483  rcode = devConfig[i]->Release();
-
484 
-
485  usb_task_state = USB_DETACHED_SUBSTATE_WAIT_FOR_DEVICE;
-
486  break;
-
487  case USB_DETACHED_SUBSTATE_WAIT_FOR_DEVICE: //just sit here
-
488  break;
-
489  case USB_DETACHED_SUBSTATE_ILLEGAL: //just sit here
-
490  break;
-
491  case USB_ATTACHED_SUBSTATE_SETTLE: //settle time for just attached device
-
492  if((int32_t)((uint32_t)millis() - delay) >= 0L)
-
493  usb_task_state = USB_ATTACHED_SUBSTATE_RESET_DEVICE;
-
494  else break; // don't fall through
- -
496  regWr(rHCTL, bmBUSRST); //issue bus reset
- -
498  break;
- -
500  if((regRd(rHCTL) & bmBUSRST) == 0) {
-
501  tmpdata = regRd(rMODE) | bmSOFKAENAB; //start SOF generation
-
502  regWr(rMODE, tmpdata);
-
503  usb_task_state = USB_ATTACHED_SUBSTATE_WAIT_SOF;
-
504  //delay = (uint32_t)millis() + 20; //20ms wait after reset per USB spec
-
505  }
-
506  break;
-
507  case USB_ATTACHED_SUBSTATE_WAIT_SOF: //todo: change check order
-
508  if(regRd(rHIRQ) & bmFRAMEIRQ) {
-
509  //when first SOF received _and_ 20ms has passed we can continue
-
510  /*
-
511  if (delay < (uint32_t)millis()) //20ms passed
-
512  usb_task_state = USB_STATE_CONFIGURING;
-
513  */
-
514  usb_task_state = USB_ATTACHED_SUBSTATE_WAIT_RESET;
-
515  delay = (uint32_t)millis() + 20;
-
516  }
-
517  break;
- -
519  if((int32_t)((uint32_t)millis() - delay) >= 0L) usb_task_state = USB_STATE_CONFIGURING;
-
520  else break; // don't fall through
- -
522 
-
523  //Serial.print("\r\nConf.LS: ");
-
524  //Serial.println(lowspeed, HEX);
-
525 
-
526  rcode = Configuring(0, 0, lowspeed);
-
527 
-
528  if(rcode) {
- -
530  usb_error = rcode;
-
531  usb_task_state = USB_STATE_ERROR;
-
532  }
-
533  } else
-
534  usb_task_state = USB_STATE_RUNNING;
-
535  break;
-
536  case USB_STATE_RUNNING:
-
537  break;
-
538  case USB_STATE_ERROR:
-
539  //MAX3421E::Init();
-
540  break;
-
541  } // switch( usb_task_state )
-
542 }
-
543 
-
544 uint8_t USB::DefaultAddressing(uint8_t parent, uint8_t port, bool lowspeed) {
-
545  //uint8_t buf[12];
-
546  uint8_t rcode;
-
547  UsbDevice *p0 = NULL, *p = NULL;
-
548 
-
549  // Get pointer to pseudo device with address 0 assigned
-
550  p0 = addrPool.GetUsbDevicePtr(0);
-
551 
-
552  if(!p0)
- -
554 
-
555  if(!p0->epinfo)
- -
557 
-
558  p0->lowspeed = (lowspeed) ? true : false;
-
559 
-
560  // Allocate new address according to device class
-
561  uint8_t bAddress = addrPool.AllocAddress(parent, false, port);
-
562 
-
563  if(!bAddress)
- +
463  MAX3421E::Task();
+
464 
+
465  tmpdata = getVbusState();
+
466 
+
467  /* modify USB task state if Vbus changed */
+
468  switch(tmpdata) {
+
469  case SE1: //illegal state
+
470  usb_task_state = USB_DETACHED_SUBSTATE_ILLEGAL;
+
471  lowspeed = false;
+
472  break;
+
473  case SE0: //disconnected
+
474  if((usb_task_state & USB_STATE_MASK) != USB_STATE_DETACHED)
+
475  usb_task_state = USB_DETACHED_SUBSTATE_INITIALIZE;
+
476  lowspeed = false;
+
477  break;
+
478  case LSHOST:
+
479 
+
480  lowspeed = true;
+
481  //intentional fallthrough
+
482  case FSHOST: //attached
+
483  if((usb_task_state & USB_STATE_MASK) == USB_STATE_DETACHED) {
+
484  delay = (uint32_t)millis() + USB_SETTLE_DELAY;
+
485  usb_task_state = USB_ATTACHED_SUBSTATE_SETTLE;
+
486  }
+
487  break;
+
488  }// switch( tmpdata
+
489 
+
490  for(uint8_t i = 0; i < USB_NUMDEVICES; i++)
+
491  if(devConfig[i])
+
492  rcode = devConfig[i]->Poll();
+
493 
+
494  switch(usb_task_state) {
+ +
496  init();
+
497 
+
498  for(uint8_t i = 0; i < USB_NUMDEVICES; i++)
+
499  if(devConfig[i])
+
500  rcode = devConfig[i]->Release();
+
501 
+
502  usb_task_state = USB_DETACHED_SUBSTATE_WAIT_FOR_DEVICE;
+
503  break;
+
504  case USB_DETACHED_SUBSTATE_WAIT_FOR_DEVICE: //just sit here
+
505  break;
+
506  case USB_DETACHED_SUBSTATE_ILLEGAL: //just sit here
+
507  break;
+
508  case USB_ATTACHED_SUBSTATE_SETTLE: //settle time for just attached device
+
509  if((int32_t)((uint32_t)millis() - delay) >= 0L)
+
510  usb_task_state = USB_ATTACHED_SUBSTATE_RESET_DEVICE;
+
511  else break; // don't fall through
+ +
513  regWr(rHCTL, bmBUSRST); //issue bus reset
+ +
515  break;
+ +
517  if((regRd(rHCTL) & bmBUSRST) == 0) {
+
518  tmpdata = regRd(rMODE) | bmSOFKAENAB; //start SOF generation
+
519  regWr(rMODE, tmpdata);
+
520  usb_task_state = USB_ATTACHED_SUBSTATE_WAIT_SOF;
+
521  //delay = (uint32_t)millis() + 20; //20ms wait after reset per USB spec
+
522  }
+
523  break;
+
524  case USB_ATTACHED_SUBSTATE_WAIT_SOF: //todo: change check order
+
525  if(regRd(rHIRQ) & bmFRAMEIRQ) {
+
526  //when first SOF received _and_ 20ms has passed we can continue
+
527  /*
+
528  if (delay < (uint32_t)millis()) //20ms passed
+
529  usb_task_state = USB_STATE_CONFIGURING;
+
530  */
+
531  usb_task_state = USB_ATTACHED_SUBSTATE_WAIT_RESET;
+
532  delay = (uint32_t)millis() + 20;
+
533  }
+
534  break;
+ +
536  if((int32_t)((uint32_t)millis() - delay) >= 0L) usb_task_state = USB_STATE_CONFIGURING;
+
537  else break; // don't fall through
+ +
539 
+
540  //Serial.print("\r\nConf.LS: ");
+
541  //Serial.println(lowspeed, HEX);
+
542 
+
543  rcode = Configuring(0, 0, lowspeed);
+
544 
+
545  if(rcode) {
+ +
547  usb_error = rcode;
+
548  usb_task_state = USB_STATE_ERROR;
+
549  }
+
550  } else
+
551  usb_task_state = USB_STATE_RUNNING;
+
552  break;
+
553  case USB_STATE_RUNNING:
+
554  break;
+
555  case USB_STATE_ERROR:
+
556  //MAX3421E::Init();
+
557  break;
+
558  } // switch( usb_task_state )
+
559 }
+
560 
+
561 uint8_t USB::DefaultAddressing(uint8_t parent, uint8_t port, bool lowspeed) {
+
562  //uint8_t buf[12];
+
563  uint8_t rcode;
+
564  UsbDevice *p0 = NULL, *p = NULL;
565 
-
566  p = addrPool.GetUsbDevicePtr(bAddress);
-
567 
-
568  if(!p)
- -
570 
-
571  p->lowspeed = lowspeed;
-
572 
-
573  // Assign new address to the device
-
574  rcode = setAddr(0, 0, bAddress);
-
575 
-
576  if(rcode) {
-
577  addrPool.FreeAddress(bAddress);
-
578  bAddress = 0;
-
579  return rcode;
-
580  }
-
581  return 0;
-
582 };
-
583 
-
584 uint8_t USB::AttemptConfig(uint8_t driver, uint8_t parent, uint8_t port, bool lowspeed) {
-
585  //printf("AttemptConfig: parent = %i, port = %i\r\n", parent, port);
-
586  uint8_t retries = 0;
+
566  // Get pointer to pseudo device with address 0 assigned
+
567  p0 = addrPool.GetUsbDevicePtr(0);
+
568 
+
569  if(!p0)
+ +
571 
+
572  if(!p0->epinfo)
+ +
574 
+
575  p0->lowspeed = (lowspeed) ? true : false;
+
576 
+
577  // Allocate new address according to device class
+
578  uint8_t bAddress = addrPool.AllocAddress(parent, false, port);
+
579 
+
580  if(!bAddress)
+ +
582 
+
583  p = addrPool.GetUsbDevicePtr(bAddress);
+
584 
+
585  if(!p)
+
587 
-
588 again:
-
589  uint8_t rcode = devConfig[driver]->ConfigureDevice(parent, port, lowspeed);
- -
591  if(parent == 0) {
-
592  // Send a bus reset on the root interface.
-
593  regWr(rHCTL, bmBUSRST); //issue bus reset
-
594  delay(102); // delay 102ms, compensate for clock inaccuracy.
-
595  } else {
-
596  // reset parent port
-
597  devConfig[parent]->ResetHubPort(port);
-
598  }
-
599  } else if(rcode == hrJERR && retries < 3) { // Some devices returns this when plugged in - trying to initialize the device again usually works
-
600  delay(100);
-
601  retries++;
-
602  goto again;
-
603  } else if(rcode)
-
604  return rcode;
-
605 
-
606  rcode = devConfig[driver]->Init(parent, port, lowspeed);
-
607  if(rcode == hrJERR && retries < 3) { // Some devices returns this when plugged in - trying to initialize the device again usually works
-
608  delay(100);
-
609  retries++;
-
610  goto again;
-
611  }
-
612  if(rcode) {
-
613  // Issue a bus reset, because the device may be in a limbo state
-
614  if(parent == 0) {
-
615  // Send a bus reset on the root interface.
-
616  regWr(rHCTL, bmBUSRST); //issue bus reset
-
617  delay(102); // delay 102ms, compensate for clock inaccuracy.
-
618  } else {
-
619  // reset parent port
-
620  devConfig[parent]->ResetHubPort(port);
-
621  }
-
622  }
-
623  return rcode;
-
624 }
-
625 
-
626 /*
-
627  * This is broken. We need to enumerate differently.
-
628  * It causes major problems with several devices if detected in an unexpected order.
-
629  *
-
630  *
-
631  * Oleg - I wouldn't do anything before the newly connected device is considered sane.
-
632  * i.e.(delays are not indicated for brevity):
-
633  * 1. reset
-
634  * 2. GetDevDescr();
-
635  * 3a. If ACK, continue with allocating address, addressing, etc.
-
636  * 3b. Else reset again, count resets, stop at some number (5?).
-
637  * 4. When max.number of resets is reached, toggle power/fail
-
638  * If desired, this could be modified by performing two resets with GetDevDescr() in the middle - however, from my experience, if a device answers to GDD()
-
639  * it doesn't need to be reset again
-
640  * New steps proposal:
-
641  * 1: get address pool instance. exit on fail
-
642  * 2: pUsb->getDevDescr(0, 0, constBufSize, (uint8_t*)buf). exit on fail.
-
643  * 3: bus reset, 100ms delay
-
644  * 4: set address
-
645  * 5: pUsb->setEpInfoEntry(bAddress, 1, epInfo), exit on fail
-
646  * 6: while (configurations) {
-
647  * for(each configuration) {
-
648  * for (each driver) {
-
649  * 6a: Ask device if it likes configuration. Returns 0 on OK.
-
650  * If successful, the driver configured device.
-
651  * The driver now owns the endpoints, and takes over managing them.
-
652  * The following will need codes:
-
653  * Everything went well, instance consumed, exit with success.
-
654  * Instance already in use, ignore it, try next driver.
-
655  * Not a supported device, ignore it, try next driver.
-
656  * Not a supported configuration for this device, ignore it, try next driver.
-
657  * Could not configure device, fatal, exit with fail.
-
658  * }
-
659  * }
-
660  * }
-
661  * 7: for(each driver) {
-
662  * 7a: Ask device if it knows this VID/PID. Acts exactly like 6a, but using VID/PID
-
663  * 8: if we get here, no driver likes the device plugged in, so exit failure.
-
664  *
-
665  */
-
666 uint8_t USB::Configuring(uint8_t parent, uint8_t port, bool lowspeed) {
-
667  //uint8_t bAddress = 0;
-
668  //printf("Configuring: parent = %i, port = %i\r\n", parent, port);
-
669  uint8_t devConfigIndex;
-
670  uint8_t rcode = 0;
-
671  uint8_t buf[sizeof (USB_DEVICE_DESCRIPTOR)];
-
672  USB_DEVICE_DESCRIPTOR *udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR *>(buf);
-
673  UsbDevice *p = NULL;
-
674  EpInfo *oldep_ptr = NULL;
-
675  EpInfo epInfo;
-
676 
-
677  epInfo.epAddr = 0;
-
678  epInfo.maxPktSize = 8;
-
679  epInfo.bmSndToggle = 0;
-
680  epInfo.bmRcvToggle = 0;
-
681  epInfo.bmNakPower = USB_NAK_MAX_POWER;
-
682 
-
683  //delay(2000);
-
684  AddressPool &addrPool = GetAddressPool();
-
685  // Get pointer to pseudo device with address 0 assigned
-
686  p = addrPool.GetUsbDevicePtr(0);
-
687  if(!p) {
-
688  //printf("Configuring error: USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL\r\n");
- -
690  }
-
691 
-
692  // Save old pointer to EP_RECORD of address 0
-
693  oldep_ptr = p->epinfo;
-
694 
-
695  // Temporary assign new pointer to epInfo to p->epinfo in order to
-
696  // avoid toggle inconsistence
-
697 
-
698  p->epinfo = &epInfo;
+
588  p->lowspeed = lowspeed;
+
589 
+
590  // Assign new address to the device
+
591  rcode = setAddr(0, 0, bAddress);
+
592 
+
593  if(rcode) {
+
594  addrPool.FreeAddress(bAddress);
+
595  bAddress = 0;
+
596  return rcode;
+
597  }
+
598  return 0;
+
599 };
+
600 
+
601 uint8_t USB::AttemptConfig(uint8_t driver, uint8_t parent, uint8_t port, bool lowspeed) {
+
602  //printf("AttemptConfig: parent = %i, port = %i\r\n", parent, port);
+
603  uint8_t retries = 0;
+
604 
+
605 again:
+
606  uint8_t rcode = devConfig[driver]->ConfigureDevice(parent, port, lowspeed);
+ +
608  if(parent == 0) {
+
609  // Send a bus reset on the root interface.
+
610  regWr(rHCTL, bmBUSRST); //issue bus reset
+
611  delay(102); // delay 102ms, compensate for clock inaccuracy.
+
612  } else {
+
613  // reset parent port
+
614  devConfig[parent]->ResetHubPort(port);
+
615  }
+
616  } else if(rcode == hrJERR && retries < 3) { // Some devices returns this when plugged in - trying to initialize the device again usually works
+
617  delay(100);
+
618  retries++;
+
619  goto again;
+
620  } else if(rcode)
+
621  return rcode;
+
622 
+
623  rcode = devConfig[driver]->Init(parent, port, lowspeed);
+
624  if(rcode == hrJERR && retries < 3) { // Some devices returns this when plugged in - trying to initialize the device again usually works
+
625  delay(100);
+
626  retries++;
+
627  goto again;
+
628  }
+
629  if(rcode) {
+
630  // Issue a bus reset, because the device may be in a limbo state
+
631  if(parent == 0) {
+
632  // Send a bus reset on the root interface.
+
633  regWr(rHCTL, bmBUSRST); //issue bus reset
+
634  delay(102); // delay 102ms, compensate for clock inaccuracy.
+
635  } else {
+
636  // reset parent port
+
637  devConfig[parent]->ResetHubPort(port);
+
638  }
+
639  }
+
640  return rcode;
+
641 }
+
642 
+
643 /*
+
644  * This is broken. We need to enumerate differently.
+
645  * It causes major problems with several devices if detected in an unexpected order.
+
646  *
+
647  *
+
648  * Oleg - I wouldn't do anything before the newly connected device is considered sane.
+
649  * i.e.(delays are not indicated for brevity):
+
650  * 1. reset
+
651  * 2. GetDevDescr();
+
652  * 3a. If ACK, continue with allocating address, addressing, etc.
+
653  * 3b. Else reset again, count resets, stop at some number (5?).
+
654  * 4. When max.number of resets is reached, toggle power/fail
+
655  * If desired, this could be modified by performing two resets with GetDevDescr() in the middle - however, from my experience, if a device answers to GDD()
+
656  * it doesn't need to be reset again
+
657  * New steps proposal:
+
658  * 1: get address pool instance. exit on fail
+
659  * 2: pUsb->getDevDescr(0, 0, constBufSize, (uint8_t*)buf). exit on fail.
+
660  * 3: bus reset, 100ms delay
+
661  * 4: set address
+
662  * 5: pUsb->setEpInfoEntry(bAddress, 1, epInfo), exit on fail
+
663  * 6: while (configurations) {
+
664  * for(each configuration) {
+
665  * for (each driver) {
+
666  * 6a: Ask device if it likes configuration. Returns 0 on OK.
+
667  * If successful, the driver configured device.
+
668  * The driver now owns the endpoints, and takes over managing them.
+
669  * The following will need codes:
+
670  * Everything went well, instance consumed, exit with success.
+
671  * Instance already in use, ignore it, try next driver.
+
672  * Not a supported device, ignore it, try next driver.
+
673  * Not a supported configuration for this device, ignore it, try next driver.
+
674  * Could not configure device, fatal, exit with fail.
+
675  * }
+
676  * }
+
677  * }
+
678  * 7: for(each driver) {
+
679  * 7a: Ask device if it knows this VID/PID. Acts exactly like 6a, but using VID/PID
+
680  * 8: if we get here, no driver likes the device plugged in, so exit failure.
+
681  *
+
682  */
+
683 uint8_t USB::Configuring(uint8_t parent, uint8_t port, bool lowspeed) {
+
684  //uint8_t bAddress = 0;
+
685  //printf("Configuring: parent = %i, port = %i\r\n", parent, port);
+
686  uint8_t devConfigIndex;
+
687  uint8_t rcode = 0;
+
688  uint8_t buf[sizeof (USB_DEVICE_DESCRIPTOR)];
+
689  USB_DEVICE_DESCRIPTOR *udd = reinterpret_cast<USB_DEVICE_DESCRIPTOR *>(buf);
+
690  UsbDevice *p = NULL;
+
691  EpInfo *oldep_ptr = NULL;
+
692  EpInfo epInfo;
+
693 
+
694  epInfo.epAddr = 0;
+
695  epInfo.maxPktSize = 8;
+
696  epInfo.bmSndToggle = 0;
+
697  epInfo.bmRcvToggle = 0;
+
698  epInfo.bmNakPower = USB_NAK_MAX_POWER;
699 
-
700  p->lowspeed = lowspeed;
-
701  // Get device descriptor
-
702  rcode = getDevDescr(0, 0, sizeof (USB_DEVICE_DESCRIPTOR), (uint8_t*)buf);
-
703 
-
704  // Restore p->epinfo
-
705  p->epinfo = oldep_ptr;
-
706 
-
707  if(rcode) {
-
708  //printf("Configuring error: Can't get USB_DEVICE_DESCRIPTOR\r\n");
-
709  return rcode;
-
710  }
+
700  //delay(2000);
+
701  AddressPool &addrPool = GetAddressPool();
+
702  // Get pointer to pseudo device with address 0 assigned
+
703  p = addrPool.GetUsbDevicePtr(0);
+
704  if(!p) {
+
705  //printf("Configuring error: USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL\r\n");
+ +
707  }
+
708 
+
709  // Save old pointer to EP_RECORD of address 0
+
710  oldep_ptr = p->epinfo;
711 
-
712  // to-do?
-
713  // Allocate new address according to device class
-
714  //bAddress = addrPool.AllocAddress(parent, false, port);
-
715 
-
716  uint16_t vid = udd->idVendor;
-
717  uint16_t pid = udd->idProduct;
-
718  uint8_t klass = udd->bDeviceClass;
-
719  uint8_t subklass = udd->bDeviceSubClass;
-
720  // Attempt to configure if VID/PID or device class matches with a driver
-
721  // Qualify with subclass too.
-
722  //
-
723  // VID/PID & class tests default to false for drivers not yet ported
-
724  // subclass defaults to true, so you don't have to define it if you don't have to.
-
725  //
-
726  for(devConfigIndex = 0; devConfigIndex < USB_NUMDEVICES; devConfigIndex++) {
-
727  if(!devConfig[devConfigIndex]) continue; // no driver
-
728  if(devConfig[devConfigIndex]->GetAddress()) continue; // consumed
-
729  if(devConfig[devConfigIndex]->DEVSUBCLASSOK(subklass) && (devConfig[devConfigIndex]->VIDPIDOK(vid, pid) || devConfig[devConfigIndex]->DEVCLASSOK(klass))) {
-
730  rcode = AttemptConfig(devConfigIndex, parent, port, lowspeed);
- -
732  break;
-
733  }
-
734  }
-
735 
-
736  if(devConfigIndex < USB_NUMDEVICES) {
-
737  return rcode;
-
738  }
-
739 
-
740 
-
741  // blindly attempt to configure
-
742  for(devConfigIndex = 0; devConfigIndex < USB_NUMDEVICES; devConfigIndex++) {
-
743  if(!devConfig[devConfigIndex]) continue;
-
744  if(devConfig[devConfigIndex]->GetAddress()) continue; // consumed
-
745  if(devConfig[devConfigIndex]->DEVSUBCLASSOK(subklass) && (devConfig[devConfigIndex]->VIDPIDOK(vid, pid) || devConfig[devConfigIndex]->DEVCLASSOK(klass))) continue; // If this is true it means it must have returned USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED above
-
746  rcode = AttemptConfig(devConfigIndex, parent, port, lowspeed);
-
747 
-
748  //printf("ERROR ENUMERATING %2.2x\r\n", rcode);
- -
750  // in case of an error dev_index should be reset to 0
-
751  // in order to start from the very beginning the
-
752  // next time the program gets here
-
753  //if (rcode != USB_DEV_CONFIG_ERROR_DEVICE_INIT_INCOMPLETE)
-
754  // devConfigIndex = 0;
-
755  return rcode;
-
756  }
-
757  }
-
758  // if we get here that means that the device class is not supported by any of registered classes
-
759  rcode = DefaultAddressing(parent, port, lowspeed);
-
760 
-
761  return rcode;
-
762 }
-
763 
-
764 uint8_t USB::ReleaseDevice(uint8_t addr) {
-
765  if(!addr)
-
766  return 0;
-
767 
-
768  for(uint8_t i = 0; i < USB_NUMDEVICES; i++) {
-
769  if(!devConfig[i]) continue;
-
770  if(devConfig[i]->GetAddress() == addr)
-
771  return devConfig[i]->Release();
-
772  }
-
773  return 0;
-
774 }
-
775 
-
776 #if 1
-
777 //get device descriptor
-
778 
-
779 uint8_t USB::getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* dataptr) {
-
780  return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, 0x00, USB_DESCRIPTOR_DEVICE, 0x0000, nbytes, nbytes, dataptr, NULL));
-
781 }
-
782 //get configuration descriptor
-
783 
-
784 uint8_t USB::getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t conf, uint8_t* dataptr) {
-
785  return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, conf, USB_DESCRIPTOR_CONFIGURATION, 0x0000, nbytes, nbytes, dataptr, NULL));
-
786 }
-
787 
-
788 /* Requests Configuration Descriptor. Sends two Get Conf Descr requests. The first one gets the total length of all descriptors, then the second one requests this
-
789  total length. The length of the first request can be shorter ( 4 bytes ), however, there are devices which won't work unless this length is set to 9 */
-
790 uint8_t USB::getConfDescr(uint8_t addr, uint8_t ep, uint8_t conf, USBReadParser *p) {
-
791  const uint8_t bufSize = 64;
-
792  uint8_t buf[bufSize];
-
793  USB_CONFIGURATION_DESCRIPTOR *ucd = reinterpret_cast<USB_CONFIGURATION_DESCRIPTOR *>(buf);
-
794 
-
795  uint8_t ret = getConfDescr(addr, ep, 9, conf, buf);
-
796 
-
797  if(ret)
-
798  return ret;
-
799 
-
800  uint16_t total = ucd->wTotalLength;
-
801 
-
802  //USBTRACE2("\r\ntotal conf.size:", total);
-
803 
-
804  return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, conf, USB_DESCRIPTOR_CONFIGURATION, 0x0000, total, bufSize, buf, p));
-
805 }
-
806 
-
807 //get string descriptor
-
808 
-
809 uint8_t USB::getStrDescr(uint8_t addr, uint8_t ep, uint16_t ns, uint8_t index, uint16_t langid, uint8_t* dataptr) {
-
810  return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, index, USB_DESCRIPTOR_STRING, langid, ns, ns, dataptr, NULL));
-
811 }
-
812 //set address
+
712  // Temporary assign new pointer to epInfo to p->epinfo in order to
+
713  // avoid toggle inconsistence
+
714 
+
715  p->epinfo = &epInfo;
+
716 
+
717  p->lowspeed = lowspeed;
+
718  // Get device descriptor
+
719  rcode = getDevDescr(0, 0, sizeof (USB_DEVICE_DESCRIPTOR), (uint8_t*)buf);
+
720 
+
721  // Restore p->epinfo
+
722  p->epinfo = oldep_ptr;
+
723 
+
724  if(rcode) {
+
725  //printf("Configuring error: Can't get USB_DEVICE_DESCRIPTOR\r\n");
+
726  return rcode;
+
727  }
+
728 
+
729  // to-do?
+
730  // Allocate new address according to device class
+
731  //bAddress = addrPool.AllocAddress(parent, false, port);
+
732 
+
733  uint16_t vid = udd->idVendor;
+
734  uint16_t pid = udd->idProduct;
+
735  uint8_t klass = udd->bDeviceClass;
+
736  uint8_t subklass = udd->bDeviceSubClass;
+
737  // Attempt to configure if VID/PID or device class matches with a driver
+
738  // Qualify with subclass too.
+
739  //
+
740  // VID/PID & class tests default to false for drivers not yet ported
+
741  // subclass defaults to true, so you don't have to define it if you don't have to.
+
742  //
+
743  for(devConfigIndex = 0; devConfigIndex < USB_NUMDEVICES; devConfigIndex++) {
+
744  if(!devConfig[devConfigIndex]) continue; // no driver
+
745  if(devConfig[devConfigIndex]->GetAddress()) continue; // consumed
+
746  if(devConfig[devConfigIndex]->DEVSUBCLASSOK(subklass) && (devConfig[devConfigIndex]->VIDPIDOK(vid, pid) || devConfig[devConfigIndex]->DEVCLASSOK(klass))) {
+
747  rcode = AttemptConfig(devConfigIndex, parent, port, lowspeed);
+ +
749  break;
+
750  }
+
751  }
+
752 
+
753  if(devConfigIndex < USB_NUMDEVICES) {
+
754  return rcode;
+
755  }
+
756 
+
757 
+
758  // blindly attempt to configure
+
759  for(devConfigIndex = 0; devConfigIndex < USB_NUMDEVICES; devConfigIndex++) {
+
760  if(!devConfig[devConfigIndex]) continue;
+
761  if(devConfig[devConfigIndex]->GetAddress()) continue; // consumed
+
762  if(devConfig[devConfigIndex]->DEVSUBCLASSOK(subklass) && (devConfig[devConfigIndex]->VIDPIDOK(vid, pid) || devConfig[devConfigIndex]->DEVCLASSOK(klass))) continue; // If this is true it means it must have returned USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED above
+
763  rcode = AttemptConfig(devConfigIndex, parent, port, lowspeed);
+
764 
+
765  //printf("ERROR ENUMERATING %2.2x\r\n", rcode);
+ +
767  // in case of an error dev_index should be reset to 0
+
768  // in order to start from the very beginning the
+
769  // next time the program gets here
+
770  //if (rcode != USB_DEV_CONFIG_ERROR_DEVICE_INIT_INCOMPLETE)
+
771  // devConfigIndex = 0;
+
772  return rcode;
+
773  }
+
774  }
+
775  // if we get here that means that the device class is not supported by any of registered classes
+
776  rcode = DefaultAddressing(parent, port, lowspeed);
+
777 
+
778  return rcode;
+
779 }
+
780 
+
781 uint8_t USB::ReleaseDevice(uint8_t addr) {
+
782  if(!addr)
+
783  return 0;
+
784 
+
785  for(uint8_t i = 0; i < USB_NUMDEVICES; i++) {
+
786  if(!devConfig[i]) continue;
+
787  if(devConfig[i]->GetAddress() == addr)
+
788  return devConfig[i]->Release();
+
789  }
+
790  return 0;
+
791 }
+
792 
+
793 #if 1
+
794 //get device descriptor
+
795 
+
796 uint8_t USB::getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* dataptr) {
+
797  return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, 0x00, USB_DESCRIPTOR_DEVICE, 0x0000, nbytes, nbytes, dataptr, NULL));
+
798 }
+
799 //get configuration descriptor
+
800 
+
801 uint8_t USB::getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t conf, uint8_t* dataptr) {
+
802  return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, conf, USB_DESCRIPTOR_CONFIGURATION, 0x0000, nbytes, nbytes, dataptr, NULL));
+
803 }
+
804 
+
805 /* Requests Configuration Descriptor. Sends two Get Conf Descr requests. The first one gets the total length of all descriptors, then the second one requests this
+
806  total length. The length of the first request can be shorter ( 4 bytes ), however, there are devices which won't work unless this length is set to 9 */
+
807 uint8_t USB::getConfDescr(uint8_t addr, uint8_t ep, uint8_t conf, USBReadParser *p) {
+
808  const uint8_t bufSize = 64;
+
809  uint8_t buf[bufSize];
+
810  USB_CONFIGURATION_DESCRIPTOR *ucd = reinterpret_cast<USB_CONFIGURATION_DESCRIPTOR *>(buf);
+
811 
+
812  uint8_t ret = getConfDescr(addr, ep, 9, conf, buf);
813 
-
814 uint8_t USB::setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr) {
-
815  uint8_t rcode = ctrlReq(oldaddr, ep, bmREQ_SET, USB_REQUEST_SET_ADDRESS, newaddr, 0x00, 0x0000, 0x0000, 0x0000, NULL, NULL);
-
816  //delay(2); //per USB 2.0 sect.9.2.6.3
-
817  delay(300); // Older spec says you should wait at least 200ms
-
818  return rcode;
-
819  //return ( ctrlReq(oldaddr, ep, bmREQ_SET, USB_REQUEST_SET_ADDRESS, newaddr, 0x00, 0x0000, 0x0000, 0x0000, NULL, NULL));
-
820 }
-
821 //set configuration
-
822 
-
823 uint8_t USB::setConf(uint8_t addr, uint8_t ep, uint8_t conf_value) {
-
824  return ( ctrlReq(addr, ep, bmREQ_SET, USB_REQUEST_SET_CONFIGURATION, conf_value, 0x00, 0x0000, 0x0000, 0x0000, NULL, NULL));
-
825 }
-
826 
-
827 #endif // defined(USB_METHODS_INLINE)
-
uint8_t getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t conf, uint8_t *dataptr)
Definition: Usb.cpp:784
+
814  if(ret)
+
815  return ret;
+
816 
+
817  uint16_t total = ucd->wTotalLength;
+
818 
+
819  //USBTRACE2("\r\ntotal conf.size:", total);
+
820 
+
821  return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, conf, USB_DESCRIPTOR_CONFIGURATION, 0x0000, total, bufSize, buf, p));
+
822 }
+
823 
+
824 //get string descriptor
+
825 
+
826 uint8_t USB::getStrDescr(uint8_t addr, uint8_t ep, uint16_t ns, uint8_t index, uint16_t langid, uint8_t* dataptr) {
+
827  return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, index, USB_DESCRIPTOR_STRING, langid, ns, ns, dataptr, NULL));
+
828 }
+
829 //set address
+
830 
+
831 uint8_t USB::setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr) {
+
832  uint8_t rcode = ctrlReq(oldaddr, ep, bmREQ_SET, USB_REQUEST_SET_ADDRESS, newaddr, 0x00, 0x0000, 0x0000, 0x0000, NULL, NULL);
+
833  //delay(2); //per USB 2.0 sect.9.2.6.3
+
834  delay(300); // Older spec says you should wait at least 200ms
+
835  return rcode;
+
836  //return ( ctrlReq(oldaddr, ep, bmREQ_SET, USB_REQUEST_SET_ADDRESS, newaddr, 0x00, 0x0000, 0x0000, 0x0000, NULL, NULL));
+
837 }
+
838 //set configuration
+
839 
+
840 uint8_t USB::setConf(uint8_t addr, uint8_t ep, uint8_t conf_value) {
+
841  return ( ctrlReq(addr, ep, bmREQ_SET, USB_REQUEST_SET_CONFIGURATION, conf_value, 0x00, 0x0000, 0x0000, 0x0000, NULL, NULL));
+
842 }
+
843 
+
844 #endif // defined(USB_METHODS_INLINE)
+
uint8_t getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t conf, uint8_t *dataptr)
Definition: Usb.cpp:801
uint8_t bmRcvToggle
Definition: address.h:48
virtual uint8_t Poll()
Definition: UsbCore.h:149
@@ -926,7 +943,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
#define USB_ERROR_EPINFO_IS_NULL
Definition: UsbCore.h:96
uint8_t bmNakPower
Definition: address.h:49
-
EpInfo * getEpInfoEntry(uint8_t addr, uint8_t ep)
Definition: Usb.cpp:51
+
EpInfo * getEpInfoEntry(uint8_t addr, uint8_t ep)
Definition: Usb.cpp:44
#define bmSOFKAENAB
Definition: max3421e.h:173
#define USB_DESCRIPTOR_STRING
Definition: usb_ch9.h:72
@@ -941,25 +958,25 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
#define USB_DESCRIPTOR_DEVICE
Definition: usb_ch9.h:70
#define bmRCVTOG1
Definition: max3421e.h:188
#define USB_ERROR_INVALID_MAX_PKT_SIZE
Definition: UsbCore.h:99
-
uint8_t setConf(uint8_t addr, uint8_t ep, uint8_t conf_value)
Definition: Usb.cpp:823
+
uint8_t setConf(uint8_t addr, uint8_t ep, uint8_t conf_value)
Definition: Usb.cpp:840
#define USB_STATE_DETACHED
Definition: UsbCore.h:119
#define USB_NUMDEVICES
Definition: UsbCore.h:112
#define rRCVBC
Definition: max3421e.h:47
#define hrJERR
Definition: max3421e.h:227
-
uint8_t setEpInfoEntry(uint8_t addr, uint8_t epcount, EpInfo *eprecord_ptr)
Definition: Usb.cpp:71
+
uint8_t setEpInfoEntry(uint8_t addr, uint8_t epcount, EpInfo *eprecord_ptr)
Definition: Usb.cpp:64
virtual uint8_t ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed)
Definition: UsbCore.h:141
-
uint8_t Task()
Definition: usbhost.h:542
+
uint8_t Task()
Definition: usbhost.h:544
#define hrSUCCESS
Definition: max3421e.h:214
#define USB_STATE_ERROR
Definition: UsbCore.h:132
uint8_t bmRequestType
Definition: UsbCore.h:179
#define bmSNDTOGRD
Definition: max3421e.h:207
-
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)
Definition: Usb.cpp:133
+
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)
Definition: Usb.cpp:126
#define USB_DESCRIPTOR_CONFIGURATION
Definition: usb_ch9.h:71
virtual UsbDevice * GetUsbDevicePtr(uint8_t addr)=0
#define bmHXFRDNIRQ
Definition: max3421e.h:153
-
uint8_t setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr)
Definition: Usb.cpp:814
-
USB(void)
Definition: Usb.cpp:32
+
uint8_t setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr)
Definition: Usb.cpp:831
+
USB(void)
Definition: Usb.cpp:25
#define USB_STATE_RUNNING
Definition: UsbCore.h:131
uint8_t epAddr
Definition: address.h:40
@@ -975,19 +992,19 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
union SETUP_PKT::@33 wVal_u
Definition: address.h:39
#define rMODE
Definition: max3421e.h:167
-
void setUsbTaskState(uint8_t state)
Definition: Usb.cpp:47
-
uint8_t outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *data)
Definition: Usb.cpp:300
+
void setUsbTaskState(uint8_t state)
Definition: Usb.cpp:40
+
uint8_t outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *data)
Definition: Usb.cpp:303
#define hrNAK
Definition: max3421e.h:218
#define bmREQ_GET_DESCR
Definition: UsbCore.h:60
#define rSNDBC
Definition: max3421e.h:48
#define rHRSL
Definition: max3421e.h:203
#define USB_ATTACHED_SUBSTATE_RESET_DEVICE
Definition: UsbCore.h:124
-
uint8_t * bytesRd(uint8_t reg, uint8_t nbytes, uint8_t *data_p)
Definition: usbhost.h:322
+
uint8_t * bytesRd(uint8_t reg, uint8_t nbytes, uint8_t *data_p)
Definition: usbhost.h:323
#define tokINHS
Definition: max3421e.h:198
#define bmLOWSPEED
Definition: max3421e.h:171
virtual void ResetHubPort(uint8_t port)
Definition: UsbCore.h:157
uint8_t * bytesWr(uint8_t reg, uint8_t nbytes, uint8_t *data_p)
Definition: usbhost.h:220
-
uint8_t getStrDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t index, uint16_t langid, uint8_t *dataptr)
Definition: Usb.cpp:809
+
uint8_t getStrDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t index, uint16_t langid, uint8_t *dataptr)
Definition: Usb.cpp:826
#define USB_REQUEST_SET_ADDRESS
Definition: usb_ch9.h:43
#define tokSETUP
Definition: max3421e.h:195
@@ -1000,11 +1017,11 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
uint8_t devAddress
Definition: address.h:74
#define tokOUTHS
Definition: max3421e.h:199
-
uint8_t getUsbTaskState(void)
Definition: Usb.cpp:43
+
uint8_t getUsbTaskState(void)
Definition: Usb.cpp:36
#define USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL
Definition: UsbCore.h:95
#define USB_STATE_MASK
Definition: UsbCore.h:117
#define USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED
Definition: UsbCore.h:90
-
void Task(void)
Definition: Usb.cpp:438
+
void Task(void)
Definition: Usb.cpp:455
#define USB_DETACHED_SUBSTATE_ILLEGAL
Definition: UsbCore.h:122
#define hrTIMEOUT
Definition: max3421e.h:228
#define rPERADDR
Definition: max3421e.h:179
@@ -1013,17 +1030,17 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
void regWr(uint8_t reg, uint8_t data)
Definition: usbhost.h:177
#define bmRCVTOG0
Definition: max3421e.h:187
uint8_t epcount
Definition: address.h:85
-
uint8_t inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t *data, uint8_t bInterval=0)
Definition: Usb.cpp:213
+
uint8_t inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t *data, uint8_t bInterval=0)
Definition: Usb.cpp:209
#define USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL
Definition: UsbCore.h:93
#define USB_STATE_CONFIGURING
Definition: UsbCore.h:130
-
uint8_t dispatchPkt(uint8_t token, uint8_t ep, uint16_t nak_limit)
Definition: Usb.cpp:384
+
uint8_t dispatchPkt(uint8_t token, uint8_t ep, uint16_t nak_limit)
Definition: Usb.cpp:401
virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed)
Definition: UsbCore.h:137
#define bmSNDTOG0
Definition: max3421e.h:189
-
uint8_t regRd(uint8_t reg)
Definition: usbhost.h:283
+
uint8_t regRd(uint8_t reg)
Definition: usbhost.h:284
uint8_t maxPktSize
Definition: address.h:41
AddressPool & GetAddressPool()
Definition: UsbCore.h:226
#define USB_ERROR_INVALID_ARGUMENT
Definition: UsbCore.h:97
-
uint8_t Configuring(uint8_t parent, uint8_t port, bool lowspeed)
Definition: Usb.cpp:666
+
uint8_t Configuring(uint8_t parent, uint8_t port, bool lowspeed)
Definition: Usb.cpp:683
union SETUP_PKT::@32 ReqType_u
#define USBTRACE3(s, r, l)
Definition: macros.h:85
uint8_t bRequest
Definition: UsbCore.h:187
@@ -1040,13 +1057,13 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
#define USB_REQUEST_SET_CONFIGURATION
Definition: usb_ch9.h:47
#define USB_DETACHED_SUBSTATE_WAIT_FOR_DEVICE
Definition: UsbCore.h:121
uint8_t wValueHi
Definition: UsbCore.h:194
-
uint8_t DefaultAddressing(uint8_t parent, uint8_t port, bool lowspeed)
Definition: Usb.cpp:544
+
uint8_t DefaultAddressing(uint8_t parent, uint8_t port, bool lowspeed)
Definition: Usb.cpp:561
#define USB_DETACHED_SUBSTATE_INITIALIZE
Definition: UsbCore.h:120
-
uint8_t getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *dataptr)
defined(USB_METHODS_INLINE)
Definition: Usb.cpp:779
+
uint8_t getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *dataptr)
defined(USB_METHODS_INLINE)
Definition: Usb.cpp:796
#define USB_ATTACHED_SUBSTATE_WAIT_SOF
Definition: UsbCore.h:126
uint8_t wValueLo
Definition: UsbCore.h:193
#define bmSNDTOG1
Definition: max3421e.h:190
-
uint8_t ReleaseDevice(uint8_t addr)
Definition: Usb.cpp:764
+
uint8_t ReleaseDevice(uint8_t addr)
Definition: Usb.cpp:781
#define USB_ERROR_TRANSFER_TIMEOUT
Definition: UsbCore.h:105
#define USB_ERROR_CONFIG_REQUIRES_ADDITIONAL_RESET
Definition: UsbCore.h:101
diff --git a/_usb_core_8h_source.html b/_usb_core_8h_source.html index 843b2080..c3babd81 100644 --- a/_usb_core_8h_source.html +++ b/_usb_core_8h_source.html @@ -396,56 +396,56 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
309 #endif // defined(USB_METHODS_INLINE)
310 
311 #endif /* USBCORE_H */
-
uint8_t getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t conf, uint8_t *dataptr)
Definition: Usb.cpp:784
+
uint8_t getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t conf, uint8_t *dataptr)
Definition: Usb.cpp:801
uint16_t wValue
Definition: UsbCore.h:190
virtual uint8_t Poll()
Definition: UsbCore.h:149
#define bmHUBPRE
Definition: max3421e.h:172
virtual uint8_t GetAddress()
Definition: UsbCore.h:153
-
EpInfo * getEpInfoEntry(uint8_t addr, uint8_t ep)
Definition: Usb.cpp:51
+
EpInfo * getEpInfoEntry(uint8_t addr, uint8_t ep)
Definition: Usb.cpp:44
#define USB_DESCRIPTOR_STRING
Definition: usb_ch9.h:72
uint16_t wLength
Definition: UsbCore.h:198
#define USB_REQUEST_GET_DESCRIPTOR
Definition: usb_ch9.h:44
#define USB_DESCRIPTOR_DEVICE
Definition: usb_ch9.h:70
uint8_t ctrlData(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *dataptr, bool direction)
-
uint8_t setConf(uint8_t addr, uint8_t ep, uint8_t conf_value)
Definition: Usb.cpp:823
+
uint8_t setConf(uint8_t addr, uint8_t ep, uint8_t conf_value)
Definition: Usb.cpp:840
#define USB_NUMDEVICES
Definition: UsbCore.h:112
-
uint8_t setEpInfoEntry(uint8_t addr, uint8_t epcount, EpInfo *eprecord_ptr)
Definition: Usb.cpp:71
+
uint8_t setEpInfoEntry(uint8_t addr, uint8_t epcount, EpInfo *eprecord_ptr)
Definition: Usb.cpp:64
virtual uint8_t ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed)
Definition: UsbCore.h:141
uint8_t bmRequestType
Definition: UsbCore.h:179
-
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)
Definition: Usb.cpp:133
+
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)
Definition: Usb.cpp:126
#define USB_DESCRIPTOR_CONFIGURATION
Definition: usb_ch9.h:71
void ResetHubPreMask()
Definition: UsbCore.h:222
-
uint8_t setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr)
Definition: Usb.cpp:814
-
USB(void)
Definition: Usb.cpp:32
+
uint8_t setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr)
Definition: Usb.cpp:831
+
USB(void)
Definition: Usb.cpp:25
void(* UsbDeviceHandleFunc)(UsbDevice *pdev)
Definition: address.h:97
uint16_t wIndex
Definition: UsbCore.h:197
void SetHubPreMask()
Definition: UsbCore.h:218
Definition: address.h:39
-
void setUsbTaskState(uint8_t state)
Definition: Usb.cpp:47
-
uint8_t outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *data)
Definition: Usb.cpp:300
+
void setUsbTaskState(uint8_t state)
Definition: Usb.cpp:40
+
uint8_t outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *data)
Definition: Usb.cpp:303
#define bmREQ_GET_DESCR
Definition: UsbCore.h:60
virtual void ResetHubPort(uint8_t port)
Definition: UsbCore.h:157
#define USB_ERROR_UNABLE_TO_REGISTER_DEVICE_CLASS
Definition: UsbCore.h:92
-
uint8_t getStrDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t index, uint16_t langid, uint8_t *dataptr)
Definition: Usb.cpp:809
+
uint8_t getStrDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t index, uint16_t langid, uint8_t *dataptr)
Definition: Usb.cpp:826
#define USB_REQUEST_SET_ADDRESS
Definition: usb_ch9.h:43
uint8_t ctrlStatus(uint8_t ep, bool direction, uint16_t nak_limit)
MAX3421e< P10, P9 > MAX3421E
Definition: UsbCore.h:56
-
uint8_t getUsbTaskState(void)
Definition: Usb.cpp:43
-
void Task(void)
Definition: Usb.cpp:438
+
uint8_t getUsbTaskState(void)
Definition: Usb.cpp:36
+
void Task(void)
Definition: Usb.cpp:455
virtual bool DEVSUBCLASSOK(uint8_t subklass)
Definition: UsbCore.h:169
-
uint8_t inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t *data, uint8_t bInterval=0)
Definition: Usb.cpp:213
+
uint8_t inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t *data, uint8_t bInterval=0)
Definition: Usb.cpp:209
void ForEachUsbDevice(UsbDeviceHandleFunc pfunc)
Definition: address.h:199
-
uint8_t dispatchPkt(uint8_t token, uint8_t ep, uint16_t nak_limit)
Definition: Usb.cpp:384
+
uint8_t dispatchPkt(uint8_t token, uint8_t ep, uint16_t nak_limit)
Definition: Usb.cpp:401
virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed)
Definition: UsbCore.h:137
AddressPool & GetAddressPool()
Definition: UsbCore.h:226
virtual bool VIDPIDOK(uint16_t vid, uint16_t pid)
Definition: UsbCore.h:161
-
uint8_t Configuring(uint8_t parent, uint8_t port, bool lowspeed)
Definition: Usb.cpp:666
+
uint8_t Configuring(uint8_t parent, uint8_t port, bool lowspeed)
Definition: Usb.cpp:683
Definition: UsbCore.h:210
uint8_t bRequest
Definition: UsbCore.h:187
virtual uint8_t Release()
Definition: UsbCore.h:145
@@ -455,10 +455,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
void ForEachUsbDevice(UsbDeviceHandleFunc pfunc)
Definition: UsbCore.h:240
#define USB_REQUEST_SET_CONFIGURATION
Definition: usb_ch9.h:47
uint8_t wValueHi
Definition: UsbCore.h:194
-
uint8_t DefaultAddressing(uint8_t parent, uint8_t port, bool lowspeed)
Definition: Usb.cpp:544
-
uint8_t getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *dataptr)
defined(USB_METHODS_INLINE)
Definition: Usb.cpp:779
+
uint8_t DefaultAddressing(uint8_t parent, uint8_t port, bool lowspeed)
Definition: Usb.cpp:561
+
uint8_t getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *dataptr)
defined(USB_METHODS_INLINE)
Definition: Usb.cpp:796
uint8_t wValueLo
Definition: UsbCore.h:193
-
uint8_t ReleaseDevice(uint8_t addr)
Definition: Usb.cpp:764
+
uint8_t ReleaseDevice(uint8_t addr)
Definition: Usb.cpp:781