Axeda demo software for u-blox C027 (GSM)

Dependencies:   mbed

Committer:
AxedaCorp
Date:
Mon Aug 11 19:07:20 2014 +0000
Revision:
1:ff6d8adaf6b9
Parent:
0:a725e8eab383
Pointed to platform (prod)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AxedaCorp 0:a725e8eab383 1 #pragma once
AxedaCorp 0:a725e8eab383 2
AxedaCorp 0:a725e8eab383 3 #include "mbed.h"
AxedaCorp 0:a725e8eab383 4 #include "Pipe.h"
AxedaCorp 0:a725e8eab383 5
AxedaCorp 0:a725e8eab383 6 #define _SerialPipeBase SerialBase //!< base class used by this class
AxedaCorp 0:a725e8eab383 7
AxedaCorp 0:a725e8eab383 8 /** Buffered serial interface (rtos capable/interrupt driven)
AxedaCorp 0:a725e8eab383 9 */
AxedaCorp 0:a725e8eab383 10 class SerialPipe : public _SerialPipeBase
AxedaCorp 0:a725e8eab383 11 {
AxedaCorp 0:a725e8eab383 12 public:
AxedaCorp 0:a725e8eab383 13 /** Constructor
AxedaCorp 0:a725e8eab383 14 \param tx the trasmitting pin
AxedaCorp 0:a725e8eab383 15 \param rx the receiving pin
AxedaCorp 0:a725e8eab383 16 \param rxSize the size of the receiving buffer
AxedaCorp 0:a725e8eab383 17 \param txSize the size of the transmitting buffer
AxedaCorp 0:a725e8eab383 18 */
AxedaCorp 0:a725e8eab383 19 SerialPipe(PinName tx, PinName rx, int rxSize = 128, int txSize = 128);
AxedaCorp 0:a725e8eab383 20
AxedaCorp 0:a725e8eab383 21 /** Destructor
AxedaCorp 0:a725e8eab383 22 */
AxedaCorp 0:a725e8eab383 23 virtual ~SerialPipe(void);
AxedaCorp 0:a725e8eab383 24
AxedaCorp 0:a725e8eab383 25 // tx channel
AxedaCorp 0:a725e8eab383 26 //----------------------------------------------------
AxedaCorp 0:a725e8eab383 27
AxedaCorp 0:a725e8eab383 28 /** check if writable
AxedaCorp 0:a725e8eab383 29 return the number of free bytes
AxedaCorp 0:a725e8eab383 30 */
AxedaCorp 0:a725e8eab383 31 int writeable(void);
AxedaCorp 0:a725e8eab383 32
AxedaCorp 0:a725e8eab383 33 /** send a character (blocking)
AxedaCorp 0:a725e8eab383 34 \param c the character to send
AxedaCorp 0:a725e8eab383 35 \return c
AxedaCorp 0:a725e8eab383 36 */
AxedaCorp 0:a725e8eab383 37 int putc(int c);
AxedaCorp 0:a725e8eab383 38
AxedaCorp 0:a725e8eab383 39 /** send a buffer
AxedaCorp 0:a725e8eab383 40 \param buffer the buffer to send
AxedaCorp 0:a725e8eab383 41 \param length the size of the buffer to send
AxedaCorp 0:a725e8eab383 42 \param blocking, if true this function will block
AxedaCorp 0:a725e8eab383 43 until all bytes placed in the buffer.
AxedaCorp 0:a725e8eab383 44 \return the number of bytes written
AxedaCorp 0:a725e8eab383 45 */
AxedaCorp 0:a725e8eab383 46 int put(const void* buffer, int length, bool blocking);
AxedaCorp 0:a725e8eab383 47
AxedaCorp 0:a725e8eab383 48 // rx channel
AxedaCorp 0:a725e8eab383 49 //----------------------------------------------------
AxedaCorp 0:a725e8eab383 50
AxedaCorp 0:a725e8eab383 51 /** check if readable
AxedaCorp 0:a725e8eab383 52 \return the size available in the buffer.
AxedaCorp 0:a725e8eab383 53 */
AxedaCorp 0:a725e8eab383 54 int readable(void);
AxedaCorp 0:a725e8eab383 55
AxedaCorp 0:a725e8eab383 56 /** receive one character from the serial port (blocking)
AxedaCorp 0:a725e8eab383 57 \param the character received
AxedaCorp 0:a725e8eab383 58 */
AxedaCorp 0:a725e8eab383 59 int getc(void);
AxedaCorp 0:a725e8eab383 60
AxedaCorp 0:a725e8eab383 61 /** read a buffer from the serial port
AxedaCorp 0:a725e8eab383 62 \param pointer to the buffer to read.
AxedaCorp 0:a725e8eab383 63 \param length number of bytes to read
AxedaCorp 0:a725e8eab383 64 \param blocking true if all bytes shall be read. false if only the available bytes.
AxedaCorp 0:a725e8eab383 65 \return the number of bytes read.
AxedaCorp 0:a725e8eab383 66 */
AxedaCorp 0:a725e8eab383 67 int get(void* buffer, int length, bool blocking);
AxedaCorp 0:a725e8eab383 68
AxedaCorp 0:a725e8eab383 69 protected:
AxedaCorp 0:a725e8eab383 70 //! receive interrupt routine
AxedaCorp 0:a725e8eab383 71 void rxIrqBuf(void);
AxedaCorp 0:a725e8eab383 72 //! transmit interrupt woutine
AxedaCorp 0:a725e8eab383 73 void txIrqBuf(void);
AxedaCorp 0:a725e8eab383 74 //! start transmission helper
AxedaCorp 0:a725e8eab383 75 void txStart(void);
AxedaCorp 0:a725e8eab383 76 //! move bytes to hardware
AxedaCorp 0:a725e8eab383 77 void txCopy(void);
AxedaCorp 0:a725e8eab383 78 Pipe<char> _pipeRx; //!< receive pipe
AxedaCorp 0:a725e8eab383 79 Pipe<char> _pipeTx; //!< transmit pipe
AxedaCorp 0:a725e8eab383 80 };