RAMDisk example for the USBFileSystem

Dependencies:   mbed USBFileSystem

Fork of USBFileSystem_RAMDISK_HelloWorld by Erik -

Committer:
Sissors
Date:
Tue Jul 30 18:27:18 2013 +0000
Revision:
1:e1b0157ce547
Memory leaks -_-

Who changed what in which revision?

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