USBMSD SD card Hello World for Mbed platforms

Dependencies:   mbed USBMSD_SD USBDevice

Committer:
samux
Date:
Tue Dec 06 12:07:12 2011 +0000
Revision:
14:757226626acb
protection enabled when usb cable plugged. filesystem has no access when plugged

Who changed what in which revision?

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