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 /* Standard descriptor types */
Sissors 1:e1b0157ce547 20 #define DEVICE_DESCRIPTOR (1)
Sissors 1:e1b0157ce547 21 #define CONFIGURATION_DESCRIPTOR (2)
Sissors 1:e1b0157ce547 22 #define STRING_DESCRIPTOR (3)
Sissors 1:e1b0157ce547 23 #define INTERFACE_DESCRIPTOR (4)
Sissors 1:e1b0157ce547 24 #define ENDPOINT_DESCRIPTOR (5)
Sissors 1:e1b0157ce547 25 #define QUALIFIER_DESCRIPTOR (6)
Sissors 1:e1b0157ce547 26
Sissors 1:e1b0157ce547 27 /* Standard descriptor lengths */
Sissors 1:e1b0157ce547 28 #define DEVICE_DESCRIPTOR_LENGTH (0x12)
Sissors 1:e1b0157ce547 29 #define CONFIGURATION_DESCRIPTOR_LENGTH (0x09)
Sissors 1:e1b0157ce547 30 #define INTERFACE_DESCRIPTOR_LENGTH (0x09)
Sissors 1:e1b0157ce547 31 #define ENDPOINT_DESCRIPTOR_LENGTH (0x07)
Sissors 1:e1b0157ce547 32
Sissors 1:e1b0157ce547 33
Sissors 1:e1b0157ce547 34 /*string offset*/
Sissors 1:e1b0157ce547 35 #define STRING_OFFSET_LANGID (0)
Sissors 1:e1b0157ce547 36 #define STRING_OFFSET_IMANUFACTURER (1)
Sissors 1:e1b0157ce547 37 #define STRING_OFFSET_IPRODUCT (2)
Sissors 1:e1b0157ce547 38 #define STRING_OFFSET_ISERIAL (3)
Sissors 1:e1b0157ce547 39 #define STRING_OFFSET_ICONFIGURATION (4)
Sissors 1:e1b0157ce547 40 #define STRING_OFFSET_IINTERFACE (5)
Sissors 1:e1b0157ce547 41
Sissors 1:e1b0157ce547 42 /* USB Specification Release Number */
Sissors 1:e1b0157ce547 43 #define USB_VERSION_2_0 (0x0200)
Sissors 1:e1b0157ce547 44
Sissors 1:e1b0157ce547 45 /* Least/Most significant byte of short integer */
Sissors 1:e1b0157ce547 46 #define LSB(n) ((n)&0xff)
Sissors 1:e1b0157ce547 47 #define MSB(n) (((n)&0xff00)>>8)
Sissors 1:e1b0157ce547 48
Sissors 1:e1b0157ce547 49 /* Convert physical endpoint number to descriptor endpoint number */
Sissors 1:e1b0157ce547 50 #define PHY_TO_DESC(endpoint) (((endpoint)>>1) | (((endpoint) & 1) ? 0x80:0))
Sissors 1:e1b0157ce547 51
Sissors 1:e1b0157ce547 52 /* bmAttributes in configuration descriptor */
Sissors 1:e1b0157ce547 53 /* C_RESERVED must always be set */
Sissors 1:e1b0157ce547 54 #define C_RESERVED (1U<<7)
Sissors 1:e1b0157ce547 55 #define C_SELF_POWERED (1U<<6)
Sissors 1:e1b0157ce547 56 #define C_REMOTE_WAKEUP (1U<<5)
Sissors 1:e1b0157ce547 57
Sissors 1:e1b0157ce547 58 /* bMaxPower in configuration descriptor */
Sissors 1:e1b0157ce547 59 #define C_POWER(mA) ((mA)/2)
Sissors 1:e1b0157ce547 60
Sissors 1:e1b0157ce547 61 /* bmAttributes in endpoint descriptor */
Sissors 1:e1b0157ce547 62 #define E_CONTROL (0x00)
Sissors 1:e1b0157ce547 63 #define E_ISOCHRONOUS (0x01)
Sissors 1:e1b0157ce547 64 #define E_BULK (0x02)
Sissors 1:e1b0157ce547 65 #define E_INTERRUPT (0x03)
Sissors 1:e1b0157ce547 66
Sissors 1:e1b0157ce547 67 /* For isochronous endpoints only: */
Sissors 1:e1b0157ce547 68 #define E_NO_SYNCHRONIZATION (0x00)
Sissors 1:e1b0157ce547 69 #define E_ASYNCHRONOUS (0x04)
Sissors 1:e1b0157ce547 70 #define E_ADAPTIVE (0x08)
Sissors 1:e1b0157ce547 71 #define E_SYNCHRONOUS (0x0C)
Sissors 1:e1b0157ce547 72 #define E_DATA (0x00)
Sissors 1:e1b0157ce547 73 #define E_FEEDBACK (0x10)
Sissors 1:e1b0157ce547 74 #define E_IMPLICIT_FEEDBACK (0x20)