This is early stages of my project, the idea of this project is to be able to mix a guitar with windows sounds in reverse such as instrumental background music or trance music perhaps or maybe another fellow guitarist you may have downloaded from the internet. Microphone or guitar pin is p19 I would use a microphone for drums:) and that it for the moment, the code makes the mbed act as usb speaker that excepts a guitar or microphone input, but with a twist it all in reverse like a guitar reverse effects pedal but only you can mix anything you can get from the internet or any windows sound.

Dependencies:   mbed

Committer:
mbed2f
Date:
Sun Jan 08 17:28:24 2012 +0000
Revision:
0:7610d342c76e

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed2f 0:7610d342c76e 1 /* Copyright (c) 2010-2011 mbed.org, MIT License
mbed2f 0:7610d342c76e 2 *
mbed2f 0:7610d342c76e 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
mbed2f 0:7610d342c76e 4 * and associated documentation files (the "Software"), to deal in the Software without
mbed2f 0:7610d342c76e 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
mbed2f 0:7610d342c76e 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
mbed2f 0:7610d342c76e 7 * Software is furnished to do so, subject to the following conditions:
mbed2f 0:7610d342c76e 8 *
mbed2f 0:7610d342c76e 9 * The above copyright notice and this permission notice shall be included in all copies or
mbed2f 0:7610d342c76e 10 * substantial portions of the Software.
mbed2f 0:7610d342c76e 11 *
mbed2f 0:7610d342c76e 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
mbed2f 0:7610d342c76e 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
mbed2f 0:7610d342c76e 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
mbed2f 0:7610d342c76e 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
mbed2f 0:7610d342c76e 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
mbed2f 0:7610d342c76e 17 */
mbed2f 0:7610d342c76e 18
mbed2f 0:7610d342c76e 19 #ifndef USB_HID_H
mbed2f 0:7610d342c76e 20 #define USB_HID_H
mbed2f 0:7610d342c76e 21
mbed2f 0:7610d342c76e 22 /* These headers are included for child class. */
mbed2f 0:7610d342c76e 23 #include "USBEndpoints.h"
mbed2f 0:7610d342c76e 24 #include "USBDescriptor.h"
mbed2f 0:7610d342c76e 25 #include "USBDevice_Types.h"
mbed2f 0:7610d342c76e 26
mbed2f 0:7610d342c76e 27 #include "USBHID_Types.h"
mbed2f 0:7610d342c76e 28 #include "USBDevice.h"
mbed2f 0:7610d342c76e 29
mbed2f 0:7610d342c76e 30
mbed2f 0:7610d342c76e 31 /**
mbed2f 0:7610d342c76e 32 * USBHID example
mbed2f 0:7610d342c76e 33 * @code
mbed2f 0:7610d342c76e 34 * #include "mbed.h"
mbed2f 0:7610d342c76e 35 * #include "USBHID.h"
mbed2f 0:7610d342c76e 36 *
mbed2f 0:7610d342c76e 37 * USBHID hid;
mbed2f 0:7610d342c76e 38 * HID_REPORT recv;
mbed2f 0:7610d342c76e 39 * BusOut leds(LED1,LED2,LED3,LED4);
mbed2f 0:7610d342c76e 40 *
mbed2f 0:7610d342c76e 41 * int main(void) {
mbed2f 0:7610d342c76e 42 * while (1) {
mbed2f 0:7610d342c76e 43 * hid.read(&recv);
mbed2f 0:7610d342c76e 44 * leds = recv.data[0];
mbed2f 0:7610d342c76e 45 * }
mbed2f 0:7610d342c76e 46 * }
mbed2f 0:7610d342c76e 47 * @endcode
mbed2f 0:7610d342c76e 48 */
mbed2f 0:7610d342c76e 49
mbed2f 0:7610d342c76e 50 class USBHID: public USBDevice {
mbed2f 0:7610d342c76e 51 public:
mbed2f 0:7610d342c76e 52
mbed2f 0:7610d342c76e 53 /**
mbed2f 0:7610d342c76e 54 * Constructor
mbed2f 0:7610d342c76e 55 *
mbed2f 0:7610d342c76e 56 * @param output_report_length Maximum length of a sent report (up to 64 bytes) (default: 64 bytes)
mbed2f 0:7610d342c76e 57 * @param input_report_length Maximum length of a received report (up to 64 bytes) (default: 64 bytes)
mbed2f 0:7610d342c76e 58 * @param vendor_id Your vendor_id
mbed2f 0:7610d342c76e 59 * @param product_id Your product_id
mbed2f 0:7610d342c76e 60 * @param product_release Your preoduct_release
mbed2f 0:7610d342c76e 61 * @param connect Connect the device
mbed2f 0:7610d342c76e 62 */
mbed2f 0:7610d342c76e 63 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, bool connect = true);
mbed2f 0:7610d342c76e 64
mbed2f 0:7610d342c76e 65
mbed2f 0:7610d342c76e 66 /**
mbed2f 0:7610d342c76e 67 * Send a Report. warning: blocking
mbed2f 0:7610d342c76e 68 *
mbed2f 0:7610d342c76e 69 * @param report Report which will be sent (a report is defined by all data and the length)
mbed2f 0:7610d342c76e 70 * @returns true if successful
mbed2f 0:7610d342c76e 71 */
mbed2f 0:7610d342c76e 72 bool send(HID_REPORT *report);
mbed2f 0:7610d342c76e 73
mbed2f 0:7610d342c76e 74
mbed2f 0:7610d342c76e 75 /**
mbed2f 0:7610d342c76e 76 * Send a Report. warning: non blocking
mbed2f 0:7610d342c76e 77 *
mbed2f 0:7610d342c76e 78 * @param report Report which will be sent (a report is defined by all data and the length)
mbed2f 0:7610d342c76e 79 * @returns true if successful
mbed2f 0:7610d342c76e 80 */
mbed2f 0:7610d342c76e 81 bool sendNB(HID_REPORT *report);
mbed2f 0:7610d342c76e 82
mbed2f 0:7610d342c76e 83 /**
mbed2f 0:7610d342c76e 84 * Read a report: blocking
mbed2f 0:7610d342c76e 85 *
mbed2f 0:7610d342c76e 86 * @param report pointer to the report to fill
mbed2f 0:7610d342c76e 87 * @returns true if successful
mbed2f 0:7610d342c76e 88 */
mbed2f 0:7610d342c76e 89 bool read(HID_REPORT * report);
mbed2f 0:7610d342c76e 90
mbed2f 0:7610d342c76e 91 /**
mbed2f 0:7610d342c76e 92 * Read a report: non blocking
mbed2f 0:7610d342c76e 93 *
mbed2f 0:7610d342c76e 94 * @param report pointer to the report to fill
mbed2f 0:7610d342c76e 95 * @returns true if successful
mbed2f 0:7610d342c76e 96 */
mbed2f 0:7610d342c76e 97 bool readNB(HID_REPORT * report);
mbed2f 0:7610d342c76e 98
mbed2f 0:7610d342c76e 99 protected:
mbed2f 0:7610d342c76e 100 uint16_t reportLength;
mbed2f 0:7610d342c76e 101
mbed2f 0:7610d342c76e 102 /*
mbed2f 0:7610d342c76e 103 * Get the Report descriptor
mbed2f 0:7610d342c76e 104 *
mbed2f 0:7610d342c76e 105 * @returns pointer to the report descriptor
mbed2f 0:7610d342c76e 106 */
mbed2f 0:7610d342c76e 107 virtual uint8_t * reportDesc();
mbed2f 0:7610d342c76e 108
mbed2f 0:7610d342c76e 109 /*
mbed2f 0:7610d342c76e 110 * Get the length of the report descriptor
mbed2f 0:7610d342c76e 111 *
mbed2f 0:7610d342c76e 112 * @returns the length of the report descriptor
mbed2f 0:7610d342c76e 113 */
mbed2f 0:7610d342c76e 114 virtual uint16_t reportDescLength();
mbed2f 0:7610d342c76e 115
mbed2f 0:7610d342c76e 116 /*
mbed2f 0:7610d342c76e 117 * Get string product descriptor
mbed2f 0:7610d342c76e 118 *
mbed2f 0:7610d342c76e 119 * @returns pointer to the string product descriptor
mbed2f 0:7610d342c76e 120 */
mbed2f 0:7610d342c76e 121 virtual uint8_t * stringIproductDesc();
mbed2f 0:7610d342c76e 122
mbed2f 0:7610d342c76e 123 /*
mbed2f 0:7610d342c76e 124 * Get string interface descriptor
mbed2f 0:7610d342c76e 125 *
mbed2f 0:7610d342c76e 126 * @returns pointer to the string interface descriptor
mbed2f 0:7610d342c76e 127 */
mbed2f 0:7610d342c76e 128 virtual uint8_t * stringIinterfaceDesc();
mbed2f 0:7610d342c76e 129
mbed2f 0:7610d342c76e 130 /*
mbed2f 0:7610d342c76e 131 * Get configuration descriptor
mbed2f 0:7610d342c76e 132 *
mbed2f 0:7610d342c76e 133 * @returns pointer to the configuration descriptor
mbed2f 0:7610d342c76e 134 */
mbed2f 0:7610d342c76e 135 virtual uint8_t * configurationDesc();
mbed2f 0:7610d342c76e 136
mbed2f 0:7610d342c76e 137
mbed2f 0:7610d342c76e 138 /*
mbed2f 0:7610d342c76e 139 * HID Report received by SET_REPORT request. Warning: Called in ISR context
mbed2f 0:7610d342c76e 140 * First byte of data will be the report ID
mbed2f 0:7610d342c76e 141 *
mbed2f 0:7610d342c76e 142 * @param report Data and length received
mbed2f 0:7610d342c76e 143 */
mbed2f 0:7610d342c76e 144 virtual void HID_callbackSetReport(HID_REPORT *report){};
mbed2f 0:7610d342c76e 145
mbed2f 0:7610d342c76e 146
mbed2f 0:7610d342c76e 147 /*
mbed2f 0:7610d342c76e 148 * Called by USBDevice on Endpoint0 request. Warning: Called in ISR context
mbed2f 0:7610d342c76e 149 * This is used to handle extensions to standard requests
mbed2f 0:7610d342c76e 150 * and class specific requests
mbed2f 0:7610d342c76e 151 *
mbed2f 0:7610d342c76e 152 * @returns true if class handles this request
mbed2f 0:7610d342c76e 153 */
mbed2f 0:7610d342c76e 154 virtual bool USBCallback_request();
mbed2f 0:7610d342c76e 155
mbed2f 0:7610d342c76e 156
mbed2f 0:7610d342c76e 157 /*
mbed2f 0:7610d342c76e 158 * Called by USBDevice layer. Set configuration of the device.
mbed2f 0:7610d342c76e 159 * For instance, you can add all endpoints that you need on this function.
mbed2f 0:7610d342c76e 160 *
mbed2f 0:7610d342c76e 161 * @param configuration Number of the configuration
mbed2f 0:7610d342c76e 162 * @returns true if class handles this request
mbed2f 0:7610d342c76e 163 */
mbed2f 0:7610d342c76e 164 virtual bool USBCallback_setConfiguration(uint8_t configuration);
mbed2f 0:7610d342c76e 165
mbed2f 0:7610d342c76e 166 private:
mbed2f 0:7610d342c76e 167 HID_REPORT outputReport;
mbed2f 0:7610d342c76e 168 uint8_t output_length;
mbed2f 0:7610d342c76e 169 uint8_t input_length;
mbed2f 0:7610d342c76e 170 };
mbed2f 0:7610d342c76e 171
mbed2f 0:7610d342c76e 172 #endif