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:
Fri Aug 17 14:31:27 2012 +0000
Revision:
22:06fb2a93a1f6
Parent:
16:02db4f537955
Child:
96:b50f5f795684
Fork with names/headers changes to prepare for pre-built version

Who changed what in which revision?

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