ST/USBHOST forked to add another HID handler for raw keyboard data to get more detail not available with current handlers (all pressed keys, all releases, and periodic updates)

Dependents:   C64-stm429_discovery

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers IUSBHostSerial.h Source File

IUSBHostSerial.h

00001 /* IUSBHostSerial.h */
00002 /* Copyright (c) 2010-2012 mbed.org, MIT License
00003 *
00004 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
00005 * and associated documentation files (the "Software"), to deal in the Software without
00006 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
00007 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
00008 * Software is furnished to do so, subject to the following conditions:
00009 *
00010 * The above copyright notice and this permission notice shall be included in all copies or
00011 * substantial portions of the Software.
00012 *
00013 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
00014 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00015 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
00016 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00017 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00018 */
00019 
00020 #ifndef IUSBHOSTSERIAL_H_
00021 #define IUSBHOSTSERIAL_H_
00022 
00023 /**
00024  * Generic interface to abstract 3G dongles' impl
00025  */
00026 
00027 #include "USBHostConf.h"
00028 
00029 #ifdef USBHOST_3GMODULE
00030 
00031 #include "IUSBHostSerialListener.h"
00032 
00033 // This is needed by some versions of GCC
00034 #undef putc
00035 #undef getc
00036 
00037 class IUSBHostSerial {
00038 public:
00039 
00040     enum IrqType {
00041         RxIrq,
00042         TxIrq
00043     };
00044 
00045     /*
00046     * Get a char from the dongle's serial interface
00047     */
00048     virtual int getc() = 0;
00049 
00050     /*
00051     * Put a char to the dongle's serial interface
00052     */
00053     virtual int putc(int c) = 0;
00054 
00055     /*
00056      *  Read a packet from the dongle's serial interface, to be called after multiple getc() calls
00057      */
00058     virtual int readPacket() = 0;
00059 
00060     /*
00061      *  Write a packet to the dongle's serial interface, to be called after multiple putc() calls
00062      */
00063     virtual int writePacket() = 0;
00064 
00065     /**
00066     * Check the number of bytes available.
00067     *
00068     * @returns the number of bytes available
00069     */
00070     virtual int readable() = 0;
00071 
00072     /**
00073     * Check the free space in output.
00074     *
00075     * @returns the number of bytes available
00076     */
00077     virtual int writeable() = 0;
00078 
00079     /**
00080      *  Attach a handler to call when a packet is received / when a packet has been transmitted.
00081      *
00082      *  @param pListener instance of the listener deriving from the IUSBHostSerialListener
00083      */
00084     virtual void attach(IUSBHostSerialListener* pListener) = 0;
00085 
00086     /**
00087      * Enable or disable readable/writeable callbacks
00088      */
00089     virtual void setupIrq(bool en, IrqType irq = RxIrq) = 0;
00090 
00091 };
00092 
00093 #endif /* USBHOST_3GMODULE */
00094 
00095 #endif /* IUSBHOSTSERIAL_H_ */