Pierre Provent / USBHost

Dependents:   TEST_USB_Nucleo_F429ZI Essais_USB_Nucleo_F429ZI SID_V3_Nucleo_F429ZI SID_V4_Nucleo_F429ZI_copy

Committer:
pierreprovent
Date:
Fri Sep 25 10:17:49 2020 +0000
Revision:
0:77ca32e8e04e
Programme acquisition en enregistrement sur clef USB carte Nucleo F429ZI cours ELE118 Cnam

Who changed what in which revision?

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