The beta version of the Vodafone K3770 dongle driver

This library is deprecated. Please use the newest production branch of the library from https://mbed.org/users/mbed_official/code/VodafoneUSBModem/

Committer:
donatien
Date:
Thu Nov 01 10:03:50 2012 +0000
Revision:
1:4b33ffe61bfa
Parent:
0:0ac66acdfdc0
Deprecating library, pointing out at new one

Who changed what in which revision?

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