Merge branch 'master' of github.com:felis/USB_Host_Shield_2.0

This commit is contained in:
Kristian Sloth Lauszus 2013-04-03 21:29:24 +02:00
commit 7dc1c97fe0
8 changed files with 45 additions and 16 deletions

View file

@ -28,6 +28,7 @@ bControlIface(0),
bDataIface(0), bDataIface(0),
bNumEP(1), bNumEP(1),
qNextPollTime(0), qNextPollTime(0),
ready(false),
bPollEnable(false) { bPollEnable(false) {
for (uint8_t i = 0; i < ACM_MAX_ENDPOINTS; i++) { for (uint8_t i = 0; i < ACM_MAX_ENDPOINTS; i++) {
epInfo[i].epAddr = 0; epInfo[i].epAddr = 0;
@ -173,6 +174,8 @@ uint8_t ACM::Init(uint8_t parent, uint8_t port, bool lowspeed) {
goto FailOnInit; goto FailOnInit;
USBTRACE("ACM configured\r\n"); USBTRACE("ACM configured\r\n");
ready = true;
//bPollEnable = true; //bPollEnable = true;

View file

@ -89,6 +89,16 @@ e-mail : support@circuitsathome.com
#define CDC_GET_LINE_PARMS 0x35 #define CDC_GET_LINE_PARMS 0x35
#define CDC_DIAL_DIGITS 0x36 #define CDC_DIAL_DIGITS 0x36
//Class-Specific Notification Codes
#define NETWORK_CONNECTION 0x00
#define RESPONSE_AVAILABLE 0x01
#define AUX_JACK_HOOK_STATE 0x08
#define RING_DETECT 0x09
#define SERIAL_STATE 0x20
#define CALL_STATE_CHANGE 0x28
#define LINE_STATE_CHANGE 0x29
#define CONNECTION_SPEED_CHANGE 0x2a
// CDC Functional Descriptor Structures // CDC Functional Descriptor Structures
typedef struct { typedef struct {
@ -122,6 +132,16 @@ typedef struct {
uint8_t bDataBits; // Data bits (5, 6, 7, 8 or 16) uint8_t bDataBits; // Data bits (5, 6, 7, 8 or 16)
} LINE_CODING; } LINE_CODING;
typedef struct
{
uint8_t bmRequestType; // 0xa1 for class-specific notifications
uint8_t bNotification;
uint16_t wValue;
uint16_t wIndex;
uint16_t wLength;
uint16_t bmState; //UART state bitmap for SERIAL_STATE, other notifications variable length
} CLASS_NOTIFICATION;
class ACM; class ACM;
class CDCAsyncOper { class CDCAsyncOper {
@ -149,6 +169,7 @@ protected:
uint8_t bNumEP; // total number of EP in the configuration uint8_t bNumEP; // total number of EP in the configuration
uint32_t qNextPollTime; // next poll time uint32_t qNextPollTime; // next poll time
bool bPollEnable; // poll enable flag bool bPollEnable; // poll enable flag
bool ready; //device ready indicator
EpInfo epInfo[ACM_MAX_ENDPOINTS]; EpInfo epInfo[ACM_MAX_ENDPOINTS];
@ -164,6 +185,7 @@ public:
uint8_t GetLineCoding(LINE_CODING *dataptr); uint8_t GetLineCoding(LINE_CODING *dataptr);
uint8_t SetControlLineState(uint8_t state); uint8_t SetControlLineState(uint8_t state);
uint8_t SendBreak(uint16_t duration); uint8_t SendBreak(uint16_t duration);
uint8_t GetNotif( uint16_t *bytes_rcvd, uint8_t *dataptr );
// Methods for recieving and sending data // Methods for recieving and sending data
uint8_t RcvData(uint16_t *nbytesptr, uint8_t *dataptr); uint8_t RcvData(uint16_t *nbytesptr, uint8_t *dataptr);
@ -178,6 +200,10 @@ public:
return bAddress; return bAddress;
}; };
virtual bool isReady() {
return ready;
};
// UsbConfigXtracter implementation // UsbConfigXtracter implementation
virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep);
}; };

View file

@ -63,22 +63,22 @@ void JoystickReportParser::Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t
void JoystickEvents::OnGamePadChanged(const GamePadEventData *evt) void JoystickEvents::OnGamePadChanged(const GamePadEventData *evt)
{ {
Serial.print("X: "); Serial.print("X: ");
PrintHex<uint8_t>(evt->X); PrintHex<uint8_t>(evt->X, 0x80);
Serial.print("\tY: "); Serial.print("\tY: ");
PrintHex<uint8_t>(evt->Y); PrintHex<uint8_t>(evt->Y, 0x80);
Serial.print("\tZ: "); Serial.print("\tZ: ");
PrintHex<uint8_t>(evt->Z1); PrintHex<uint8_t>(evt->Z1, 0x80);
Serial.print("\tZ: "); Serial.print("\tZ: ");
PrintHex<uint8_t>(evt->Z2); PrintHex<uint8_t>(evt->Z2, 0x80);
Serial.print("\tRz: "); Serial.print("\tRz: ");
PrintHex<uint8_t>(evt->Rz); PrintHex<uint8_t>(evt->Rz, 0x80);
Serial.println(""); Serial.println("");
} }
void JoystickEvents::OnHatSwitch(uint8_t hat) void JoystickEvents::OnHatSwitch(uint8_t hat)
{ {
Serial.print("Hat Switch: "); Serial.print("Hat Switch: ");
PrintHex<uint8_t>(hat); PrintHex<uint8_t>(hat, 0x80);
Serial.println(""); Serial.println("");
} }
@ -92,4 +92,4 @@ void JoystickEvents::OnButtonDn(uint8_t but_id)
{ {
Serial.print("Dn: "); Serial.print("Dn: ");
Serial.println(but_id, DEC); Serial.println(but_id, DEC);
} }

View file

@ -51,4 +51,4 @@ public:
virtual void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf); virtual void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf);
}; };
#endif // __HIDJOYSTICKRPTPARSER_H__ #endif // __HIDJOYSTICKRPTPARSER_H__

View file

@ -26,18 +26,18 @@ void JoystickReportParser::Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t
void JoystickEvents::OnGamePadChanged(const GamePadEventData *evt) void JoystickEvents::OnGamePadChanged(const GamePadEventData *evt)
{ {
Serial.print("X: "); Serial.print("X: ");
PrintHex<uint16_t>(evt->x); PrintHex<uint16_t>(evt->x, 0x80);
Serial.print(" Y: "); Serial.print(" Y: ");
PrintHex<uint16_t>(evt->y); PrintHex<uint16_t>(evt->y, 0x80);
Serial.print(" Hat Switch: "); Serial.print(" Hat Switch: ");
PrintHex<uint8_t>(evt->hat); PrintHex<uint8_t>(evt->hat, 0x80);
Serial.print(" Twist: "); Serial.print(" Twist: ");
PrintHex<uint8_t>(evt->twist); PrintHex<uint8_t>(evt->twist, 0x80);
Serial.print(" Slider: "); Serial.print(" Slider: ");
PrintHex<uint8_t>(evt->slider); PrintHex<uint8_t>(evt->slider, 0x80);
Serial.print(" Buttons A: "); Serial.print(" Buttons A: ");
PrintHex<uint8_t>(evt->buttons_a); PrintHex<uint8_t>(evt->buttons_a, 0x80);
Serial.print(" Buttons B: "); Serial.print(" Buttons B: ");
PrintHex<uint8_t>(evt->buttons_b); PrintHex<uint8_t>(evt->buttons_b, 0x80);
Serial.println(""); Serial.println("");
} }

View file

@ -57,4 +57,4 @@ public:
virtual void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf); virtual void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf);
}; };
#endif // __HIDJOYSTICKRPTPARSER_H__ #endif // __HIDJOYSTICKRPTPARSER_H__