Changes to support Vodafone K4606
Fork of USBHostWANDongle by
Embed:
(wiki syntax)
Show/hide line numbers
WANDongleSerialPort.h
00001 /* Copyright (c) 2010-2012 mbed.org, MIT License 00002 * 00003 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 00004 * and associated documentation files (the "Software"), to deal in the Software without 00005 * restriction, including without limitation the rights to use, copy, modify, merge, publish, 00006 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the 00007 * Software is furnished to do so, subject to the following conditions: 00008 * 00009 * The above copyright notice and this permission notice shall be included in all copies or 00010 * substantial portions of the Software. 00011 * 00012 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 00013 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00014 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 00015 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00016 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00017 */ 00018 00019 #ifndef WANDONGLESERIALPORT_H 00020 #define WANDONGLESERIALPORT_H 00021 00022 #include "USBHost.h" 00023 #include "IUSBHostSerial.h" 00024 00025 #include "rtos.h" 00026 00027 00028 #define WANDONGLE_MAX_OUTEP_SIZE 64 00029 #define WANDONGLE_MAX_INEP_SIZE 64 00030 00031 /** A class to use a WAN (3G/LTE) access dongle 00032 * 00033 */ 00034 class WANDongleSerialPort : public IUSBHostSerial { 00035 public: 00036 /* 00037 * Constructor 00038 * 00039 */ 00040 WANDongleSerialPort(); 00041 00042 void init( USBHost* pHost ); 00043 00044 void connect( USBDeviceConnected* pDev, USBEndpoint* pInEp, USBEndpoint* pOutEp ); 00045 00046 void disconnect( ); 00047 00048 /* 00049 * Get a char from the dongle's serial interface 00050 */ 00051 virtual int getc(); 00052 00053 /* 00054 * Put a char to the dongle's serial interface 00055 */ 00056 virtual int putc(int c); 00057 00058 /* 00059 * Read a packet from the dongle's serial interface, to be called after multiple getc() calls 00060 */ 00061 virtual int readPacket(); 00062 00063 /* 00064 * Write a packet to the dongle's serial interface, to be called after multiple putc() calls 00065 */ 00066 virtual int writePacket(); 00067 00068 /** 00069 * Check the number of bytes available. 00070 * 00071 * @returns the number of bytes available 00072 */ 00073 virtual int readable(); 00074 00075 /** 00076 * Check the free space in output. 00077 * 00078 * @returns the number of bytes available 00079 */ 00080 virtual int writeable(); 00081 00082 /** 00083 * Attach a handler to call when a packet is received / when a packet has been transmitted. 00084 * 00085 * @param pListener instance of the listener deriving from the IUSBHostSerialListener 00086 */ 00087 virtual void attach(IUSBHostSerialListener* pListener); 00088 00089 /** 00090 * Enable or disable readable/writeable callbacks 00091 */ 00092 virtual void setupIrq(bool en, IrqType irq = RxIrq); 00093 00094 00095 protected: 00096 USBEndpoint * bulk_in; 00097 USBEndpoint * bulk_out; 00098 USBHost * host; 00099 USBDeviceConnected * dev; 00100 00101 uint8_t buf_out[WANDONGLE_MAX_OUTEP_SIZE]; 00102 volatile uint32_t buf_out_len; 00103 uint32_t max_out_size; 00104 volatile bool lock_tx; 00105 volatile bool cb_tx_en; 00106 volatile bool cb_tx_pending; 00107 Mutex tx_mtx; 00108 00109 uint8_t buf_in[WANDONGLE_MAX_INEP_SIZE]; 00110 volatile uint32_t buf_in_len; 00111 volatile uint32_t buf_in_read_pos; 00112 volatile bool lock_rx; 00113 volatile bool cb_rx_en; 00114 volatile bool cb_rx_pending; 00115 Mutex rx_mtx; 00116 00117 IUSBHostSerialListener* listener; 00118 00119 void reset(); 00120 00121 void rxHandler(); 00122 void txHandler(); 00123 00124 }; 00125 00126 #endif
Generated on Thu Jul 14 2022 09:11:27 by 1.7.2