Usb Device Interface, protocol, and programming homework #4 Audio Control device

Dependencies:   C12832_lcd USBDevice mbed

Committer:
jakowisp
Date:
Mon Aug 05 02:02:58 2013 +0000
Revision:
3:6da430f4818a
Parent:
1:948ffad3284f
Fixed several known issues to complete the assignment

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jakowisp 0:69eb9d19fb91 1 #include "stdint.h"
jakowisp 0:69eb9d19fb91 2 #include "USBAudioControl.h"
jakowisp 0:69eb9d19fb91 3
jakowisp 1:948ffad3284f 4 //Override the USBDevice suspendStateChange function to provide callback hook
jakowisp 0:69eb9d19fb91 5 void USBAudioControl::suspendStateChanged(unsigned int suspend){
jakowisp 0:69eb9d19fb91 6 if(callbackSuspendChange!=NULL)
jakowisp 0:69eb9d19fb91 7 (*callbackSuspendChange)(suspend);
jakowisp 0:69eb9d19fb91 8 }
jakowisp 0:69eb9d19fb91 9
jakowisp 1:948ffad3284f 10 //Provide a way to poll the configure state of USB device
jakowisp 0:69eb9d19fb91 11 unsigned int USBAudioControl::getConnectState(){
jakowisp 0:69eb9d19fb91 12 if (device.state != CONFIGURED)
jakowisp 0:69eb9d19fb91 13 return 0;
jakowisp 0:69eb9d19fb91 14 return 1;
jakowisp 0:69eb9d19fb91 15 }
jakowisp 0:69eb9d19fb91 16
jakowisp 1:948ffad3284f 17 //Define the report descriptor
jakowisp 0:69eb9d19fb91 18 uint8_t * USBAudioControl::reportDesc() {
jakowisp 0:69eb9d19fb91 19 static uint8_t reportDescriptor[] = {
jakowisp 0:69eb9d19fb91 20 USAGE_PAGE(2), 0x0c,0x00, // Consumer
jakowisp 0:69eb9d19fb91 21 USAGE(1), 0x01, // Remote Control
jakowisp 0:69eb9d19fb91 22 COLLECTION(1), 0x01, // Application
jakowisp 0:69eb9d19fb91 23 LOGICAL_MINIMUM(1), 0x00,
jakowisp 0:69eb9d19fb91 24 LOGICAL_MAXIMUM(1), 0x01,
jakowisp 0:69eb9d19fb91 25
jakowisp 0:69eb9d19fb91 26 USAGE(2), 0xe9,0x00, // Vol+
jakowisp 0:69eb9d19fb91 27 USAGE(2), 0xea,0x00, // Vol-
jakowisp 0:69eb9d19fb91 28 USAGE(2), 0xb5,0x00, // NextTrack
jakowisp 0:69eb9d19fb91 29 USAGE(2), 0xb6,0x00, // PrevTrack
jakowisp 0:69eb9d19fb91 30 USAGE(2), 0xcd,0x00, // Pause/play
jakowisp 0:69eb9d19fb91 31 REPORT_COUNT(1), 0x05,
jakowisp 0:69eb9d19fb91 32 REPORT_SIZE(1), 0x01,
jakowisp 0:69eb9d19fb91 33 INPUT(1), 0x02,
jakowisp 0:69eb9d19fb91 34 REPORT_COUNT(1), 0x03,
jakowisp 0:69eb9d19fb91 35 REPORT_SIZE(1), 0x01,
jakowisp 0:69eb9d19fb91 36 INPUT(1), 0x01,
jakowisp 0:69eb9d19fb91 37 LOGICAL_MINIMUM(1), 0x00, // logical minimum = 0
jakowisp 0:69eb9d19fb91 38 LOGICAL_MAXIMUM(2), 0xFF, 0x00, // logical maximum = 255
jakowisp 0:69eb9d19fb91 39 REPORT_SIZE(1), 0x08,
jakowisp 0:69eb9d19fb91 40 REPORT_COUNT(1), 0x01, // report count
jakowisp 0:69eb9d19fb91 41 USAGE(1), 0x02, // usage
jakowisp 0:69eb9d19fb91 42 OUTPUT(1), 0x02, // Output (array)
jakowisp 0:69eb9d19fb91 43 REPORT_COUNT(1), 0x01,
jakowisp 0:69eb9d19fb91 44 USAGE(1), 0x03,
jakowisp 0:69eb9d19fb91 45 FEATURE(2), 0x02, 0x01,
jakowisp 0:69eb9d19fb91 46 END_COLLECTION(0),
jakowisp 0:69eb9d19fb91 47 };
jakowisp 0:69eb9d19fb91 48 reportLength = sizeof(reportDescriptor);
jakowisp 0:69eb9d19fb91 49 return reportDescriptor;
jakowisp 0:69eb9d19fb91 50 }
jakowisp 0:69eb9d19fb91 51
jakowisp 0:69eb9d19fb91 52
jakowisp 0:69eb9d19fb91 53