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