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