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