PHS module SMA-01 library. see: https://developer.mbed.org/users/phsfan/notebook/abitusbmodem/

Dependencies:   Socket lwip-sys lwip

Dependents:   AbitUSBModem_HTTPTest AbitUSBModem_MQTTTest AbitUSBModem_WebsocketTest AbitUSBModem_SMSTest

Fork of VodafoneUSBModem by mbed official

/media/uploads/phsfan/sma01_003.png

Committer:
donatien
Date:
Thu May 24 16:40:40 2012 +0000
Revision:
0:3b2f052c333b
Initial Commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
donatien 0:3b2f052c333b 1 /* USBSerialStream.h */
donatien 0:3b2f052c333b 2 /*
donatien 0:3b2f052c333b 3 Copyright (C) 2011 ARM Limited.
donatien 0:3b2f052c333b 4
donatien 0:3b2f052c333b 5 Permission is hereby granted, free of charge, to any person obtaining a copy of
donatien 0:3b2f052c333b 6 this software and associated documentation files (the "Software"), to deal in
donatien 0:3b2f052c333b 7 the Software without restriction, including without limitation the rights to
donatien 0:3b2f052c333b 8 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
donatien 0:3b2f052c333b 9 of the Software, and to permit persons to whom the Software is furnished to do
donatien 0:3b2f052c333b 10 so, subject to the following conditions:
donatien 0:3b2f052c333b 11
donatien 0:3b2f052c333b 12 The above copyright notice and this permission notice shall be included in all
donatien 0:3b2f052c333b 13 copies or substantial portions of the Software.
donatien 0:3b2f052c333b 14
donatien 0:3b2f052c333b 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
donatien 0:3b2f052c333b 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
donatien 0:3b2f052c333b 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
donatien 0:3b2f052c333b 18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
donatien 0:3b2f052c333b 19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
donatien 0:3b2f052c333b 20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
donatien 0:3b2f052c333b 21 SOFTWARE.
donatien 0:3b2f052c333b 22 */
donatien 0:3b2f052c333b 23
donatien 0:3b2f052c333b 24 #ifndef USBSERIALSTREAM_H_
donatien 0:3b2f052c333b 25 #define USBSERIALSTREAM_H_
donatien 0:3b2f052c333b 26
donatien 0:3b2f052c333b 27
donatien 0:3b2f052c333b 28 #include "core/fwk.h"
donatien 0:3b2f052c333b 29
donatien 0:3b2f052c333b 30 #include "USB3GModule/IUSBHostSerial.h"
donatien 0:3b2f052c333b 31 #include "USB3GModule/IUSBHostSerialListener.h"
donatien 0:3b2f052c333b 32
donatien 0:3b2f052c333b 33 #include "rtos.h"
donatien 0:3b2f052c333b 34 #include "core/MtxCircBuffer.h"
donatien 0:3b2f052c333b 35
donatien 0:3b2f052c333b 36 /* Input Serial Stream for USB virtual serial ports interfaces
donatien 0:3b2f052c333b 37 This class is not thread-safe, except for the *Abort() methods that can be called by any thread/ISR
donatien 0:3b2f052c333b 38 */
donatien 0:3b2f052c333b 39 #define CIRCBUF_SIZE 255
donatien 0:3b2f052c333b 40 class USBSerialStream : public IOStream, IUSBHostSerialListener
donatien 0:3b2f052c333b 41 {
donatien 0:3b2f052c333b 42 public:
donatien 0:3b2f052c333b 43 USBSerialStream(IUSBHostSerial& serial);
donatien 0:3b2f052c333b 44 /*virtual*/ ~USBSerialStream();
donatien 0:3b2f052c333b 45
donatien 0:3b2f052c333b 46 //0 for non-blocking (returns immediately), osWaitForever for infinite blocking
donatien 0:3b2f052c333b 47 virtual int read(uint8_t* buf, size_t* pLength, size_t maxLength, uint32_t timeout=osWaitForever);
donatien 0:3b2f052c333b 48 virtual size_t available();
donatien 0:3b2f052c333b 49 virtual int waitAvailable(uint32_t timeout=osWaitForever); //Wait for data to be available
donatien 0:3b2f052c333b 50 virtual int abortRead(); //Abort current reading (or waiting) operation
donatien 0:3b2f052c333b 51
donatien 0:3b2f052c333b 52
donatien 0:3b2f052c333b 53 //0 for non-blocking (returns immediately), osWaitForever for infinite blocking
donatien 0:3b2f052c333b 54 virtual int write(uint8_t* buf, size_t length, uint32_t timeout=osWaitForever);
donatien 0:3b2f052c333b 55 virtual size_t space();
donatien 0:3b2f052c333b 56 virtual int waitSpace(uint32_t timeout=osWaitForever); //Wait for space to be available
donatien 0:3b2f052c333b 57 virtual int abortWrite(); //Abort current writing (or waiting) operation
donatien 0:3b2f052c333b 58
donatien 0:3b2f052c333b 59 private:
donatien 0:3b2f052c333b 60 IUSBHostSerial& m_serial;
donatien 0:3b2f052c333b 61 volatile bool m_serialTxFifoEmpty;
donatien 0:3b2f052c333b 62
donatien 0:3b2f052c333b 63 void setupReadableISR(bool en);
donatien 0:3b2f052c333b 64 virtual void readable(); //Callback from m_serial when new data is available
donatien 0:3b2f052c333b 65
donatien 0:3b2f052c333b 66 Semaphore m_availableSphre; //Used for signalling
donatien 0:3b2f052c333b 67
donatien 0:3b2f052c333b 68 void setupWriteableISR(bool en);
donatien 0:3b2f052c333b 69 virtual void writeable(); //Callback from m_serial when new space is available
donatien 0:3b2f052c333b 70
donatien 0:3b2f052c333b 71 Semaphore m_spaceSphre; //Used for signalling
donatien 0:3b2f052c333b 72
donatien 0:3b2f052c333b 73 MtxCircBuffer<uint8_t, CIRCBUF_SIZE + 1> m_inBuf;
donatien 0:3b2f052c333b 74 MtxCircBuffer<uint8_t, CIRCBUF_SIZE + 1> m_outBuf;
donatien 0:3b2f052c333b 75 };
donatien 0:3b2f052c333b 76
donatien 0:3b2f052c333b 77 #endif /* USBSERIALSTREAM_H_ */