USBHost library with fixes

Dependencies:   mbed-rtos FATFileSystem

Dependents:   mbedica

Committer:
zrussell3
Date:
Thu Dec 13 19:24:21 2018 +0000
Revision:
0:b176d95bb38f
Modified USBHost library to fix modifier input

Who changed what in which revision?

UserRevisionLine numberNew contents of line
zrussell3 0:b176d95bb38f 1 /* IUSBHostSerial.h */
zrussell3 0:b176d95bb38f 2 /* Copyright (c) 2010-2012 mbed.org, MIT License
zrussell3 0:b176d95bb38f 3 *
zrussell3 0:b176d95bb38f 4 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
zrussell3 0:b176d95bb38f 5 * and associated documentation files (the "Software"), to deal in the Software without
zrussell3 0:b176d95bb38f 6 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
zrussell3 0:b176d95bb38f 7 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
zrussell3 0:b176d95bb38f 8 * Software is furnished to do so, subject to the following conditions:
zrussell3 0:b176d95bb38f 9 *
zrussell3 0:b176d95bb38f 10 * The above copyright notice and this permission notice shall be included in all copies or
zrussell3 0:b176d95bb38f 11 * substantial portions of the Software.
zrussell3 0:b176d95bb38f 12 *
zrussell3 0:b176d95bb38f 13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
zrussell3 0:b176d95bb38f 14 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
zrussell3 0:b176d95bb38f 15 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
zrussell3 0:b176d95bb38f 16 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
zrussell3 0:b176d95bb38f 17 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
zrussell3 0:b176d95bb38f 18 */
zrussell3 0:b176d95bb38f 19
zrussell3 0:b176d95bb38f 20 #ifndef IUSBHOSTSERIAL_H_
zrussell3 0:b176d95bb38f 21 #define IUSBHOSTSERIAL_H_
zrussell3 0:b176d95bb38f 22
zrussell3 0:b176d95bb38f 23 /**
zrussell3 0:b176d95bb38f 24 * Generic interface to abstract 3G dongles' impl
zrussell3 0:b176d95bb38f 25 */
zrussell3 0:b176d95bb38f 26
zrussell3 0:b176d95bb38f 27 #include "USBHostConf.h"
zrussell3 0:b176d95bb38f 28
zrussell3 0:b176d95bb38f 29 #ifdef USBHOST_3GMODULE
zrussell3 0:b176d95bb38f 30
zrussell3 0:b176d95bb38f 31 #include "IUSBHostSerialListener.h"
zrussell3 0:b176d95bb38f 32
zrussell3 0:b176d95bb38f 33 // This is needed by some versions of GCC
zrussell3 0:b176d95bb38f 34 #undef putc
zrussell3 0:b176d95bb38f 35 #undef getc
zrussell3 0:b176d95bb38f 36
zrussell3 0:b176d95bb38f 37 class IUSBHostSerial {
zrussell3 0:b176d95bb38f 38 public:
zrussell3 0:b176d95bb38f 39
zrussell3 0:b176d95bb38f 40 enum IrqType {
zrussell3 0:b176d95bb38f 41 RxIrq,
zrussell3 0:b176d95bb38f 42 TxIrq
zrussell3 0:b176d95bb38f 43 };
zrussell3 0:b176d95bb38f 44
zrussell3 0:b176d95bb38f 45 /*
zrussell3 0:b176d95bb38f 46 * Get a char from the dongle's serial interface
zrussell3 0:b176d95bb38f 47 */
zrussell3 0:b176d95bb38f 48 virtual int getc() = 0;
zrussell3 0:b176d95bb38f 49
zrussell3 0:b176d95bb38f 50 /*
zrussell3 0:b176d95bb38f 51 * Put a char to the dongle's serial interface
zrussell3 0:b176d95bb38f 52 */
zrussell3 0:b176d95bb38f 53 virtual int putc(int c) = 0;
zrussell3 0:b176d95bb38f 54
zrussell3 0:b176d95bb38f 55 /*
zrussell3 0:b176d95bb38f 56 * Read a packet from the dongle's serial interface, to be called after multiple getc() calls
zrussell3 0:b176d95bb38f 57 */
zrussell3 0:b176d95bb38f 58 virtual int readPacket() = 0;
zrussell3 0:b176d95bb38f 59
zrussell3 0:b176d95bb38f 60 /*
zrussell3 0:b176d95bb38f 61 * Write a packet to the dongle's serial interface, to be called after multiple putc() calls
zrussell3 0:b176d95bb38f 62 */
zrussell3 0:b176d95bb38f 63 virtual int writePacket() = 0;
zrussell3 0:b176d95bb38f 64
zrussell3 0:b176d95bb38f 65 /**
zrussell3 0:b176d95bb38f 66 * Check the number of bytes available.
zrussell3 0:b176d95bb38f 67 *
zrussell3 0:b176d95bb38f 68 * @returns the number of bytes available
zrussell3 0:b176d95bb38f 69 */
zrussell3 0:b176d95bb38f 70 virtual int readable() = 0;
zrussell3 0:b176d95bb38f 71
zrussell3 0:b176d95bb38f 72 /**
zrussell3 0:b176d95bb38f 73 * Check the free space in output.
zrussell3 0:b176d95bb38f 74 *
zrussell3 0:b176d95bb38f 75 * @returns the number of bytes available
zrussell3 0:b176d95bb38f 76 */
zrussell3 0:b176d95bb38f 77 virtual int writeable() = 0;
zrussell3 0:b176d95bb38f 78
zrussell3 0:b176d95bb38f 79 /**
zrussell3 0:b176d95bb38f 80 * Attach a handler to call when a packet is received / when a packet has been transmitted.
zrussell3 0:b176d95bb38f 81 *
zrussell3 0:b176d95bb38f 82 * @param pListener instance of the listener deriving from the IUSBHostSerialListener
zrussell3 0:b176d95bb38f 83 */
zrussell3 0:b176d95bb38f 84 virtual void attach(IUSBHostSerialListener* pListener) = 0;
zrussell3 0:b176d95bb38f 85
zrussell3 0:b176d95bb38f 86 /**
zrussell3 0:b176d95bb38f 87 * Enable or disable readable/writeable callbacks
zrussell3 0:b176d95bb38f 88 */
zrussell3 0:b176d95bb38f 89 virtual void setupIrq(bool en, IrqType irq = RxIrq) = 0;
zrussell3 0:b176d95bb38f 90
zrussell3 0:b176d95bb38f 91 };
zrussell3 0:b176d95bb38f 92
zrussell3 0:b176d95bb38f 93 #endif /* USBHOST_3GMODULE */
zrussell3 0:b176d95bb38f 94
zrussell3 0:b176d95bb38f 95 #endif /* IUSBHOSTSERIAL_H_ */