blablabla

Dependencies:   MAG3110 MMA8451Q SLCD- TSI USBDevice mbed

Committer:
Osator
Date:
Wed Apr 16 12:20:00 2014 +0000
Revision:
0:339b7abfa147
blablabla

Who changed what in which revision?

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