Base library for cellular modes connected on USB

Dependencies:   CellularModem USBHost

Dependents:   UbloxUSBModem

Committer:
mbed_official
Date:
Mon Dec 16 09:00:30 2013 +0000
Revision:
3:be33ff78d8c7
Synchronized with git revision 170ac6562b7b2b5bb43f8ecf82b2af18b37eeb9c

Full URL: https://github.com/mbedmicro/mbed/commit/170ac6562b7b2b5bb43f8ecf82b2af18b37eeb9c/

improve USB host library and cellular modem stack

Who changed what in which revision?

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