support library for C027 helper functions for Buffer Pipes, Buffered Serial Port (rtos capable) and GPS parsing. It includes modem APIs for USSD, SMS and Sockets.
Fork of C027_Support by
SerialPipe.h
00001 #pragma once 00002 00003 #include "mbed.h" 00004 #include "Pipe.h" 00005 00006 #define _SerialPipeBase SerialBase //!< base class used by this class 00007 00008 /** Buffered serial interface (rtos capable/interrupt driven) 00009 */ 00010 class SerialPipe : public _SerialPipeBase 00011 { 00012 public: 00013 /** Constructor 00014 \param tx the trasmitting pin 00015 \param rx the receiving pin 00016 \param rxSize the size of the receiving buffer 00017 \param txSize the size of the transmitting buffer 00018 */ 00019 SerialPipe(PinName tx, PinName rx, int rxSize = 128, int txSize = 128); 00020 00021 /** Destructor 00022 */ 00023 virtual ~SerialPipe(void); 00024 00025 // tx channel 00026 //---------------------------------------------------- 00027 00028 /** check if writable 00029 return the number of free bytes 00030 */ 00031 int writeable(void); 00032 00033 /** send a character (blocking) 00034 \param c the character to send 00035 \return c 00036 */ 00037 int putc(int c); 00038 00039 /** send a buffer 00040 \param buffer the buffer to send 00041 \param length the size of the buffer to send 00042 \param blocking, if true this function will block 00043 until all bytes placed in the buffer. 00044 \return the number of bytes written 00045 */ 00046 int put(const void* buffer, int length, bool blocking); 00047 00048 // rx channel 00049 //---------------------------------------------------- 00050 00051 /** check if readable 00052 \return the size available in the buffer. 00053 */ 00054 int readable(void); 00055 00056 /** receive one character from the serial port (blocking) 00057 \param the character received 00058 */ 00059 int getc(void); 00060 00061 /** read a buffer from the serial port 00062 \param pointer to the buffer to read. 00063 \param length number of bytes to read 00064 \param blocking true if all bytes shall be read. false if only the available bytes. 00065 \return the number of bytes read. 00066 */ 00067 int get(void* buffer, int length, bool blocking); 00068 00069 protected: 00070 //! receive interrupt routine 00071 void rxIrqBuf(void); 00072 //! transmit interrupt woutine 00073 void txIrqBuf(void); 00074 //! start transmission helper 00075 void txStart(void); 00076 //! move bytes to hardware 00077 void txCopy(void); 00078 Pipe<char> _pipeRx; //!< receive pipe 00079 Pipe<char> _pipeTx; //!< transmit pipe 00080 };
Generated on Wed Jul 13 2022 04:28:18 by 1.7.2