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.
USBKeyboard.h
00001 /* USBKeyboard.h */ 00002 /* USB device example: Standard keyboard */ 00003 /* Copyright (c) 2011 ARM Limited. All rights reserved. */ 00004 00005 #ifndef USBKEYBOARD_H 00006 #define USBKEYBOARD_H 00007 00008 #include "USBHID.h" 00009 #include "Stream.h" 00010 00011 00012 enum MEDIA_KEY 00013 { 00014 KEY_NEXT_TRACK, /*!< next Track Button */ 00015 KEY_PREVIOUS_TRACK, /*!< Previous track Button */ 00016 KEY_STOP, /*!< Stop Button */ 00017 KEY_PLAY_PAUSE, /*!< Play/Pause Button */ 00018 KEY_MUTE, /*!< Mute Button */ 00019 KEY_VOLUME_UP, /*!< Volume Up Button */ 00020 KEY_VOLUME_DOWN, /*!< Volume Down Button */ 00021 }; 00022 00023 enum FUNCTION_KEY 00024 { 00025 KEY_F1 = 128, /* F1 key */ 00026 KEY_F2, /* F2 key */ 00027 KEY_F3, /* F3 key */ 00028 KEY_F4, /* F4 key */ 00029 KEY_F5, /* F5 key */ 00030 KEY_F6, /* F6 key */ 00031 KEY_F7, /* F7 key */ 00032 KEY_F8, /* F8 key */ 00033 KEY_F9, /* F9 key */ 00034 KEY_F10, /* F10 key */ 00035 KEY_F11, /* F11 key */ 00036 KEY_F12, /* F12 key */ 00037 KEY_PRINT_SCREEN, /* Print Screen key */ 00038 KEY_INSERT, /* Insert key */ 00039 KEY_HOME, /* Home key */ 00040 KEY_PAGE_UP, /* Page Up key */ 00041 KEY_PAGE_DOWN, /* Page Down key */ 00042 }; 00043 00044 /** USB device: a keyboard 00045 * 00046 * Warning: you can only instantiate one instance of a USB device: USBMouse, USBKeyboard, USBAbsMouse, USBMouseKeyboard, or USBAbsMouseKeyboard. 00047 * 00048 * Example: 00049 * @code 00050 * 00051 * #include "mbed.h" 00052 * #include "USBKeyboard.h" 00053 * 00054 * USBKeyboard key; 00055 * 00056 * int main(void) 00057 * { 00058 * while (1) 00059 * { 00060 * key.puts("Hello World\r\n"); 00061 * wait(1); 00062 * } 00063 * } 00064 * 00065 * @endcode 00066 */ 00067 class USBKeyboard: public USBHID, public Stream 00068 { 00069 public: 00070 00071 /** 00072 * Constructor 00073 * 00074 * @param vendor_id Your vendor_id (default: 0x1234) 00075 * @param product_id Your product_id (default: 0x0001) 00076 * @param product_release Your preoduct_release (default: 0x0001) 00077 * 00078 */ 00079 USBKeyboard(uint16_t vendor_id = 0x1234, uint16_t product_id = 0x0003, uint16_t product_release = 0x0001): USBHID(vendor_id, product_id, product_release){}; 00080 00081 /** 00082 * To send a character defined by a modifier(CTRL, SHIFT, ALT) and the key 00083 * 00084 * @code 00085 * //To send CTRL + s (save) 00086 * keyboard.keyCode('s', KEY_CTRL); 00087 * @endcode 00088 * 00089 * @param modifier bit 0: CTRL, bit 1: SHIFT, bit 2: ALT (default: 0) 00090 * @param key character to send 00091 * @returns true if there is no error, false otherwise 00092 */ 00093 bool keyCode(uint8_t key, uint8_t modifier = 0); 00094 00095 /** 00096 * Send a character 00097 * 00098 * @param c character to be sent 00099 * @returns true if there is no error, false otherwise 00100 */ 00101 virtual int _putc(int c); 00102 00103 /** 00104 * Control media keys 00105 * 00106 * @param key media key pressed (KEY_NEXT_TRACK, KEY_PREVIOUS_TRACK, KEY_STOP, KEY_PLAY_PAUSE, KEY_MUTE, KEY_VOLUME_UP, KEY_VOLUME_DOWN) 00107 * @returns true if there is no error, false otherwise 00108 */ 00109 bool mediaControl(MEDIA_KEY key); 00110 00111 /** 00112 * To define the report descriptor. Warning: this method has to store the length of the report descriptor in reportLength. 00113 * 00114 * @returns pointer to the report descriptor 00115 */ 00116 virtual uint8_t * reportDesc(); 00117 00118 private: 00119 //dummy otherwise it doesn,t compile (we must define all methods of an abstract class) 00120 virtual int _getc() { return -1;} 00121 }; 00122 00123 #endif 00124 00125
Generated on Tue Jul 12 2022 20:27:20 by 1.7.2