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