ADC Niose test Connect four analog signals to your MBED. and then run the Windows app. The four traces are displayed on an oscilloscope like display. I have used a USB HID DEVICE link, so connections to D+, D- are required. The MBED code is otherwise quite basic, So you can modify it to your own test needs. Additionaly, there is a 16 bit count value, in my MBED code Mainly to test if MSB & LSB are correct.
USBHID.h
00001 /* USBHID.h */ 00002 /* Human Interface Device (HID) class */ 00003 /* Copyright (c) 2011 ARM Limited. All rights reserved. */ 00004 00005 #ifndef USB_HID_H 00006 #define USB_HID_H 00007 00008 /* These headers are included for child class. */ 00009 #include "USBEndpoints.h" 00010 #include "USBDescriptor.h" 00011 #include "USBDevice_Types.h" 00012 00013 #include "USBHID_Types.h" 00014 #include "USBDevice.h" 00015 00016 00017 /** 00018 * USBHID example 00019 * @code 00020 * #include "mbed.h" 00021 * #include "USBHID.h" 00022 * 00023 * USBHID hid; 00024 * HID_REPORT recv; 00025 * BusOut leds(LED1,LED2,LED3,LED4); 00026 * 00027 * int main(void) { 00028 * while (1) { 00029 * hid.read(&recv); 00030 * leds = recv.data[0]; 00031 * } 00032 * } 00033 * @endcode 00034 */ 00035 00036 class USBHID: public USBDevice { 00037 public: 00038 00039 /** 00040 * Constructor 00041 * 00042 * @param output_report_length Maximum length of a sent report (up to 64 bytes) (default: 64 bytes) 00043 * @param input_report_length Maximum length of a received report (up to 64 bytes) (default: 64 bytes) 00044 * @param vendor_id Your vendor_id 00045 * @param product_id Your product_id 00046 * @param product_release Your preoduct_release 00047 */ 00048 USBHID(uint8_t output_report_length = 64, uint8_t input_report_length = 64, uint16_t vendor_id = 0x1234, uint16_t product_id = 0x0006, uint16_t product_release = 0x0001); 00049 00050 00051 /** 00052 * Send a Report 00053 * 00054 * @param report Report which will be sent (a report is defined by all data and the length) 00055 * @returns true if successful 00056 */ 00057 bool send(HID_REPORT *report); 00058 00059 /** 00060 * Read a report. Warning: blocking 00061 * 00062 * @param report pointer to the report to fill 00063 * @returns true if successful 00064 */ 00065 bool read(HID_REPORT * report); 00066 00067 /** 00068 * Read a report. Warning: non blocking 00069 * 00070 * @param report pointer to the report to fill 00071 * @returns true if successful 00072 */ 00073 bool readNB(HID_REPORT * report); 00074 00075 /** 00076 * Get the Report descriptor 00077 * 00078 * @returns pointer to the report descriptor 00079 */ 00080 virtual uint8_t * reportDesc(); 00081 00082 /** 00083 * Get the length of the report descriptor 00084 * 00085 * @returns the length of the report descriptor 00086 */ 00087 virtual uint16_t reportDescLength(); 00088 00089 /** 00090 * Get string product descriptor 00091 * 00092 * @returns pointer to the string product descriptor 00093 */ 00094 virtual uint8_t * stringIproductDesc(); 00095 00096 /** 00097 * Get string interface descriptor 00098 * 00099 * @returns pointer to the string interface descriptor 00100 */ 00101 virtual uint8_t * stringIinterfaceDesc(); 00102 00103 /** 00104 * Get configuration descriptor 00105 * 00106 * @returns pointer to the configuration descriptor 00107 */ 00108 virtual uint8_t * configurationDesc(); 00109 00110 00111 /** 00112 * HID Report received by SET_REPORT request. Warning: Called in ISR context 00113 * First byte of data will be the report ID 00114 * 00115 * @param report Data and length received 00116 */ 00117 virtual void HID_callbackSetReport(HID_REPORT *report){}; 00118 00119 00120 /** 00121 * Called by USBDevice on Endpoint0 request. Warning: Called in ISR context 00122 * This is used to handle extensions to standard requests 00123 * and class specific requests 00124 * 00125 * @returns true if class handles this request 00126 */ 00127 virtual bool USBCallback_request(); 00128 00129 /** 00130 * Called by USBDevice on Endpoint0 request completion 00131 * if the 'notify' flag has been set to true. Warning: Called in ISR context 00132 * 00133 * In this case it is used to indicate that a HID report has 00134 * been received from the host on endpoint 0 00135 */ 00136 virtual void USBCallback_requestCompleted(); 00137 00138 /** 00139 * Called by USBDevice layer. Set configuration of the device. 00140 * For instance, you can add all endpoints that you need on this function. 00141 * 00142 * @param configuration Number of the configuration 00143 * @returns true if class handles this request 00144 */ 00145 virtual bool USBCallback_setConfiguration(uint8_t configuration); 00146 00147 00148 00149 protected: 00150 uint16_t reportLength; 00151 00152 private: 00153 HID_REPORT outputReport; 00154 uint8_t output_length; 00155 uint8_t input_length; 00156 }; 00157 00158 #endif
Generated on Tue Jul 12 2022 20:27:20 by 1.7.2