Il y avait des problèmes dans la libraire...

Fork of USBDEVICE by ST

Committer:
qroche
Date:
Sun Sep 03 23:19:21 2017 +0000
Branch:
master
Revision:
5:3329e56e51d7
Parent:
1:2a3ae13b45ef
fin;

Who changed what in which revision?

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