,,

Fork of Application by Daniel Sygut

Committer:
Zaitsev
Date:
Thu Feb 15 14:29:23 2018 +0000
Revision:
15:2a20c3d2616e
Parent:
10:41552d038a69
j

Who changed what in which revision?

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