USB Host Library for Sprint Dongles

Fork of USBHostWANDongleSprint by mbed official

Committer:
donatien
Date:
Mon Dec 10 18:18:35 2012 +0000
Revision:
9:2a7b7333245f
Parent:
0:bfed5767d0a5
Merge

Who changed what in which revision?

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