ST/USBHOST forked to add another HID handler for raw keyboard data to get more detail not available with current handlers (all pressed keys, all releases, and periodic updates)
Dependents: C64-stm429_discovery
USBHostSerial/USBHostSerial.h@7:9dc1cb9d5e12, 2020-04-13 (annotated)
- Committer:
- davervw
- Date:
- Mon Apr 13 05:25:10 2020 +0000
- Revision:
- 7:9dc1cb9d5e12
- Parent:
- 1:ab240722d7ef
Added handler to USBHostHID/USBHostKeyboard.cpp:; void (*onKeyData)(uint8_t len, uint8_t* data);; so can get raw keyboard data for all keys simultaneously pressed, and all releases and periodic data
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 1 | /* mbed USBHost Library |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 2 | * Copyright (c) 2006-2013 ARM Limited |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 3 | * |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 5 | * you may not use this file except in compliance with the License. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 6 | * You may obtain a copy of the License at |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 7 | * |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 9 | * |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 10 | * Unless required by applicable law or agreed to in writing, software |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 13 | * See the License for the specific language governing permissions and |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 14 | * limitations under the License. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 15 | */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 16 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 17 | #ifndef USBHOSTSERIAL_H |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 18 | #define USBHOSTSERIAL_H |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 19 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 20 | #include "USBHostConf.h" |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 21 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 22 | #if USBHOST_SERIAL |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 23 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 24 | #include "USBHost.h" |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 25 | #include "Stream.h" |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 26 | #include "MtxCircBuffer.h" |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 27 | #include "Callback.h" |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 28 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 29 | /** |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 30 | * A class to communicate a USB virtual serial port |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 31 | */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 32 | class USBHostSerialPort : public Stream { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 33 | public: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 34 | /** |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 35 | * Constructor |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 36 | */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 37 | USBHostSerialPort(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 38 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 39 | enum IrqType { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 40 | RxIrq, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 41 | TxIrq |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 42 | }; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 43 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 44 | enum Parity { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 45 | None = 0, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 46 | Odd, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 47 | Even, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 48 | Mark, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 49 | Space |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 50 | }; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 51 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 52 | void connect(USBHost* _host, USBDeviceConnected * _dev, |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 53 | uint8_t _serial_intf, USBEndpoint* _bulk_in, USBEndpoint* _bulk_out); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 54 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 55 | /** |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 56 | * Check the number of bytes available. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 57 | * |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 58 | * @returns the number of bytes available |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 59 | */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 60 | uint8_t available(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 61 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 62 | /** |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 63 | * Attach a member function to call when a packet is received. |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 64 | * |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 65 | * @param tptr pointer to the object to call the member function on |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 66 | * @param mptr pointer to the member function to be called |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 67 | * @param irq irq type |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 68 | */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 69 | template<typename T> |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 70 | inline void attach(T* tptr, void (T::*mptr)(void), IrqType irq = RxIrq) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 71 | if ((mptr != NULL) && (tptr != NULL)) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 72 | if (irq == RxIrq) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 73 | rx.attach(tptr, mptr); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 74 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 75 | tx.attach(tptr, mptr); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 76 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 77 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 78 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 79 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 80 | /** |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 81 | * Attach a callback called when a packet is received |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 82 | * |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 83 | * @param ptr function pointer |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 84 | */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 85 | inline void attach(void (*fn)(void), IrqType irq = RxIrq) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 86 | if (fn != NULL) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 87 | if (irq == RxIrq) { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 88 | rx.attach(fn); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 89 | } else { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 90 | tx.attach(fn); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 91 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 92 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 93 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 94 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 95 | /** Set the baud rate of the serial port |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 96 | * |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 97 | * @param baudrate The baudrate of the serial port (default = 9600). |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 98 | */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 99 | void baud(int baudrate = 9600); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 100 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 101 | /** Set the transmission format used by the Serial port |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 102 | * |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 103 | * @param bits The number of bits in a word (default = 8) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 104 | * @param parity The parity used (USBHostSerialPort::None, USBHostSerialPort::Odd, USBHostSerialPort::Even, USBHostSerialPort::Mark, USBHostSerialPort::Space; default = USBHostSerialPort::None) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 105 | * @param stop The number of stop bits (1 or 2; default = 1) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 106 | */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 107 | void format(int bits = 8, Parity parity = USBHostSerialPort::None, int stop_bits = 1); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 108 | virtual int writeBuf(const char* b, int s); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 109 | virtual int readBuf(char* b, int s); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 110 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 111 | protected: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 112 | virtual int _getc(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 113 | virtual int _putc(int c); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 114 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 115 | private: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 116 | USBHost * host; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 117 | USBDeviceConnected * dev; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 118 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 119 | USBEndpoint * bulk_in; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 120 | USBEndpoint * bulk_out; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 121 | uint32_t size_bulk_in; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 122 | uint32_t size_bulk_out; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 123 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 124 | void init(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 125 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 126 | MtxCircBuffer<uint8_t, 128> circ_buf; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 127 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 128 | uint8_t buf[64]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 129 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 130 | typedef struct { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 131 | uint32_t baudrate; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 132 | uint8_t stop_bits; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 133 | uint8_t parity; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 134 | uint8_t data_bits; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 135 | } PACKED LINE_CODING; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 136 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 137 | LINE_CODING line_coding; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 138 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 139 | void rxHandler(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 140 | void txHandler(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 141 | Callback<void()> rx; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 142 | Callback<void()> tx; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 143 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 144 | uint8_t serial_intf; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 145 | }; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 146 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 147 | #if (USBHOST_SERIAL <= 1) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 148 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 149 | class USBHostSerial : public IUSBEnumerator, public USBHostSerialPort |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 150 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 151 | public: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 152 | USBHostSerial(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 153 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 154 | /** |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 155 | * Try to connect a serial device |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 156 | * |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 157 | * @return true if connection was successful |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 158 | */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 159 | bool connect(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 160 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 161 | void disconnect(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 162 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 163 | /** |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 164 | * Check if a any serial port is connected |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 165 | * |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 166 | * @returns true if a serial device is connected |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 167 | */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 168 | bool connected(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 169 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 170 | protected: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 171 | USBHost* host; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 172 | USBDeviceConnected* dev; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 173 | uint8_t port_intf; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 174 | int ports_found; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 175 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 176 | //From IUSBEnumerator |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 177 | virtual void setVidPid(uint16_t vid, uint16_t pid); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 178 | virtual bool parseInterface(uint8_t intf_nb, uint8_t intf_class, uint8_t intf_subclass, uint8_t intf_protocol); //Must return true if the interface should be parsed |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 179 | virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 180 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 181 | private: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 182 | bool dev_connected; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 183 | }; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 184 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 185 | #else // (USBHOST_SERIAL > 1) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 186 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 187 | class USBHostMultiSerial : public IUSBEnumerator { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 188 | public: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 189 | USBHostMultiSerial(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 190 | virtual ~USBHostMultiSerial(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 191 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 192 | USBHostSerialPort* getPort(int port) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 193 | { |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 194 | return port < USBHOST_SERIAL ? ports[port] : NULL; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 195 | } |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 196 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 197 | /** |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 198 | * Try to connect a serial device |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 199 | * |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 200 | * @return true if connection was successful |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 201 | */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 202 | bool connect(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 203 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 204 | void disconnect(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 205 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 206 | /** |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 207 | * Check if a any serial port is connected |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 208 | * |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 209 | * @returns true if a serial device is connected |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 210 | */ |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 211 | bool connected(); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 212 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 213 | protected: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 214 | USBHost* host; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 215 | USBDeviceConnected* dev; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 216 | USBHostSerialPort* ports[USBHOST_SERIAL]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 217 | uint8_t port_intf[USBHOST_SERIAL]; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 218 | int ports_found; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 219 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 220 | //From IUSBEnumerator |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 221 | virtual void setVidPid(uint16_t vid, uint16_t pid); |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 222 | virtual bool parseInterface(uint8_t intf_nb, uint8_t intf_class, uint8_t intf_subclass, uint8_t intf_protocol); //Must return true if the interface should be parsed |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 223 | virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 224 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 225 | private: |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 226 | bool dev_connected; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 227 | }; |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 228 | #endif // (USBHOST_SERIAL <= 1) |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 229 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 230 | #endif |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 231 | |
frq08711@LMECWL0871.LME.ST.COM | 1:ab240722d7ef | 232 | #endif |