Android Open Accessory Library化してみました。 バルク転送の使い方が分かっていないため、相変わらず動作は不安定。 I do not understand the usage of the bulk transfer. Please teach someone.

Dependencies:   mbed

Committer:
abe00makoto
Date:
Fri Jun 03 17:43:15 2011 +0000
Revision:
0:4fcfc05943ff
Android Open Accessory Library+ demokit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
abe00makoto 0:4fcfc05943ff 1
abe00makoto 0:4fcfc05943ff 2 #ifndef ADK_H_INCLUDED
abe00makoto 0:4fcfc05943ff 3 #define ADK_H_INCLUDED
abe00makoto 0:4fcfc05943ff 4
abe00makoto 0:4fcfc05943ff 5 #include "mbed.h"
abe00makoto 0:4fcfc05943ff 6 #include "USBHost.h"
abe00makoto 0:4fcfc05943ff 7
abe00makoto 0:4fcfc05943ff 8
abe00makoto 0:4fcfc05943ff 9 #define ADKLOG 1
abe00makoto 0:4fcfc05943ff 10 #if ADKLOG
abe00makoto 0:4fcfc05943ff 11 #define LOG(...) printf(__VA_ARGS__)
abe00makoto 0:4fcfc05943ff 12 #define Log(...) printf(__VA_ARGS__)
abe00makoto 0:4fcfc05943ff 13 #define log(...) printf(__VA_ARGS__)
abe00makoto 0:4fcfc05943ff 14
abe00makoto 0:4fcfc05943ff 15 #else
abe00makoto 0:4fcfc05943ff 16 #define LOG(...) do {} while(0)
abe00makoto 0:4fcfc05943ff 17 #define Log(...) do {} while(0)
abe00makoto 0:4fcfc05943ff 18 #define log(...) do {} while(0)
abe00makoto 0:4fcfc05943ff 19
abe00makoto 0:4fcfc05943ff 20 #endif
abe00makoto 0:4fcfc05943ff 21
abe00makoto 0:4fcfc05943ff 22 #define ACCESSORY_STRING_MANUFACTURER 0
abe00makoto 0:4fcfc05943ff 23 #define ACCESSORY_STRING_MODEL 1
abe00makoto 0:4fcfc05943ff 24 #define ACCESSORY_STRING_DESCRIPTION 2
abe00makoto 0:4fcfc05943ff 25 #define ACCESSORY_STRING_VERSION 3
abe00makoto 0:4fcfc05943ff 26 #define ACCESSORY_STRING_URI 4
abe00makoto 0:4fcfc05943ff 27 #define ACCESSORY_STRING_SERIAL 5
abe00makoto 0:4fcfc05943ff 28
abe00makoto 0:4fcfc05943ff 29 #define ACCESSORY_GET_PROTOCOL 51
abe00makoto 0:4fcfc05943ff 30 #define ACCESSORY_SEND_STRING 52
abe00makoto 0:4fcfc05943ff 31 #define ACCESSORY_START 53
abe00makoto 0:4fcfc05943ff 32
abe00makoto 0:4fcfc05943ff 33
abe00makoto 0:4fcfc05943ff 34 bool switchDevice(int device);
abe00makoto 0:4fcfc05943ff 35
abe00makoto 0:4fcfc05943ff 36 class AndroidAccessory {
abe00makoto 0:4fcfc05943ff 37 public:
abe00makoto 0:4fcfc05943ff 38
abe00makoto 0:4fcfc05943ff 39 AndroidAccessory(int rbuffsize,int wbuffsize,
abe00makoto 0:4fcfc05943ff 40 const char* manufacturer,
abe00makoto 0:4fcfc05943ff 41 const char *model,
abe00makoto 0:4fcfc05943ff 42 const char *description,
abe00makoto 0:4fcfc05943ff 43 const char *version,
abe00makoto 0:4fcfc05943ff 44 const char *uri,
abe00makoto 0:4fcfc05943ff 45 const char *serial
abe00makoto 0:4fcfc05943ff 46 );
abe00makoto 0:4fcfc05943ff 47 virtual void init(int device, int configuration, int interfaceNumber);
abe00makoto 0:4fcfc05943ff 48
abe00makoto 0:4fcfc05943ff 49 virtual void resetDevice()=0;
abe00makoto 0:4fcfc05943ff 50 virtual void setupDevice()=0;
abe00makoto 0:4fcfc05943ff 51 virtual int callbackRead(u8 *buff, int len)=0;
abe00makoto 0:4fcfc05943ff 52 int write(u8 *buff, int len);
abe00makoto 0:4fcfc05943ff 53 int write() {
abe00makoto 0:4fcfc05943ff 54 return write(_writebuff,_writebuffsize);
abe00makoto 0:4fcfc05943ff 55 }
abe00makoto 0:4fcfc05943ff 56 //int read(u8 *buff, int len);
abe00makoto 0:4fcfc05943ff 57
abe00makoto 0:4fcfc05943ff 58
abe00makoto 0:4fcfc05943ff 59 void adkEnd() {
abe00makoto 0:4fcfc05943ff 60 // _initok=false;
abe00makoto 0:4fcfc05943ff 61 resetDevice();
abe00makoto 0:4fcfc05943ff 62 }; //if connection close
abe00makoto 0:4fcfc05943ff 63 bool switchDevice(int device);
abe00makoto 0:4fcfc05943ff 64
abe00makoto 0:4fcfc05943ff 65 //buffer
abe00makoto 0:4fcfc05943ff 66 u8* _readbuff;
abe00makoto 0:4fcfc05943ff 67 int _readbuffsize;
abe00makoto 0:4fcfc05943ff 68 u8* _writebuff;
abe00makoto 0:4fcfc05943ff 69 int _writebuffsize;
abe00makoto 0:4fcfc05943ff 70 u8* _strbuff;//255bytes;
abe00makoto 0:4fcfc05943ff 71
abe00makoto 0:4fcfc05943ff 72 private:
abe00makoto 0:4fcfc05943ff 73
abe00makoto 0:4fcfc05943ff 74 void sendString(int device, int index, const char *str);
abe00makoto 0:4fcfc05943ff 75 int getProtocol(int device);
abe00makoto 0:4fcfc05943ff 76
abe00makoto 0:4fcfc05943ff 77 const char *manufacturer;
abe00makoto 0:4fcfc05943ff 78 const char *model;
abe00makoto 0:4fcfc05943ff 79 const char *description;
abe00makoto 0:4fcfc05943ff 80 const char *version;
abe00makoto 0:4fcfc05943ff 81 const char *uri;
abe00makoto 0:4fcfc05943ff 82 const char *serial;
abe00makoto 0:4fcfc05943ff 83
abe00makoto 0:4fcfc05943ff 84 //endpoints
abe00makoto 0:4fcfc05943ff 85 int input_ep;
abe00makoto 0:4fcfc05943ff 86 int output_ep;
abe00makoto 0:4fcfc05943ff 87
abe00makoto 0:4fcfc05943ff 88 int _device;
abe00makoto 0:4fcfc05943ff 89 int _configuration;
abe00makoto 0:4fcfc05943ff 90 int _interfaceNumber;
abe00makoto 0:4fcfc05943ff 91
abe00makoto 0:4fcfc05943ff 92 //bool _initok;
abe00makoto 0:4fcfc05943ff 93
abe00makoto 0:4fcfc05943ff 94 };
abe00makoto 0:4fcfc05943ff 95
abe00makoto 0:4fcfc05943ff 96 extern AndroidAccessory* _adk;
abe00makoto 0:4fcfc05943ff 97
abe00makoto 0:4fcfc05943ff 98
abe00makoto 0:4fcfc05943ff 99 #endif