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