From feda98924546cc91aa5dc9f2e0678d5267fab576 Mon Sep 17 00:00:00 2001 From: Oleg Mazurov Date: Wed, 3 Apr 2013 12:59:35 -0600 Subject: [PATCH 1/3] replaced old versions of cdcacm --- cdcacm.cpp | 3 +++ cdcacm.h | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/cdcacm.cpp b/cdcacm.cpp index 84b8cb99..5d797273 100644 --- a/cdcacm.cpp +++ b/cdcacm.cpp @@ -28,6 +28,7 @@ bControlIface(0), bDataIface(0), bNumEP(1), qNextPollTime(0), +ready(false), bPollEnable(false) { for (uint8_t i = 0; i < ACM_MAX_ENDPOINTS; i++) { epInfo[i].epAddr = 0; @@ -173,6 +174,8 @@ uint8_t ACM::Init(uint8_t parent, uint8_t port, bool lowspeed) { goto FailOnInit; USBTRACE("ACM configured\r\n"); + + ready = true; //bPollEnable = true; diff --git a/cdcacm.h b/cdcacm.h index 34c92b93..469d9383 100644 --- a/cdcacm.h +++ b/cdcacm.h @@ -89,6 +89,16 @@ e-mail : support@circuitsathome.com #define CDC_GET_LINE_PARMS 0x35 #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 typedef struct { @@ -122,6 +132,16 @@ typedef struct { uint8_t bDataBits; // Data bits (5, 6, 7, 8 or 16) } 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 CDCAsyncOper { @@ -149,6 +169,7 @@ protected: uint8_t bNumEP; // total number of EP in the configuration uint32_t qNextPollTime; // next poll time bool bPollEnable; // poll enable flag + bool ready; //device ready indicator EpInfo epInfo[ACM_MAX_ENDPOINTS]; @@ -164,6 +185,7 @@ public: uint8_t GetLineCoding(LINE_CODING *dataptr); uint8_t SetControlLineState(uint8_t state); uint8_t SendBreak(uint16_t duration); + uint8_t GetNotif( uint16_t *bytes_rcvd, uint8_t *dataptr ); // Methods for recieving and sending data uint8_t RcvData(uint16_t *nbytesptr, uint8_t *dataptr); @@ -178,6 +200,10 @@ public: return bAddress; }; + virtual bool isReady() { + return ready; + }; + // UsbConfigXtracter implementation virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep); }; From e1a11e9d5c028c03220f0c99817a62d037082af9 Mon Sep 17 00:00:00 2001 From: Oleg Mazurov Date: Wed, 3 Apr 2013 13:08:24 -0600 Subject: [PATCH 2/3] fixed printhex --- examples/HID/le3dp/{le3dp.pde => le3dp.ino} | 0 examples/HID/le3dp/le3dp_rptparser.cpp | 14 +++++++------- examples/HID/le3dp/le3dp_rptparser.h | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) rename examples/HID/le3dp/{le3dp.pde => le3dp.ino} (100%) diff --git a/examples/HID/le3dp/le3dp.pde b/examples/HID/le3dp/le3dp.ino similarity index 100% rename from examples/HID/le3dp/le3dp.pde rename to examples/HID/le3dp/le3dp.ino diff --git a/examples/HID/le3dp/le3dp_rptparser.cpp b/examples/HID/le3dp/le3dp_rptparser.cpp index 016f8fb7..cc4a0869 100644 --- a/examples/HID/le3dp/le3dp_rptparser.cpp +++ b/examples/HID/le3dp/le3dp_rptparser.cpp @@ -26,18 +26,18 @@ void JoystickReportParser::Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t void JoystickEvents::OnGamePadChanged(const GamePadEventData *evt) { Serial.print("X: "); - PrintHex(evt->x); + PrintHex(evt->x, 0x80); Serial.print(" Y: "); - PrintHex(evt->y); + PrintHex(evt->y, 0x80); Serial.print(" Hat Switch: "); - PrintHex(evt->hat); + PrintHex(evt->hat, 0x80); Serial.print(" Twist: "); - PrintHex(evt->twist); + PrintHex(evt->twist, 0x80); Serial.print(" Slider: "); - PrintHex(evt->slider); + PrintHex(evt->slider, 0x80); Serial.print(" Buttons A: "); - PrintHex(evt->buttons_a); + PrintHex(evt->buttons_a, 0x80); Serial.print(" Buttons B: "); - PrintHex(evt->buttons_b); + PrintHex(evt->buttons_b, 0x80); Serial.println(""); } diff --git a/examples/HID/le3dp/le3dp_rptparser.h b/examples/HID/le3dp/le3dp_rptparser.h index 36e13d5b..dfb89271 100644 --- a/examples/HID/le3dp/le3dp_rptparser.h +++ b/examples/HID/le3dp/le3dp_rptparser.h @@ -57,4 +57,4 @@ public: virtual void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf); }; -#endif // __HIDJOYSTICKRPTPARSER_H__ \ No newline at end of file +#endif // __HIDJOYSTICKRPTPARSER_H__ From 84cff61f49755e8c000bea3761ec80347b895c8f Mon Sep 17 00:00:00 2001 From: Oleg Mazurov Date: Wed, 3 Apr 2013 13:14:25 -0600 Subject: [PATCH 3/3] fixed printhex --- .../{USBHIDJoystick.pde => USBHIDJoystick.ino} | 0 .../HID/USBHIDJoystick/hidjoystickrptparser.cpp | 14 +++++++------- examples/HID/USBHIDJoystick/hidjoystickrptparser.h | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) rename examples/HID/USBHIDJoystick/{USBHIDJoystick.pde => USBHIDJoystick.ino} (100%) diff --git a/examples/HID/USBHIDJoystick/USBHIDJoystick.pde b/examples/HID/USBHIDJoystick/USBHIDJoystick.ino similarity index 100% rename from examples/HID/USBHIDJoystick/USBHIDJoystick.pde rename to examples/HID/USBHIDJoystick/USBHIDJoystick.ino diff --git a/examples/HID/USBHIDJoystick/hidjoystickrptparser.cpp b/examples/HID/USBHIDJoystick/hidjoystickrptparser.cpp index 324c2f48..78993682 100644 --- a/examples/HID/USBHIDJoystick/hidjoystickrptparser.cpp +++ b/examples/HID/USBHIDJoystick/hidjoystickrptparser.cpp @@ -63,22 +63,22 @@ void JoystickReportParser::Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t void JoystickEvents::OnGamePadChanged(const GamePadEventData *evt) { Serial.print("X: "); - PrintHex(evt->X); + PrintHex(evt->X, 0x80); Serial.print("\tY: "); - PrintHex(evt->Y); + PrintHex(evt->Y, 0x80); Serial.print("\tZ: "); - PrintHex(evt->Z1); + PrintHex(evt->Z1, 0x80); Serial.print("\tZ: "); - PrintHex(evt->Z2); + PrintHex(evt->Z2, 0x80); Serial.print("\tRz: "); - PrintHex(evt->Rz); + PrintHex(evt->Rz, 0x80); Serial.println(""); } void JoystickEvents::OnHatSwitch(uint8_t hat) { Serial.print("Hat Switch: "); - PrintHex(hat); + PrintHex(hat, 0x80); Serial.println(""); } @@ -92,4 +92,4 @@ void JoystickEvents::OnButtonDn(uint8_t but_id) { Serial.print("Dn: "); Serial.println(but_id, DEC); -} \ No newline at end of file +} diff --git a/examples/HID/USBHIDJoystick/hidjoystickrptparser.h b/examples/HID/USBHIDJoystick/hidjoystickrptparser.h index 055dbaca..c9aad9d4 100644 --- a/examples/HID/USBHIDJoystick/hidjoystickrptparser.h +++ b/examples/HID/USBHIDJoystick/hidjoystickrptparser.h @@ -51,4 +51,4 @@ public: virtual void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf); }; -#endif // __HIDJOYSTICKRPTPARSER_H__ \ No newline at end of file +#endif // __HIDJOYSTICKRPTPARSER_H__