2018.07.26

Dependencies:   FATFileSystem3 mbed-rtos

Fork of USBHost by mbed official

Committer:
sayzyas
Date:
Thu Jul 26 00:20:32 2018 +0000
Revision:
43:1675750cca08
2018.07.26

Who changed what in which revision?

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