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

Dependencies:   mbed

Committer:
abe00makoto
Date:
Thu May 26 19:08:55 2011 +0000
Revision:
2:a05c7cbe396f
Parent:
1:371cbed7a29b
Child:
3:432e5675d240
read/write test ok

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