test public

Dependencies:   HttpServer_snapshot_mbed-os

Committer:
anhtran
Date:
Fri Oct 18 03:09:43 2019 +0000
Revision:
0:e9fd5575b10e
abc

Who changed what in which revision?

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