Markus Pilz / Mbed 2 deprecated PS2toUSBHIDAdapter

Dependencies:   mbed

Committer:
pilzm
Date:
Sun Jun 07 15:20:11 2020 +0000
Revision:
7:7ece3804edf5
Parent:
5:61ad1a6be0fd
Link to helpfull website added

Who changed what in which revision?

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