mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Make ADK work as per USB spec.
This commit is contained in:
parent
416ca04fee
commit
47b9b257d6
2 changed files with 11 additions and 4 deletions
12
adk.cpp
12
adk.cpp
|
@ -58,14 +58,18 @@ ready(false) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t ADK::ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
|
return Init(parent, port, lowspeed); // Just call Init. Yes, really!
|
||||||
|
}
|
||||||
|
|
||||||
/* Connection initialization of an Android phone */
|
/* Connection initialization of an Android phone */
|
||||||
uint8_t ADK::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
uint8_t ADK::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
|
|
||||||
uint8_t buf[sizeof (USB_DEVICE_DESCRIPTOR)];
|
uint8_t buf[sizeof (USB_DEVICE_DESCRIPTOR)];
|
||||||
uint8_t rcode;
|
uint8_t rcode;
|
||||||
|
uint8_t num_of_conf; // number of configurations
|
||||||
UsbDevice *p = NULL;
|
UsbDevice *p = NULL;
|
||||||
EpInfo *oldep_ptr = NULL;
|
EpInfo *oldep_ptr = NULL;
|
||||||
uint8_t num_of_conf; // number of configurations
|
|
||||||
|
|
||||||
// get memory address of USB device address pool
|
// get memory address of USB device address pool
|
||||||
AddressPool &addrPool = pUsb->GetAddressPool();
|
AddressPool &addrPool = pUsb->GetAddressPool();
|
||||||
|
@ -114,7 +118,6 @@ uint8_t ADK::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
|
|
||||||
// Extract Max Packet Size from device descriptor
|
// Extract Max Packet Size from device descriptor
|
||||||
epInfo[0].maxPktSize = (uint8_t)((USB_DEVICE_DESCRIPTOR*)buf)->bMaxPacketSize0;
|
epInfo[0].maxPktSize = (uint8_t)((USB_DEVICE_DESCRIPTOR*)buf)->bMaxPacketSize0;
|
||||||
|
|
||||||
// Assign new address to the device
|
// Assign new address to the device
|
||||||
rcode = pUsb->setAddr(0, 0, bAddress);
|
rcode = pUsb->setAddr(0, 0, bAddress);
|
||||||
if (rcode) {
|
if (rcode) {
|
||||||
|
@ -126,6 +129,8 @@ uint8_t ADK::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
}//if (rcode...
|
}//if (rcode...
|
||||||
|
|
||||||
//USBTRACE2("\r\nAddr:", bAddress);
|
//USBTRACE2("\r\nAddr:", bAddress);
|
||||||
|
// Spec says you should wait at least 200ms.
|
||||||
|
delay(300);
|
||||||
|
|
||||||
p->lowspeed = false;
|
p->lowspeed = false;
|
||||||
|
|
||||||
|
@ -222,7 +227,8 @@ uint8_t ADK::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
if (rcode) {
|
if (rcode) {
|
||||||
goto FailSwAcc; //init fails
|
goto FailSwAcc; //init fails
|
||||||
}
|
}
|
||||||
rcode = -1;
|
rcode = USB_ERROR_CONFIG_REQUIRES_ADDITIONAL_RESET;
|
||||||
|
delay(1000); // Give Android a chance to do its reset. This is a guess, and possibly could be lower.
|
||||||
goto SwAttempt; //switch to accessory mode attempted
|
goto SwAttempt; //switch to accessory mode attempted
|
||||||
|
|
||||||
/* diagnostic messages */
|
/* diagnostic messages */
|
||||||
|
|
1
adk.h
1
adk.h
|
@ -110,6 +110,7 @@ public:
|
||||||
|
|
||||||
|
|
||||||
// USBDeviceConfig implementation
|
// USBDeviceConfig implementation
|
||||||
|
virtual uint8_t ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed);
|
||||||
virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed);
|
virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed);
|
||||||
virtual uint8_t Release();
|
virtual uint8_t Release();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue