SD card interface

Committer:
lharoon
Date:
Mon Oct 08 11:14:07 2012 +0000
Revision:
0:22612ae617a0
1st edition

Who changed what in which revision?

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