Dependencies:   MAX44000 PWM_Tone_Library nexpaq_mdk

Fork of LED_Demo by Maxim nexpaq

Committer:
cyberjoey
Date:
Sat Oct 22 01:31:58 2016 +0000
Revision:
9:6bb35cef007d
Parent:
1:55a6170b404f
WORKING

Who changed what in which revision?

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