C027 の mbes os 5 での動作を確認しました。 I confirmed the operation at mbes os 5 of C 027.

Fork of C027_Support by u-blox

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SerialPipe.h Source File

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 baud the initial baudrate 
00017         \param rxSize the size of the receiving buffer
00018         \param txSize the size of the transmitting buffer
00019     */
00020     SerialPipe(PinName tx, PinName rx, int baudrate, int rxSize = 128, int txSize = 128);
00021     
00022     /** Destructor
00023     */
00024     virtual ~SerialPipe(void);
00025     
00026     // tx channel
00027     //----------------------------------------------------
00028     
00029     /** check if writable 
00030         return the number of free bytes
00031     */
00032     int writeable(void);
00033     
00034     /** send a character (blocking)
00035         \param c the character to send
00036         \return c
00037     */
00038     int putc(int c);
00039     
00040     /** send a buffer
00041         \param buffer the buffer to send
00042         \param length the size of the buffer to send
00043         \param blocking, if true this function will block 
00044                until all bytes placed in the buffer. 
00045         \return the number of bytes written 
00046     */
00047     int put(const void* buffer, int length, bool blocking);
00048     
00049     // rx channel
00050     //----------------------------------------------------
00051     
00052     /** check if readable
00053         \return the size available in the buffer.
00054     */
00055     int readable(void);
00056     
00057     /** receive one character from the serial port (blocking)
00058         \param the character received 
00059     */
00060     int getc(void);
00061     
00062     /** read a buffer from the serial port
00063         \param pointer to the buffer to read.
00064         \param length number of bytes to read 
00065         \param blocking true if all bytes shall be read. false if only the available bytes.
00066         \return the number of bytes read.
00067     */
00068     int get(void* buffer, int length, bool blocking);
00069     
00070 protected:
00071     //! receive interrupt routine
00072     void rxIrqBuf(void);
00073     //! transmit interrupt woutine 
00074     void txIrqBuf(void);
00075     //! start transmission helper
00076     void txStart(void);
00077     //! move bytes to hardware
00078     void txCopy(void);
00079     Pipe<char>  _pipeRx; //!< receive pipe
00080     Pipe<char>  _pipeTx; //!< transmit pipe
00081 };