mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
629594f957
was using an old version of adk.cpp and adk.h
This commit is contained in:
parent
10453c0fe8
commit
0be721e1b3
2 changed files with 45 additions and 28 deletions
59
adk.cpp
59
adk.cpp
|
@ -30,7 +30,6 @@ ADK::ADK(USB *p, const char* manufacturer,
|
||||||
const char* serial) :
|
const char* serial) :
|
||||||
|
|
||||||
/* ADK ID Strings */
|
/* ADK ID Strings */
|
||||||
|
|
||||||
manufacturer(manufacturer),
|
manufacturer(manufacturer),
|
||||||
model(model),
|
model(model),
|
||||||
description(description),
|
description(description),
|
||||||
|
@ -46,12 +45,10 @@ ready(false) {
|
||||||
for (uint8_t i = 0; i < ADK_MAX_ENDPOINTS; i++) {
|
for (uint8_t i = 0; i < ADK_MAX_ENDPOINTS; i++) {
|
||||||
epInfo[i].epAddr = 0;
|
epInfo[i].epAddr = 0;
|
||||||
epInfo[i].maxPktSize = (i) ? 0 : 8;
|
epInfo[i].maxPktSize = (i) ? 0 : 8;
|
||||||
epInfo[i].epAttribs = (0xfc & (USB_NAK_MAX_POWER << 2));
|
epInfo[i].epAttribs = 0;
|
||||||
|
epInfo[i].bmNakPower = (i) ? USB_NAK_NOWAIT : USB_NAK_MAX_POWER;
|
||||||
}//for(uint8_t i=0; i<ADK_MAX_ENDPOINTS; i++...
|
}//for(uint8_t i=0; i<ADK_MAX_ENDPOINTS; i++...
|
||||||
|
|
||||||
//set bulk-IN EP naklimit to 1
|
|
||||||
epInfo[epDataInIndex].epAttribs = (0xfc & (USB_NAK_NOWAIT << 2));
|
|
||||||
|
|
||||||
// register in USB subsystem
|
// register in USB subsystem
|
||||||
if (pUsb) {
|
if (pUsb) {
|
||||||
pUsb->RegisterDeviceClass(this); //set devConfig[] entry
|
pUsb->RegisterDeviceClass(this); //set devConfig[] entry
|
||||||
|
@ -64,7 +61,6 @@ uint8_t ADK::ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
|
|
||||||
/* 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
|
uint8_t num_of_conf; // number of configurations
|
||||||
|
@ -118,6 +114,7 @@ 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) {
|
||||||
|
@ -156,10 +153,18 @@ uint8_t ADK::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
num_of_conf = ((USB_DEVICE_DESCRIPTOR*)buf)->bNumConfigurations;
|
num_of_conf = ((USB_DEVICE_DESCRIPTOR*)buf)->bNumConfigurations;
|
||||||
|
|
||||||
//USBTRACE2("\r\nNC:",num_of_conf);
|
//USBTRACE2("\r\nNC:",num_of_conf);
|
||||||
|
|
||||||
for (uint8_t i = 0; i < num_of_conf; i++) {
|
for (uint8_t i = 0; i < num_of_conf; i++) {
|
||||||
ConfigDescParser < 0, 0, 0, 0 > confDescrParser(this);
|
ConfigDescParser < 0, 0, 0, 0 > confDescrParser(this);
|
||||||
|
delay(1);
|
||||||
rcode = pUsb->getConfDescr(bAddress, 0, i, &confDescrParser);
|
rcode = pUsb->getConfDescr(bAddress, 0, i, &confDescrParser);
|
||||||
|
#if defined(XOOM)
|
||||||
|
//added by Jaylen Scott Vanorden
|
||||||
|
if (rcode) {
|
||||||
|
USBTRACE2("\r\nGot 1st bad code for config: ", rcode);
|
||||||
|
// Try once more
|
||||||
|
rcode = pUsb->getConfDescr(bAddress, 0, i, &confDescrParser);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (rcode) {
|
if (rcode) {
|
||||||
goto FailGetConfDescr;
|
goto FailGetConfDescr;
|
||||||
}
|
}
|
||||||
|
@ -176,27 +181,27 @@ uint8_t ADK::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Set Configuration Value
|
// Set Configuration Value
|
||||||
rcode = pUsb->setConf(bAddress, 0, bConfNum);
|
rcode = pUsb->setConf(bAddress, 0, bConfNum);
|
||||||
if (rcode) {
|
if (rcode) {
|
||||||
goto FailSetConfDescr;
|
goto FailSetConfDescr;
|
||||||
}
|
}
|
||||||
/* print endpoint structure */
|
/* print endpoint structure */
|
||||||
// USBTRACE("\r\nEndpoint Structure:");
|
/*
|
||||||
// USBTRACE("\r\nEP0:");
|
USBTRACE("\r\nEndpoint Structure:");
|
||||||
// USBTRACE2("\r\nAddr: ", epInfo[0].epAddr );
|
USBTRACE("\r\nEP0:");
|
||||||
// USBTRACE2("\r\nMax.pkt.size: ", epInfo[0].maxPktSize );
|
USBTRACE2("\r\nAddr: ", epInfo[0].epAddr);
|
||||||
// USBTRACE2("\r\nAttr: ", epInfo[0].epAttribs );
|
USBTRACE2("\r\nMax.pkt.size: ", epInfo[0].maxPktSize);
|
||||||
// USBTRACE("\r\nEpout:");
|
USBTRACE2("\r\nAttr: ", epInfo[0].epAttribs);
|
||||||
// USBTRACE2("\r\nAddr: ", epInfo[epDataOutIndex].epAddr );
|
USBTRACE("\r\nEpout:");
|
||||||
// USBTRACE2("\r\nMax.pkt.size: ", epInfo[epDataOutIndex].maxPktSize );
|
USBTRACE2("\r\nAddr: ", epInfo[epDataOutIndex].epAddr);
|
||||||
// USBTRACE2("\r\nAttr: ", epInfo[epDataOutIndex].epAttribs );
|
USBTRACE2("\r\nMax.pkt.size: ", epInfo[epDataOutIndex].maxPktSize);
|
||||||
// USBTRACE("\r\nEpin:");
|
USBTRACE2("\r\nAttr: ", epInfo[epDataOutIndex].epAttribs);
|
||||||
// USBTRACE2("\r\nAddr: ", epInfo[epDataInIndex].epAddr );
|
USBTRACE("\r\nEpin:");
|
||||||
// USBTRACE2("\r\nMax.pkt.size: ", epInfo[epDataInIndex].maxPktSize );
|
USBTRACE2("\r\nAddr: ", epInfo[epDataInIndex].epAddr);
|
||||||
// USBTRACE2("\r\nAttr: ", epInfo[epDataInIndex].epAttribs );
|
USBTRACE2("\r\nMax.pkt.size: ", epInfo[epDataInIndex].maxPktSize);
|
||||||
|
USBTRACE2("\r\nAttr: ", epInfo[epDataInIndex].epAttribs);
|
||||||
|
*/
|
||||||
|
|
||||||
USBTRACE("\r\nConfiguration successful");
|
USBTRACE("\r\nConfiguration successful");
|
||||||
ready = true;
|
ready = true;
|
||||||
|
@ -206,7 +211,16 @@ uint8_t ADK::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
//probe device - get accessory protocol revision
|
//probe device - get accessory protocol revision
|
||||||
{
|
{
|
||||||
uint16_t adkproto = -1;
|
uint16_t adkproto = -1;
|
||||||
|
delay(1);
|
||||||
rcode = getProto((uint8_t*) & adkproto);
|
rcode = getProto((uint8_t*) & adkproto);
|
||||||
|
#if defined(XOOM)
|
||||||
|
//added by Jaylen Scott Vanorden
|
||||||
|
if (rcode) {
|
||||||
|
USBTRACE2("\r\nGot 1st bad code for proto: ", rcode);
|
||||||
|
// Try once more
|
||||||
|
rcode = getProto((uint8_t*) & adkproto);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (rcode) {
|
if (rcode) {
|
||||||
goto FailGetProto; //init fails
|
goto FailGetProto; //init fails
|
||||||
}
|
}
|
||||||
|
@ -275,7 +289,6 @@ SwAttempt:
|
||||||
//FailOnInit:
|
//FailOnInit:
|
||||||
// USBTRACE("OnInit:");
|
// USBTRACE("OnInit:");
|
||||||
// goto Fail;
|
// goto Fail;
|
||||||
//
|
|
||||||
Fail:
|
Fail:
|
||||||
//USBTRACE2("\r\nADK Init Failed, error code: ", rcode);
|
//USBTRACE2("\r\nADK Init Failed, error code: ", rcode);
|
||||||
//NotifyFail(rcode);
|
//NotifyFail(rcode);
|
||||||
|
|
4
adk.h
4
adk.h
|
@ -26,6 +26,10 @@ e-mail : support@circuitsathome.com
|
||||||
#define ADK_PID 0x2D00
|
#define ADK_PID 0x2D00
|
||||||
#define ADB_PID 0x2D01
|
#define ADB_PID 0x2D01
|
||||||
|
|
||||||
|
#define XOOM //enables repeating getProto() and getConf() attempts
|
||||||
|
//necessary for slow devices such as Motorola XOOM
|
||||||
|
//defined by default, can be commented out to save memory
|
||||||
|
|
||||||
/* requests */
|
/* requests */
|
||||||
|
|
||||||
#define ADK_GETPROTO 51 //check USB accessory protocol version
|
#define ADK_GETPROTO 51 //check USB accessory protocol version
|
||||||
|
|
Loading…
Reference in a new issue