Changes to support Vodafone K4606

Dependents:   VodafoneUSBModem

Fork of USBHostWANDongle by mbed official

Committer:
dmitryp
Date:
Wed Jan 28 11:38:44 2015 +0000
Revision:
28:34cdecfff9f4
Parent:
10:08bce4cd973a
Added support for Vodafone K4606, for more details refer to ; http://atmega.magictale.com/2215/hacking-vodafone-k4606-3g-hsdpa-usb-modem/

Who changed what in which revision?

UserRevisionLine numberNew contents of line
donatien 10:08bce4cd973a 1 /* Copyright (c) 2010-2012 mbed.org, MIT License
donatien 9:c9e9817c398c 2 *
donatien 9:c9e9817c398c 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
donatien 9:c9e9817c398c 4 * and associated documentation files (the "Software"), to deal in the Software without
donatien 9:c9e9817c398c 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
donatien 9:c9e9817c398c 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
donatien 9:c9e9817c398c 7 * Software is furnished to do so, subject to the following conditions:
donatien 9:c9e9817c398c 8 *
donatien 9:c9e9817c398c 9 * The above copyright notice and this permission notice shall be included in all copies or
donatien 9:c9e9817c398c 10 * substantial portions of the Software.
donatien 9:c9e9817c398c 11 *
donatien 9:c9e9817c398c 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
donatien 9:c9e9817c398c 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
donatien 9:c9e9817c398c 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
donatien 9:c9e9817c398c 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
donatien 9:c9e9817c398c 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
donatien 9:c9e9817c398c 17 */
donatien 9:c9e9817c398c 18
donatien 9:c9e9817c398c 19 #ifndef WANDONGLESERIALPORT_H
donatien 9:c9e9817c398c 20 #define WANDONGLESERIALPORT_H
donatien 9:c9e9817c398c 21
donatien 9:c9e9817c398c 22 #include "USBHost.h"
donatien 9:c9e9817c398c 23 #include "IUSBHostSerial.h"
donatien 9:c9e9817c398c 24
donatien 9:c9e9817c398c 25 #include "rtos.h"
donatien 9:c9e9817c398c 26
donatien 9:c9e9817c398c 27
donatien 9:c9e9817c398c 28 #define WANDONGLE_MAX_OUTEP_SIZE 64
donatien 9:c9e9817c398c 29 #define WANDONGLE_MAX_INEP_SIZE 64
donatien 9:c9e9817c398c 30
donatien 9:c9e9817c398c 31 /** A class to use a WAN (3G/LTE) access dongle
donatien 9:c9e9817c398c 32 *
donatien 9:c9e9817c398c 33 */
donatien 9:c9e9817c398c 34 class WANDongleSerialPort : public IUSBHostSerial {
donatien 9:c9e9817c398c 35 public:
donatien 9:c9e9817c398c 36 /*
donatien 9:c9e9817c398c 37 * Constructor
donatien 9:c9e9817c398c 38 *
donatien 9:c9e9817c398c 39 */
donatien 9:c9e9817c398c 40 WANDongleSerialPort();
donatien 9:c9e9817c398c 41
donatien 9:c9e9817c398c 42 void init( USBHost* pHost );
donatien 9:c9e9817c398c 43
donatien 9:c9e9817c398c 44 void connect( USBDeviceConnected* pDev, USBEndpoint* pInEp, USBEndpoint* pOutEp );
donatien 9:c9e9817c398c 45
donatien 9:c9e9817c398c 46 void disconnect( );
donatien 9:c9e9817c398c 47
donatien 9:c9e9817c398c 48 /*
donatien 9:c9e9817c398c 49 * Get a char from the dongle's serial interface
donatien 9:c9e9817c398c 50 */
donatien 9:c9e9817c398c 51 virtual int getc();
donatien 9:c9e9817c398c 52
donatien 9:c9e9817c398c 53 /*
donatien 9:c9e9817c398c 54 * Put a char to the dongle's serial interface
donatien 9:c9e9817c398c 55 */
donatien 9:c9e9817c398c 56 virtual int putc(int c);
donatien 9:c9e9817c398c 57
donatien 9:c9e9817c398c 58 /*
donatien 9:c9e9817c398c 59 * Read a packet from the dongle's serial interface, to be called after multiple getc() calls
donatien 9:c9e9817c398c 60 */
donatien 9:c9e9817c398c 61 virtual int readPacket();
donatien 9:c9e9817c398c 62
donatien 9:c9e9817c398c 63 /*
donatien 9:c9e9817c398c 64 * Write a packet to the dongle's serial interface, to be called after multiple putc() calls
donatien 9:c9e9817c398c 65 */
donatien 9:c9e9817c398c 66 virtual int writePacket();
donatien 9:c9e9817c398c 67
donatien 9:c9e9817c398c 68 /**
donatien 9:c9e9817c398c 69 * Check the number of bytes available.
donatien 9:c9e9817c398c 70 *
donatien 9:c9e9817c398c 71 * @returns the number of bytes available
donatien 9:c9e9817c398c 72 */
donatien 9:c9e9817c398c 73 virtual int readable();
donatien 9:c9e9817c398c 74
donatien 9:c9e9817c398c 75 /**
donatien 9:c9e9817c398c 76 * Check the free space in output.
donatien 9:c9e9817c398c 77 *
donatien 9:c9e9817c398c 78 * @returns the number of bytes available
donatien 9:c9e9817c398c 79 */
donatien 9:c9e9817c398c 80 virtual int writeable();
donatien 9:c9e9817c398c 81
donatien 9:c9e9817c398c 82 /**
donatien 9:c9e9817c398c 83 * Attach a handler to call when a packet is received / when a packet has been transmitted.
donatien 9:c9e9817c398c 84 *
donatien 9:c9e9817c398c 85 * @param pListener instance of the listener deriving from the IUSBHostSerialListener
donatien 9:c9e9817c398c 86 */
donatien 9:c9e9817c398c 87 virtual void attach(IUSBHostSerialListener* pListener);
donatien 9:c9e9817c398c 88
donatien 9:c9e9817c398c 89 /**
donatien 9:c9e9817c398c 90 * Enable or disable readable/writeable callbacks
donatien 9:c9e9817c398c 91 */
donatien 9:c9e9817c398c 92 virtual void setupIrq(bool en, IrqType irq = RxIrq);
donatien 9:c9e9817c398c 93
donatien 9:c9e9817c398c 94
donatien 9:c9e9817c398c 95 protected:
donatien 9:c9e9817c398c 96 USBEndpoint * bulk_in;
donatien 9:c9e9817c398c 97 USBEndpoint * bulk_out;
donatien 9:c9e9817c398c 98 USBHost * host;
donatien 9:c9e9817c398c 99 USBDeviceConnected * dev;
donatien 9:c9e9817c398c 100
donatien 9:c9e9817c398c 101 uint8_t buf_out[WANDONGLE_MAX_OUTEP_SIZE];
donatien 9:c9e9817c398c 102 volatile uint32_t buf_out_len;
donatien 9:c9e9817c398c 103 uint32_t max_out_size;
donatien 9:c9e9817c398c 104 volatile bool lock_tx;
donatien 9:c9e9817c398c 105 volatile bool cb_tx_en;
donatien 9:c9e9817c398c 106 volatile bool cb_tx_pending;
donatien 9:c9e9817c398c 107 Mutex tx_mtx;
donatien 9:c9e9817c398c 108
donatien 9:c9e9817c398c 109 uint8_t buf_in[WANDONGLE_MAX_INEP_SIZE];
donatien 9:c9e9817c398c 110 volatile uint32_t buf_in_len;
donatien 9:c9e9817c398c 111 volatile uint32_t buf_in_read_pos;
donatien 9:c9e9817c398c 112 volatile bool lock_rx;
donatien 9:c9e9817c398c 113 volatile bool cb_rx_en;
donatien 9:c9e9817c398c 114 volatile bool cb_rx_pending;
donatien 9:c9e9817c398c 115 Mutex rx_mtx;
donatien 9:c9e9817c398c 116
donatien 9:c9e9817c398c 117 IUSBHostSerialListener* listener;
donatien 9:c9e9817c398c 118
donatien 9:c9e9817c398c 119 void reset();
donatien 9:c9e9817c398c 120
donatien 9:c9e9817c398c 121 void rxHandler();
donatien 9:c9e9817c398c 122 void txHandler();
donatien 9:c9e9817c398c 123
donatien 9:c9e9817c398c 124 };
donatien 9:c9e9817c398c 125
donatien 9:c9e9817c398c 126 #endif