]>
git.gir.st - tmk_keyboard.git/blob - tmk_core/tool/mbed/mbed-sdk/libraries/USBHost/USBHost3GModule/WANDongleSerialPort.h
1 /* Copyright (c) 2010-2012 mbed.org, MIT License
3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
4 * and associated documentation files (the "Software"), to deal in the Software without
5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
7 * Software is furnished to do so, subject to the following conditions:
9 * The above copyright notice and this permission notice shall be included in all copies or
10 * substantial portions of the Software.
12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 #ifndef WANDONGLESERIALPORT_H
20 #define WANDONGLESERIALPORT_H
22 #include "USBHostConf.h"
24 #ifdef USBHOST_3GMODULE
27 #include "IUSBHostSerial.h"
32 #define WANDONGLE_MAX_OUTEP_SIZE 64
33 #define WANDONGLE_MAX_INEP_SIZE 64
35 /** A class to use a WAN (3G/LTE) access dongle
38 class WANDongleSerialPort
: public IUSBHostSerial
{
44 WANDongleSerialPort();
46 void init( USBHost
* pHost
);
48 void connect( USBDeviceConnected
* pDev
, USBEndpoint
* pInEp
, USBEndpoint
* pOutEp
);
53 * Get a char from the dongle's serial interface
58 * Put a char to the dongle's serial interface
60 virtual int putc(int c
);
63 * Read a packet from the dongle's serial interface, to be called after multiple getc() calls
65 virtual int readPacket();
68 * Write a packet to the dongle's serial interface, to be called after multiple putc() calls
70 virtual int writePacket();
73 * Check the number of bytes available.
75 * @returns the number of bytes available
77 virtual int readable();
80 * Check the free space in output.
82 * @returns the number of bytes available
84 virtual int writeable();
87 * Attach a handler to call when a packet is received / when a packet has been transmitted.
89 * @param pListener instance of the listener deriving from the IUSBHostSerialListener
91 virtual void attach(IUSBHostSerialListener
* pListener
);
94 * Enable or disable readable/writeable callbacks
96 virtual void setupIrq(bool en
, IrqType irq
= RxIrq
);
100 USBEndpoint
* bulk_in
;
101 USBEndpoint
* bulk_out
;
103 USBDeviceConnected
* dev
;
105 uint8_t buf_out
[WANDONGLE_MAX_OUTEP_SIZE
];
106 volatile uint32_t buf_out_len
;
107 uint32_t max_out_size
;
108 volatile bool lock_tx
;
109 volatile bool cb_tx_en
;
110 volatile bool cb_tx_pending
;
113 uint8_t buf_in
[WANDONGLE_MAX_INEP_SIZE
];
114 volatile uint32_t buf_in_len
;
115 volatile uint32_t buf_in_read_pos
;
116 volatile bool lock_rx
;
117 volatile bool cb_rx_en
;
118 volatile bool cb_rx_pending
;
121 IUSBHostSerialListener
* listener
;
130 #endif /* USBHOST_3GMODULE */