24 #include <avr/pgmspace.h>
31 #if defined(ARDUINO) && ARDUINO >=100
43 #define ADK_VID 0x18D1
44 #define ADK_PID 0x2D00
45 #define ADB_PID 0x2D01
49 #define ADK_GETPROTO 51 //check USB accessory protocol version
50 #define ADK_SENDSTR 52 //send identifying string
51 #define ADK_ACCSTART 53 //start device in accessory mode
53 #define bmREQ_ADK_GET USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_VENDOR|USB_SETUP_RECIPIENT_DEVICE
54 #define bmREQ_ADK_SEND USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_VENDOR|USB_SETUP_RECIPIENT_DEVICE
56 #define ACCESSORY_STRING_MANUFACTURER 0
57 #define ACCESSORY_STRING_MODEL 1
58 #define ACCESSORY_STRING_DESCRIPTION 2
59 #define ACCESSORY_STRING_VERSION 3
60 #define ACCESSORY_STRING_URI 4
61 #define ACCESSORY_STRING_SERIAL 5
63 #define ADK_MAX_ENDPOINTS 3 //endpoint 0, bulk_IN, bulk_OUT
70 const char* manufacturer;
72 const char* description;
78 uint8_t getProto(uint8_t* adkproto);
79 uint8_t sendStr(uint8_t index,
const char* str);
80 uint8_t switchAcc(
void);
102 const char* description,
108 uint8_t
RcvData(uint16_t *nbytesptr, uint8_t *dataptr);
109 uint8_t
SndData(uint16_t nbytes, uint8_t *dataptr);
113 virtual uint8_t
Init(uint8_t parent, uint8_t port,
bool lowspeed);
135 inline uint8_t ADK::getProto(uint8_t* adkproto) {
136 return(
pUsb->
ctrlReq(
bAddress, 0,
bmREQ_ADK_GET,
ADK_GETPROTO, 0, 0, 0, 2, 2, adkproto, NULL));
140 inline uint8_t ADK::sendStr(uint8_t index,
const char* str) {
141 return(
pUsb->
ctrlReq(
bAddress, 0,
bmREQ_ADK_SEND,
ADK_SENDSTR, 0, 0, index, strlen(str) + 1, strlen(str) + 1, (uint8_t*) str, NULL));
145 inline uint8_t ADK::switchAcc(
void) {
146 return(
pUsb->
ctrlReq(
bAddress, 0,
bmREQ_ADK_SEND,
ADK_ACCSTART, 0, 0, 0, 0, 0, NULL, NULL));