XOOMの動作状況を聞き処理を変えてみました。 USBケーブルを抜いた際に処理を終了するようにしました。

Dependencies:   mbed

Committer:
abe00makoto
Date:
Fri May 27 18:51:15 2011 +0000
Revision:
3:432e5675d240
Parent:
2:a05c7cbe396f
nexus one support
maybe support add XOOM ,nexus S

Who changed what in which revision?

UserRevisionLine numberNew contents of line
abe00makoto 2:a05c7cbe396f 1 #include <stdio.h>
abe00makoto 2:a05c7cbe396f 2 #include <stdlib.h>
abe00makoto 2:a05c7cbe396f 3 #include <stdio.h>
abe00makoto 2:a05c7cbe396f 4 #include <string.h>
abe00makoto 2:a05c7cbe396f 5
abe00makoto 2:a05c7cbe396f 6 #include "USBHost.h"
abe00makoto 2:a05c7cbe396f 7 #include "Utils.h"
abe00makoto 2:a05c7cbe396f 8 #include "ps3.h"
abe00makoto 2:a05c7cbe396f 9 #include "ADK.h"
abe00makoto 2:a05c7cbe396f 10 #include "mbed.h"
abe00makoto 2:a05c7cbe396f 11
abe00makoto 2:a05c7cbe396f 12 #define ADKLOG 1
abe00makoto 2:a05c7cbe396f 13 #if ADKLOG
abe00makoto 2:a05c7cbe396f 14 #define LOG(...) printf(__VA_ARGS__)
abe00makoto 2:a05c7cbe396f 15 #define Log(...) printf(__VA_ARGS__)
abe00makoto 2:a05c7cbe396f 16 #define log(...) printf(__VA_ARGS__)
abe00makoto 2:a05c7cbe396f 17
abe00makoto 2:a05c7cbe396f 18 #else
abe00makoto 2:a05c7cbe396f 19 #define LOG(...) do {} while(0)
abe00makoto 2:a05c7cbe396f 20 #define Log(...) do {} while(0)
abe00makoto 2:a05c7cbe396f 21 #define log(...) do {} while(0)
abe00makoto 2:a05c7cbe396f 22
abe00makoto 2:a05c7cbe396f 23 #endif
abe00makoto 2:a05c7cbe396f 24
abe00makoto 2:a05c7cbe396f 25
abe00makoto 3:432e5675d240 26
abe00makoto 2:a05c7cbe396f 27 PwmOut led1(LED1);
abe00makoto 2:a05c7cbe396f 28 PwmOut led2(LED2);
abe00makoto 2:a05c7cbe396f 29 PwmOut led3(LED3);
abe00makoto 2:a05c7cbe396f 30 PwmOut led4(LED4);
abe00makoto 2:a05c7cbe396f 31
abe00makoto 2:a05c7cbe396f 32 /*
abe00makoto 2:a05c7cbe396f 33 InterruptIn sw1(p21);
abe00makoto 2:a05c7cbe396f 34 InterruptIn sw2(p22);
abe00makoto 2:a05c7cbe396f 35 InterruptIn sw3(p23);
abe00makoto 2:a05c7cbe396f 36 */
abe00makoto 2:a05c7cbe396f 37 DigitalIn sw1(p21);
abe00makoto 2:a05c7cbe396f 38 DigitalIn sw2(p22);
abe00makoto 2:a05c7cbe396f 39 DigitalIn sw3(p23);
abe00makoto 2:a05c7cbe396f 40
abe00makoto 2:a05c7cbe396f 41
abe00makoto 2:a05c7cbe396f 42 u8 readbuff[3];
abe00makoto 2:a05c7cbe396f 43 u8 writebuf[3];
abe00makoto 2:a05c7cbe396f 44 //switch data backup
abe00makoto 2:a05c7cbe396f 45 u8 sw1b,sw2b,sw3b;
abe00makoto 2:a05c7cbe396f 46
abe00makoto 2:a05c7cbe396f 47
abe00makoto 2:a05c7cbe396f 48 void AdkUSB::setup() {
abe00makoto 2:a05c7cbe396f 49 sw1.mode(PullUp);
abe00makoto 2:a05c7cbe396f 50 sw2.mode(PullUp);
abe00makoto 2:a05c7cbe396f 51 sw3.mode(PullUp);
abe00makoto 3:432e5675d240 52 sw1b=sw2b=sw3b=sw1;
abe00makoto 2:a05c7cbe396f 53 }
abe00makoto 2:a05c7cbe396f 54
abe00makoto 2:a05c7cbe396f 55 void AdkUSB::loop() {
abe00makoto 2:a05c7cbe396f 56 log("enter loop\r\n");
abe00makoto 2:a05c7cbe396f 57 u8 buf[3];
abe00makoto 2:a05c7cbe396f 58 int ret=-1;
abe00makoto 3:432e5675d240 59 //booting wait
abe00makoto 3:432e5675d240 60 //wait(10);
abe00makoto 3:432e5675d240 61 while (!this->_loopend) {
abe00makoto 2:a05c7cbe396f 62 bool w_flag=false;
abe00makoto 2:a05c7cbe396f 63 //wait_ms(4);
abe00makoto 3:432e5675d240 64
abe00makoto 2:a05c7cbe396f 65 buf[0]=0x01;
abe00makoto 2:a05c7cbe396f 66 //switch1
abe00makoto 2:a05c7cbe396f 67 if (sw1!=sw1b) {
abe00makoto 2:a05c7cbe396f 68 log("sw1=%d\r\n",sw1.read());
abe00makoto 2:a05c7cbe396f 69 buf[1]=0;
abe00makoto 2:a05c7cbe396f 70 buf[2]=!sw1;
abe00makoto 2:a05c7cbe396f 71 ret=this->write(buf,sizeof(buf));
abe00makoto 3:432e5675d240 72 //wait_ms(4);
abe00makoto 2:a05c7cbe396f 73 sw1b=sw1;
abe00makoto 2:a05c7cbe396f 74 w_flag=true;
abe00makoto 2:a05c7cbe396f 75 }
abe00makoto 2:a05c7cbe396f 76 //switch2
abe00makoto 2:a05c7cbe396f 77 if (sw2!=sw2b) {
abe00makoto 2:a05c7cbe396f 78 log("sw2=%d\r\n",sw2.read());
abe00makoto 2:a05c7cbe396f 79 buf[1]=1;
abe00makoto 2:a05c7cbe396f 80 buf[2]=!sw2;
abe00makoto 2:a05c7cbe396f 81 ret=this->write(buf,sizeof(buf));
abe00makoto 3:432e5675d240 82 //wait_ms(4);
abe00makoto 2:a05c7cbe396f 83 sw2b=sw2;
abe00makoto 2:a05c7cbe396f 84 w_flag=true;
abe00makoto 2:a05c7cbe396f 85 }
abe00makoto 2:a05c7cbe396f 86 //switch3
abe00makoto 2:a05c7cbe396f 87 if (sw3!=sw3b) {
abe00makoto 2:a05c7cbe396f 88 log("sw3=%d\r\n",sw3.read());
abe00makoto 2:a05c7cbe396f 89 buf[1]=2;
abe00makoto 2:a05c7cbe396f 90 buf[2]=!sw3;
abe00makoto 2:a05c7cbe396f 91 ret=this->write(buf,sizeof(buf));
abe00makoto 3:432e5675d240 92 //wait_ms(4);
abe00makoto 2:a05c7cbe396f 93 sw3b=sw3;
abe00makoto 2:a05c7cbe396f 94 w_flag=true;
abe00makoto 2:a05c7cbe396f 95 }
abe00makoto 2:a05c7cbe396f 96
abe00makoto 3:432e5675d240 97 if (!w_flag) {
abe00makoto 3:432e5675d240 98 buf[0]=buf[1]=buf[2]=0;
abe00makoto 3:432e5675d240 99 ret=this->write(buf,sizeof(buf));
abe00makoto 2:a05c7cbe396f 100 }
abe00makoto 2:a05c7cbe396f 101 }
abe00makoto 3:432e5675d240 102
abe00makoto 3:432e5675d240 103 //reset
abe00makoto 3:432e5675d240 104 led1=led2=led3=led4=0.0;
abe00makoto 3:432e5675d240 105 log("---------------------------------------------------------------loop end\r\n");
abe00makoto 2:a05c7cbe396f 106 }
abe00makoto 2:a05c7cbe396f 107 void AdkreadCallback(int device, int endpoint, int status, u8* buf, int len, void* userData) {
abe00makoto 2:a05c7cbe396f 108
abe00makoto 2:a05c7cbe396f 109 log("AdkreadCallback(int device=%d, int endpoint=%x, int status=%d, u8* buf=%p, int len=%d, void* userData=%p)\r\n",
abe00makoto 2:a05c7cbe396f 110 device,endpoint,status,buf,len,userData);
abe00makoto 2:a05c7cbe396f 111
abe00makoto 3:432e5675d240 112 AdkUSB* t = (AdkUSB*)userData;
abe00makoto 3:432e5675d240 113 if (status!=0) {
abe00makoto 3:432e5675d240 114 log("loop end.\r\n");
abe00makoto 3:432e5675d240 115 t->loopend();
abe00makoto 3:432e5675d240 116 return;
abe00makoto 3:432e5675d240 117 }
abe00makoto 3:432e5675d240 118
abe00makoto 2:a05c7cbe396f 119
abe00makoto 2:a05c7cbe396f 120 if (buf[0] == 0x2) {
abe00makoto 2:a05c7cbe396f 121 if (buf[1] == 0x0) {
abe00makoto 2:a05c7cbe396f 122 log("led1=%d\r\n",buf[2]);
abe00makoto 2:a05c7cbe396f 123 led1=((float)buf[2])/255.0;
abe00makoto 2:a05c7cbe396f 124 } else if (buf[1]==0x3) {
abe00makoto 2:a05c7cbe396f 125 led2=((float)buf[2])/255.0;
abe00makoto 2:a05c7cbe396f 126 } else if (buf[1]==0x6) {
abe00makoto 2:a05c7cbe396f 127 led3=((float)buf[2])/255.0;
abe00makoto 2:a05c7cbe396f 128 }
abe00makoto 2:a05c7cbe396f 129 } else if (buf[0] ==0x3) {
abe00makoto 2:a05c7cbe396f 130 if (buf[1] == 0x0) {
abe00makoto 2:a05c7cbe396f 131 led4=buf[2]? 1.0:0.0;
abe00makoto 2:a05c7cbe396f 132 }
abe00makoto 2:a05c7cbe396f 133 }
abe00makoto 2:a05c7cbe396f 134
abe00makoto 2:a05c7cbe396f 135 USBBulkTransfer(device, endpoint , buf, len, AdkreadCallback, userData);
abe00makoto 2:a05c7cbe396f 136 wait_ms(4);
abe00makoto 2:a05c7cbe396f 137
abe00makoto 2:a05c7cbe396f 138 }
abe00makoto 2:a05c7cbe396f 139
abe00makoto 2:a05c7cbe396f 140 /*
abe00makoto 2:a05c7cbe396f 141 void AdkwriteCallback(int device, int endpoint, int status, u8* buf, int len, void* userData) {
abe00makoto 2:a05c7cbe396f 142
abe00makoto 2:a05c7cbe396f 143 log("AdkwriteCallback(int device=%d, int endpoint=%x, int status=%d, u8* buf=%p, int len=%d, void* userData=%p)\r\n",
abe00makoto 2:a05c7cbe396f 144 device,endpoint,status,buf,len,userData);
abe00makoto 2:a05c7cbe396f 145
abe00makoto 2:a05c7cbe396f 146 AdkUSB* t = (AdkUSB*)userData;
abe00makoto 2:a05c7cbe396f 147
abe00makoto 2:a05c7cbe396f 148 }
abe00makoto 2:a05c7cbe396f 149 */
abe00makoto 2:a05c7cbe396f 150
abe00makoto 2:a05c7cbe396f 151
abe00makoto 2:a05c7cbe396f 152 int getProtocol(int device);
abe00makoto 2:a05c7cbe396f 153 void sendString(int device, int index, const char *str);
abe00makoto 2:a05c7cbe396f 154
abe00makoto 2:a05c7cbe396f 155 bool switchDevice(int device) {
abe00makoto 2:a05c7cbe396f 156
abe00makoto 2:a05c7cbe396f 157 if (1==getProtocol(device)) {
abe00makoto 2:a05c7cbe396f 158 log("device supports protocol 1\r\n");
abe00makoto 2:a05c7cbe396f 159
abe00makoto 2:a05c7cbe396f 160 } else {
abe00makoto 2:a05c7cbe396f 161 log("could not read device protocol version\r\n");
abe00makoto 2:a05c7cbe396f 162 return false;
abe00makoto 2:a05c7cbe396f 163 }
abe00makoto 2:a05c7cbe396f 164
abe00makoto 2:a05c7cbe396f 165
abe00makoto 2:a05c7cbe396f 166 sendString(device,ACCESSORY_STRING_MANUFACTURER,"Google, Inc.");
abe00makoto 2:a05c7cbe396f 167 sendString(device,ACCESSORY_STRING_MODEL,"DemoKit");
abe00makoto 2:a05c7cbe396f 168 sendString(device,ACCESSORY_STRING_DESCRIPTION,"DemoKit Arduino Board");
abe00makoto 2:a05c7cbe396f 169 sendString(device,ACCESSORY_STRING_VERSION,"1.0");
abe00makoto 2:a05c7cbe396f 170 sendString(device,ACCESSORY_STRING_URI,"http://www.android.com");
abe00makoto 2:a05c7cbe396f 171 sendString(device,ACCESSORY_STRING_SERIAL,"0000000012345678");
abe00makoto 2:a05c7cbe396f 172 USBControlTransfer(device,
abe00makoto 2:a05c7cbe396f 173 HOST_TO_DEVICE |REQUEST_TYPE_VENDOR|RECIPIENT_DEVICE,
abe00makoto 2:a05c7cbe396f 174 ACCESSORY_START,
abe00makoto 2:a05c7cbe396f 175 0,//value
abe00makoto 2:a05c7cbe396f 176 0, //index
abe00makoto 2:a05c7cbe396f 177 0,
abe00makoto 2:a05c7cbe396f 178 0,
abe00makoto 2:a05c7cbe396f 179 0,
abe00makoto 2:a05c7cbe396f 180 0 );
abe00makoto 2:a05c7cbe396f 181
abe00makoto 3:432e5675d240 182 wait_ms(400);
abe00makoto 2:a05c7cbe396f 183
abe00makoto 2:a05c7cbe396f 184 return true;
abe00makoto 2:a05c7cbe396f 185
abe00makoto 2:a05c7cbe396f 186 }
abe00makoto 2:a05c7cbe396f 187
abe00makoto 2:a05c7cbe396f 188
abe00makoto 2:a05c7cbe396f 189 int getProtocol(int device) {
abe00makoto 2:a05c7cbe396f 190 s16 data=-1;
abe00makoto 2:a05c7cbe396f 191 USBControlTransfer(device,
abe00makoto 2:a05c7cbe396f 192 DEVICE_TO_HOST|REQUEST_TYPE_VENDOR|RECIPIENT_DEVICE,
abe00makoto 2:a05c7cbe396f 193 ACCESSORY_GET_PROTOCOL,
abe00makoto 2:a05c7cbe396f 194 0,//value
abe00makoto 2:a05c7cbe396f 195 0, //index
abe00makoto 2:a05c7cbe396f 196 (u8*)&data,
abe00makoto 2:a05c7cbe396f 197 2,
abe00makoto 2:a05c7cbe396f 198 0,
abe00makoto 2:a05c7cbe396f 199 0 );
abe00makoto 2:a05c7cbe396f 200 //printf("return %d\r\n",data);
abe00makoto 2:a05c7cbe396f 201 return data;
abe00makoto 2:a05c7cbe396f 202
abe00makoto 2:a05c7cbe396f 203 }
abe00makoto 2:a05c7cbe396f 204
abe00makoto 2:a05c7cbe396f 205 void sendString(int device, int index, const char *str) {
abe00makoto 2:a05c7cbe396f 206
abe00makoto 2:a05c7cbe396f 207 LOG("send_string start(%d,%d,%s) %d \r\n",device,index,str,strlen(str)+1);
abe00makoto 3:432e5675d240 208 u8 buffer[255];
abe00makoto 3:432e5675d240 209 strcpy((char*)buffer,str);
abe00makoto 3:432e5675d240 210 //thankyou curryman san
abe00makoto 2:a05c7cbe396f 211 USBControlTransfer(device,
abe00makoto 3:432e5675d240 212 HOST_TO_DEVICE|REQUEST_TYPE_VENDOR|RECIPIENT_DEVICE,
abe00makoto 2:a05c7cbe396f 213 ACCESSORY_SEND_STRING,
abe00makoto 2:a05c7cbe396f 214 0,//value
abe00makoto 2:a05c7cbe396f 215 index,
abe00makoto 3:432e5675d240 216 buffer,
abe00makoto 2:a05c7cbe396f 217 strlen(str)+1
abe00makoto 2:a05c7cbe396f 218 );
abe00makoto 2:a05c7cbe396f 219
abe00makoto 2:a05c7cbe396f 220 LOG("send_string end(%d,%d,%s)\r\n",device,index,str);
abe00makoto 2:a05c7cbe396f 221
abe00makoto 2:a05c7cbe396f 222 }
abe00makoto 2:a05c7cbe396f 223
abe00makoto 2:a05c7cbe396f 224 //int USBBulkTransfer(int device, int ep, u8* data, int length, USBCallback callback, void* userData)
abe00makoto 2:a05c7cbe396f 225 int AdkUSB::read(u8 *buff, int len) {
abe00makoto 2:a05c7cbe396f 226 int ret=USBBulkTransfer(_device,input_ep|0x80,buff,len,0,0);
abe00makoto 2:a05c7cbe396f 227 log("adkUSB read ret=%d \r\n",ret);
abe00makoto 2:a05c7cbe396f 228 return ret;
abe00makoto 2:a05c7cbe396f 229 }
abe00makoto 2:a05c7cbe396f 230
abe00makoto 2:a05c7cbe396f 231 void AdkwriteCallback(int device, int endpoint, int status, u8* buf, int len, void* userData);
abe00makoto 2:a05c7cbe396f 232
abe00makoto 2:a05c7cbe396f 233 int AdkUSB::write(u8 *buff, int len) {
abe00makoto 2:a05c7cbe396f 234 log("adkUSB write ------- xxx \r\n");
abe00makoto 2:a05c7cbe396f 235 int ret=USBBulkTransfer(_device,output_ep,buff,len/*,AdkwriteCallback,this*/);
abe00makoto 2:a05c7cbe396f 236 log("ret=%d \r\n",ret);
abe00makoto 2:a05c7cbe396f 237 return ret;
abe00makoto 2:a05c7cbe396f 238 }
abe00makoto 2:a05c7cbe396f 239
abe00makoto 2:a05c7cbe396f 240 void AdkreadCallback(int device, int endpoint, int status, u8* buf, int len, void* userData);
abe00makoto 2:a05c7cbe396f 241
abe00makoto 2:a05c7cbe396f 242 AdkUSB::AdkUSB(int device, int configuration, int interfaceNumber) {
abe00makoto 3:432e5675d240 243
abe00makoto 2:a05c7cbe396f 244 log("connecting Android \r\n");
abe00makoto 2:a05c7cbe396f 245 _device = device;
abe00makoto 2:a05c7cbe396f 246 _configuration = configuration;
abe00makoto 2:a05c7cbe396f 247 _interfaceNumber = interfaceNumber;
abe00makoto 3:432e5675d240 248 //for loop()
abe00makoto 3:432e5675d240 249 _loopend=false;
abe00makoto 2:a05c7cbe396f 250 printf("device = %d configuration = %d interfaceNumber = %d\r\n", device, configuration, interfaceNumber);
abe00makoto 2:a05c7cbe396f 251 int err;
abe00makoto 2:a05c7cbe396f 252
abe00makoto 2:a05c7cbe396f 253 u8 buffer[255];
abe00makoto 2:a05c7cbe396f 254 err = GetDescriptor(_device,DESCRIPTOR_TYPE_CONFIGURATION,0,buffer,4);
abe00makoto 2:a05c7cbe396f 255
abe00makoto 2:a05c7cbe396f 256 if (err < 0) {
abe00makoto 2:a05c7cbe396f 257 log("Failed to get descriptor\r\n");
abe00makoto 2:a05c7cbe396f 258 return;
abe00makoto 2:a05c7cbe396f 259 }
abe00makoto 2:a05c7cbe396f 260
abe00makoto 2:a05c7cbe396f 261
abe00makoto 2:a05c7cbe396f 262 int len = buffer[2] | (buffer[3] << 8);
abe00makoto 2:a05c7cbe396f 263 if (len > sizeof(buffer)) {
abe00makoto 2:a05c7cbe396f 264 log("config descriptor too large\n");
abe00makoto 2:a05c7cbe396f 265 /* might want to truncate here */
abe00makoto 2:a05c7cbe396f 266 return;
abe00makoto 2:a05c7cbe396f 267 }
abe00makoto 2:a05c7cbe396f 268 err = GetDescriptor(_device,DESCRIPTOR_TYPE_CONFIGURATION,0,buffer,len);
abe00makoto 2:a05c7cbe396f 269 u8* p = buffer;
abe00makoto 2:a05c7cbe396f 270 input_ep=0;
abe00makoto 2:a05c7cbe396f 271 output_ep=0;
abe00makoto 2:a05c7cbe396f 272 EndpointDescriptor *epDesc;
abe00makoto 2:a05c7cbe396f 273 while (p<(buffer+len)) {
abe00makoto 2:a05c7cbe396f 274 u8 descLen = p[0];
abe00makoto 2:a05c7cbe396f 275 u8 descType = p[1];
abe00makoto 2:a05c7cbe396f 276 log("descLen=%d,descType=%d\r\n",descLen,descType);
abe00makoto 2:a05c7cbe396f 277 switch (descType) {
abe00makoto 2:a05c7cbe396f 278 case DESCRIPTOR_TYPE_CONFIGURATION:
abe00makoto 2:a05c7cbe396f 279 log("config desc\r\n");
abe00makoto 2:a05c7cbe396f 280 break;
abe00makoto 2:a05c7cbe396f 281 case DESCRIPTOR_TYPE_INTERFACE:
abe00makoto 2:a05c7cbe396f 282 log("interface desc\r\n");
abe00makoto 2:a05c7cbe396f 283 break;
abe00makoto 2:a05c7cbe396f 284 case DESCRIPTOR_TYPE_ENDPOINT:
abe00makoto 2:a05c7cbe396f 285 epDesc=(EndpointDescriptor*)p;
abe00makoto 2:a05c7cbe396f 286 if (!input_ep && (epDesc->bEndpointAddress& 0x80)) {
abe00makoto 2:a05c7cbe396f 287 input_ep=epDesc->bEndpointAddress& 0x7f;
abe00makoto 2:a05c7cbe396f 288 //PacketSize drop
abe00makoto 2:a05c7cbe396f 289 log("input Endpoint address=%d,wMaxPacketSize=%d,bmAttributes=%d\r\n",input_ep,epDesc->wMaxPacketSize,epDesc->bmAttributes);
abe00makoto 2:a05c7cbe396f 290
abe00makoto 2:a05c7cbe396f 291 } else if (!output_ep) {
abe00makoto 2:a05c7cbe396f 292 output_ep=epDesc->bEndpointAddress& 0x7f;
abe00makoto 2:a05c7cbe396f 293 //PacketSize drop
abe00makoto 2:a05c7cbe396f 294 log("output Endpoint address=%d,wMaxPacketSize=%d,bmAttributes=%d\r\n",input_ep,epDesc->wMaxPacketSize,epDesc->bmAttributes);
abe00makoto 2:a05c7cbe396f 295 } else {
abe00makoto 2:a05c7cbe396f 296 //other
abe00makoto 2:a05c7cbe396f 297 log("non input,output Endpoint address=%d,wMaxPacketSize=%d,bmAttributes=%d\r\n",input_ep,epDesc->wMaxPacketSize,epDesc->bmAttributes);
abe00makoto 2:a05c7cbe396f 298 }
abe00makoto 2:a05c7cbe396f 299 break;
abe00makoto 2:a05c7cbe396f 300 default:
abe00makoto 2:a05c7cbe396f 301 log("unkown desc type(%d) \r\n",descType);
abe00makoto 2:a05c7cbe396f 302 }
abe00makoto 2:a05c7cbe396f 303 p+=descLen;
abe00makoto 2:a05c7cbe396f 304 }
abe00makoto 2:a05c7cbe396f 305
abe00makoto 2:a05c7cbe396f 306 if (!(input_ep && output_ep)) {
abe00makoto 2:a05c7cbe396f 307 log("can't find accessory endpoints\r\n");
abe00makoto 2:a05c7cbe396f 308 return;
abe00makoto 2:a05c7cbe396f 309 }
abe00makoto 2:a05c7cbe396f 310
abe00makoto 2:a05c7cbe396f 311 log("SetConfiguration\r\n");
abe00makoto 2:a05c7cbe396f 312 err = SetConfiguration(device,configuration);
abe00makoto 2:a05c7cbe396f 313 if (err < 0) {
abe00makoto 2:a05c7cbe396f 314 log("SetConfiguration error\r\n");
abe00makoto 3:432e5675d240 315 return;
abe00makoto 2:a05c7cbe396f 316 }
abe00makoto 2:a05c7cbe396f 317
abe00makoto 2:a05c7cbe396f 318 log("interrupt setup\r\n");
abe00makoto 2:a05c7cbe396f 319 //interrupt setup
abe00makoto 2:a05c7cbe396f 320 int ret=USBBulkTransfer(_device,input_ep|0x80,readbuff,sizeof(readbuff),AdkreadCallback,this);
abe00makoto 2:a05c7cbe396f 321 log("ret=%d \r\n",ret);
abe00makoto 2:a05c7cbe396f 322 log("ADK Standby\r\n");
abe00makoto 2:a05c7cbe396f 323
abe00makoto 2:a05c7cbe396f 324 this->setup();
abe00makoto 2:a05c7cbe396f 325 }
abe00makoto 2:a05c7cbe396f 326