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