USBDevice

Dependents:   QEI_X1_LCD_test3 macnica_test

Committer:
toucyy
Date:
Thu Apr 18 07:49:37 2013 +0000
Revision:
0:2d8d0b73e1ff
[mbed] converted /QEI_HelloWorld/USBDevice

Who changed what in which revision?

UserRevisionLine numberNew contents of line
toucyy 0:2d8d0b73e1ff 1 /* Copyright (c) 2010-2011 mbed.org, MIT License
toucyy 0:2d8d0b73e1ff 2 *
toucyy 0:2d8d0b73e1ff 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
toucyy 0:2d8d0b73e1ff 4 * and associated documentation files (the "Software"), to deal in the Software without
toucyy 0:2d8d0b73e1ff 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
toucyy 0:2d8d0b73e1ff 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
toucyy 0:2d8d0b73e1ff 7 * Software is furnished to do so, subject to the following conditions:
toucyy 0:2d8d0b73e1ff 8 *
toucyy 0:2d8d0b73e1ff 9 * The above copyright notice and this permission notice shall be included in all copies or
toucyy 0:2d8d0b73e1ff 10 * substantial portions of the Software.
toucyy 0:2d8d0b73e1ff 11 *
toucyy 0:2d8d0b73e1ff 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
toucyy 0:2d8d0b73e1ff 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
toucyy 0:2d8d0b73e1ff 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
toucyy 0:2d8d0b73e1ff 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
toucyy 0:2d8d0b73e1ff 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
toucyy 0:2d8d0b73e1ff 17 */
toucyy 0:2d8d0b73e1ff 18
toucyy 0:2d8d0b73e1ff 19 #ifndef USBCDC_H
toucyy 0:2d8d0b73e1ff 20 #define USBCDC_H
toucyy 0:2d8d0b73e1ff 21
toucyy 0:2d8d0b73e1ff 22 /* These headers are included for child class. */
toucyy 0:2d8d0b73e1ff 23 #include "USBEndpoints.h"
toucyy 0:2d8d0b73e1ff 24 #include "USBDescriptor.h"
toucyy 0:2d8d0b73e1ff 25 #include "USBDevice_Types.h"
toucyy 0:2d8d0b73e1ff 26
toucyy 0:2d8d0b73e1ff 27 #include "USBDevice.h"
toucyy 0:2d8d0b73e1ff 28
toucyy 0:2d8d0b73e1ff 29
toucyy 0:2d8d0b73e1ff 30
toucyy 0:2d8d0b73e1ff 31 class USBCDC: public USBDevice {
toucyy 0:2d8d0b73e1ff 32 public:
toucyy 0:2d8d0b73e1ff 33
toucyy 0:2d8d0b73e1ff 34 /*
toucyy 0:2d8d0b73e1ff 35 * Constructor
toucyy 0:2d8d0b73e1ff 36 *
toucyy 0:2d8d0b73e1ff 37 * @param vendor_id Your vendor_id
toucyy 0:2d8d0b73e1ff 38 * @param product_id Your product_id
toucyy 0:2d8d0b73e1ff 39 * @param product_release Your preoduct_release
toucyy 0:2d8d0b73e1ff 40 */
toucyy 0:2d8d0b73e1ff 41 USBCDC(uint16_t vendor_id, uint16_t product_id, uint16_t product_release);
toucyy 0:2d8d0b73e1ff 42
toucyy 0:2d8d0b73e1ff 43
toucyy 0:2d8d0b73e1ff 44 /*
toucyy 0:2d8d0b73e1ff 45 * Get device descriptor. Warning: this method has to store the length of the report descriptor in reportLength.
toucyy 0:2d8d0b73e1ff 46 *
toucyy 0:2d8d0b73e1ff 47 * @returns pointer to the device descriptor
toucyy 0:2d8d0b73e1ff 48 */
toucyy 0:2d8d0b73e1ff 49 virtual uint8_t * deviceDesc();
toucyy 0:2d8d0b73e1ff 50
toucyy 0:2d8d0b73e1ff 51 /*
toucyy 0:2d8d0b73e1ff 52 * Get string product descriptor
toucyy 0:2d8d0b73e1ff 53 *
toucyy 0:2d8d0b73e1ff 54 * @returns pointer to the string product descriptor
toucyy 0:2d8d0b73e1ff 55 */
toucyy 0:2d8d0b73e1ff 56 virtual uint8_t * stringIproductDesc();
toucyy 0:2d8d0b73e1ff 57
toucyy 0:2d8d0b73e1ff 58 /*
toucyy 0:2d8d0b73e1ff 59 * Get string interface descriptor
toucyy 0:2d8d0b73e1ff 60 *
toucyy 0:2d8d0b73e1ff 61 * @returns pointer to the string interface descriptor
toucyy 0:2d8d0b73e1ff 62 */
toucyy 0:2d8d0b73e1ff 63 virtual uint8_t * stringIinterfaceDesc();
toucyy 0:2d8d0b73e1ff 64
toucyy 0:2d8d0b73e1ff 65 /*
toucyy 0:2d8d0b73e1ff 66 * Get configuration descriptor
toucyy 0:2d8d0b73e1ff 67 *
toucyy 0:2d8d0b73e1ff 68 * @returns pointer to the configuration descriptor
toucyy 0:2d8d0b73e1ff 69 */
toucyy 0:2d8d0b73e1ff 70 virtual uint8_t * configurationDesc();
toucyy 0:2d8d0b73e1ff 71
toucyy 0:2d8d0b73e1ff 72 /*
toucyy 0:2d8d0b73e1ff 73 * Send a buffer
toucyy 0:2d8d0b73e1ff 74 *
toucyy 0:2d8d0b73e1ff 75 * @param endpoint endpoint which will be sent the buffer
toucyy 0:2d8d0b73e1ff 76 * @param buffer buffer to be sent
toucyy 0:2d8d0b73e1ff 77 * @param size length of the buffer
toucyy 0:2d8d0b73e1ff 78 * @returns true if successful
toucyy 0:2d8d0b73e1ff 79 */
toucyy 0:2d8d0b73e1ff 80 bool send(uint8_t * buffer, uint16_t size);
toucyy 0:2d8d0b73e1ff 81
toucyy 0:2d8d0b73e1ff 82 /*
toucyy 0:2d8d0b73e1ff 83 * Read a buffer from a certain endpoint. Warning: blocking
toucyy 0:2d8d0b73e1ff 84 *
toucyy 0:2d8d0b73e1ff 85 * @param endpoint endpoint to read
toucyy 0:2d8d0b73e1ff 86 * @param buffer buffer where will be stored bytes
toucyy 0:2d8d0b73e1ff 87 * @param size the number of bytes read will be stored in *size
toucyy 0:2d8d0b73e1ff 88 * @param maxSize the maximum length that can be read
toucyy 0:2d8d0b73e1ff 89 * @returns true if successful
toucyy 0:2d8d0b73e1ff 90 */
toucyy 0:2d8d0b73e1ff 91 bool readEP(uint8_t * buffer, uint16_t * size);
toucyy 0:2d8d0b73e1ff 92
toucyy 0:2d8d0b73e1ff 93 /*
toucyy 0:2d8d0b73e1ff 94 * Read a buffer from a certain endpoint. Warning: non blocking
toucyy 0:2d8d0b73e1ff 95 *
toucyy 0:2d8d0b73e1ff 96 * @param endpoint endpoint to read
toucyy 0:2d8d0b73e1ff 97 * @param buffer buffer where will be stored bytes
toucyy 0:2d8d0b73e1ff 98 * @param size the number of bytes read will be stored in *size
toucyy 0:2d8d0b73e1ff 99 * @param maxSize the maximum length that can be read
toucyy 0:2d8d0b73e1ff 100 * @returns true if successful
toucyy 0:2d8d0b73e1ff 101 */
toucyy 0:2d8d0b73e1ff 102 bool readEP_NB(uint8_t * buffer, uint16_t * size);
toucyy 0:2d8d0b73e1ff 103
toucyy 0:2d8d0b73e1ff 104 virtual bool USBCallback_request();
toucyy 0:2d8d0b73e1ff 105 virtual bool USBCallback_setConfiguration(uint8_t configuration);
toucyy 0:2d8d0b73e1ff 106
toucyy 0:2d8d0b73e1ff 107 };
toucyy 0:2d8d0b73e1ff 108
toucyy 0:2d8d0b73e1ff 109 #endif