![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Usb Device Interface, protocol, and programming homework #4 Audio Control device
Dependencies: C12832_lcd USBDevice mbed
USBAudioControl.cpp@0:69eb9d19fb91, 2013-07-30 (annotated)
- Committer:
- jakowisp
- Date:
- Tue Jul 30 22:35:10 2013 +0000
- Revision:
- 0:69eb9d19fb91
- Child:
- 1:948ffad3284f
AudioControl Finctional
;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jakowisp | 0:69eb9d19fb91 | 1 | #include "stdint.h" |
jakowisp | 0:69eb9d19fb91 | 2 | #include "USBAudioControl.h" |
jakowisp | 0:69eb9d19fb91 | 3 | |
jakowisp | 0:69eb9d19fb91 | 4 | void USBAudioControl::suspendStateChanged(unsigned int suspend){ |
jakowisp | 0:69eb9d19fb91 | 5 | if(callbackSuspendChange!=NULL) |
jakowisp | 0:69eb9d19fb91 | 6 | (*callbackSuspendChange)(suspend); |
jakowisp | 0:69eb9d19fb91 | 7 | } |
jakowisp | 0:69eb9d19fb91 | 8 | |
jakowisp | 0:69eb9d19fb91 | 9 | unsigned int USBAudioControl::getConnectState(){ |
jakowisp | 0:69eb9d19fb91 | 10 | if (device.state != CONFIGURED) |
jakowisp | 0:69eb9d19fb91 | 11 | return 0; |
jakowisp | 0:69eb9d19fb91 | 12 | return 1; |
jakowisp | 0:69eb9d19fb91 | 13 | } |
jakowisp | 0:69eb9d19fb91 | 14 | |
jakowisp | 0:69eb9d19fb91 | 15 | uint8_t * USBAudioControl::reportDesc() { |
jakowisp | 0:69eb9d19fb91 | 16 | static uint8_t reportDescriptor[] = { |
jakowisp | 0:69eb9d19fb91 | 17 | USAGE_PAGE(2), 0x0c,0x00, // Consumer |
jakowisp | 0:69eb9d19fb91 | 18 | USAGE(1), 0x01, // Remote Control |
jakowisp | 0:69eb9d19fb91 | 19 | COLLECTION(1), 0x01, // Application |
jakowisp | 0:69eb9d19fb91 | 20 | LOGICAL_MINIMUM(1), 0x00, |
jakowisp | 0:69eb9d19fb91 | 21 | LOGICAL_MAXIMUM(1), 0x01, |
jakowisp | 0:69eb9d19fb91 | 22 | |
jakowisp | 0:69eb9d19fb91 | 23 | USAGE(2), 0xe9,0x00, // Vol+ |
jakowisp | 0:69eb9d19fb91 | 24 | USAGE(2), 0xea,0x00, // Vol- |
jakowisp | 0:69eb9d19fb91 | 25 | USAGE(2), 0xb5,0x00, // NextTrack |
jakowisp | 0:69eb9d19fb91 | 26 | USAGE(2), 0xb6,0x00, // PrevTrack |
jakowisp | 0:69eb9d19fb91 | 27 | USAGE(2), 0xcd,0x00, // Pause/play |
jakowisp | 0:69eb9d19fb91 | 28 | REPORT_COUNT(1), 0x05, |
jakowisp | 0:69eb9d19fb91 | 29 | REPORT_SIZE(1), 0x01, |
jakowisp | 0:69eb9d19fb91 | 30 | INPUT(1), 0x02, |
jakowisp | 0:69eb9d19fb91 | 31 | REPORT_COUNT(1), 0x03, |
jakowisp | 0:69eb9d19fb91 | 32 | REPORT_SIZE(1), 0x01, |
jakowisp | 0:69eb9d19fb91 | 33 | INPUT(1), 0x01, |
jakowisp | 0:69eb9d19fb91 | 34 | LOGICAL_MINIMUM(1), 0x00, // logical minimum = 0 |
jakowisp | 0:69eb9d19fb91 | 35 | LOGICAL_MAXIMUM(2), 0xFF, 0x00, // logical maximum = 255 |
jakowisp | 0:69eb9d19fb91 | 36 | REPORT_SIZE(1), 0x08, |
jakowisp | 0:69eb9d19fb91 | 37 | REPORT_COUNT(1), 0x01, // report count |
jakowisp | 0:69eb9d19fb91 | 38 | USAGE(1), 0x02, // usage |
jakowisp | 0:69eb9d19fb91 | 39 | OUTPUT(1), 0x02, // Output (array) |
jakowisp | 0:69eb9d19fb91 | 40 | REPORT_COUNT(1), 0x01, |
jakowisp | 0:69eb9d19fb91 | 41 | USAGE(1), 0x03, |
jakowisp | 0:69eb9d19fb91 | 42 | FEATURE(2), 0x02, 0x01, |
jakowisp | 0:69eb9d19fb91 | 43 | END_COLLECTION(0), |
jakowisp | 0:69eb9d19fb91 | 44 | }; |
jakowisp | 0:69eb9d19fb91 | 45 | reportLength = sizeof(reportDescriptor); |
jakowisp | 0:69eb9d19fb91 | 46 | return reportDescriptor; |
jakowisp | 0:69eb9d19fb91 | 47 | } |
jakowisp | 0:69eb9d19fb91 | 48 | |
jakowisp | 0:69eb9d19fb91 | 49 | |
jakowisp | 0:69eb9d19fb91 | 50 |