Mistake on this page?
Report an issue in GitHub or email us
Public Member Functions | Protected Member Functions | Protected Attributes
mbed::Serial Class Reference

#include <Serial.h>

Inheritance diagram for mbed::Serial:
mbed::SerialBase mbed::Stream mbed::NonCopyable< Serial > mbed::NonCopyable< SerialBase > mbed::FileLike mbed::NonCopyable< Stream > mbed::FileHandle mbed::FileBase mbed::NonCopyable< FileLike > mbed::NonCopyable< FileHandle > mbed::NonCopyable< FileBase >

Public Member Functions

 Serial (PinName tx, PinName rx, const char *name=NULL, int baud=MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE)
 
 Serial (PinName tx, PinName rx, int baud)
 
bool readable ()
 
bool writable ()
 
bool writeable ()
 
- Public Member Functions inherited from mbed::SerialBase
void baud (int baudrate)
 
void format (int bits=8, Parity parity=SerialBase::None, int stop_bits=1)
 
int readable ()
 
int writeable ()
 
void attach (Callback< void()> func, IrqType type=RxIrq)
 
template<typename T >
void attach (T *obj, void(T::*method)(), IrqType type=RxIrq)
 
template<typename T >
void attach (T *obj, void(*method)(T *), IrqType type=RxIrq)
 
void send_break ()
 
void set_flow_control (Flow type, PinName flow1=NC, PinName flow2=NC)
 
int write (const uint8_t *buffer, int length, const event_callback_t &callback, int event=SERIAL_EVENT_TX_COMPLETE)
 
int write (const uint16_t *buffer, int length, const event_callback_t &callback, int event=SERIAL_EVENT_TX_COMPLETE)
 
void abort_write ()
 
int read (uint8_t *buffer, int length, const event_callback_t &callback, int event=SERIAL_EVENT_RX_COMPLETE, unsigned char char_match=SERIAL_RESERVED_CHAR_MATCH)
 
int read (uint16_t *buffer, int length, const event_callback_t &callback, int event=SERIAL_EVENT_RX_COMPLETE, unsigned char char_match=SERIAL_RESERVED_CHAR_MATCH)
 
void abort_read ()
 
int set_dma_usage_tx (DMAUsage usage)
 
int set_dma_usage_rx (DMAUsage usage)
 
- Public Member Functions inherited from mbed::Stream
 Stream (const char *name=NULL)
 
int putc (int c)
 
int puts (const char *s)
 
int getc ()
 
char * gets (char *s, int size)
 
int printf (const char *format,...)
 
int scanf (const char *format,...)
 
int vprintf (const char *format, std::va_list args)
 
int vscanf (const char *format, std::va_list args)
 
 operator std::FILE * ()
 
- Public Member Functions inherited from mbed::FileLike
 FileLike (const char *name=NULL)
 
- Public Member Functions inherited from mbed::FileHandle
virtual off_t lseek (off_t offset, int whence)
 
virtual int fsync ()
 
virtual off_t flen ()
 
virtual int set_blocking (bool blocking)
 
virtual bool is_blocking () const
 
virtual short poll (short events) const
 
bool writable () const
 
bool readable () const
 
virtual void sigio (Callback< void()> func)
 
- Public Member Functions inherited from mbed::FileBase
 FileBase (const char *name, PathType t)
 
const char * getName (void)
 
PathType getPathType (void)
 

Protected Member Functions

virtual int _getc ()
 
virtual int _putc (int c)
 
virtual void lock ()
 
virtual void unlock ()
 
- Protected Member Functions inherited from mbed::SerialBase
void start_read (void *buffer, int buffer_size, char buffer_width, const event_callback_t &callback, int event, unsigned char char_match)
 
void start_write (const void *buffer, int buffer_size, char buffer_width, const event_callback_t &callback, int event)
 
void interrupt_handler_asynch (void)
 
 SerialBase (PinName tx, PinName rx, int baud)
 
int _base_getc ()
 
int _base_putc (int c)
 
- Protected Member Functions inherited from mbed::Stream
virtual int close ()
 
virtual ssize_t write (const void *buffer, size_t length)
 
virtual ssize_t read (void *buffer, size_t length)
 
virtual off_t seek (off_t offset, int whence)
 
virtual off_t tell ()
 
virtual void rewind ()
 
virtual int isatty ()
 
virtual int sync ()
 
virtual off_t size ()
 

Protected Attributes

PlatformMutex _mutex
 
- Protected Attributes inherited from mbed::SerialBase
CThunk< SerialBase_thunk_irq
 
DMAUsage _tx_usage
 
DMAUsage _rx_usage
 
event_callback_t _tx_callback
 
event_callback_t _rx_callback
 
serial_t _serial
 
Callback< void()> _irq [IrqCnt]
 
int _baud
 
- Protected Attributes inherited from mbed::Stream
std::FILE * _file
 

Additional Inherited Members

- Public Types inherited from mbed::SerialBase
enum  Parity {
  None = 0, Odd, Even, Forced1,
  Forced0
}
 
enum  IrqType { RxIrq = 0, TxIrq, IrqCnt }
 
enum  Flow { Disabled = 0, RTS, CTS, RTSCTS }
 
- Static Public Member Functions inherited from mbed::SerialBase
static void _irq_handler (uint32_t id, SerialIrq irq_type)
 
- Static Public Member Functions inherited from mbed::FileBase
static FileBaselookup (const char *name, unsigned int len)
 
static FileBaseget (int n)
 

Detailed Description

A serial port (UART) for communication with other serial devices

Can be used for Full Duplex communication, or Simplex by specifying one pin as NC (Not Connected)

Note
Synchronization level: Thread safe

Example:

// Print "Hello World" to the PC
#include "mbed.h"
Serial pc(USBTX, USBRX);
int main() {
pc.printf("Hello World\n");
}

Constructor & Destructor Documentation

mbed::Serial::Serial ( PinName  tx,
PinName  rx,
const char *  name = NULL,
int  baud = MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE 
)

Create a Serial port, connected to the specified transmit and receive pins

Parameters
txTransmit pin
rxReceive pin
nameThe name of the stream associated with this serial port (optional)
baudThe baud rate of the serial port (optional, defaults to MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE)
Note
Either tx or rx may be specified as NC if unused
mbed::Serial::Serial ( PinName  tx,
PinName  rx,
int  baud 
)

Create a Serial port, connected to the specified transmit and receive pins, with the specified baud

Parameters
txTransmit pin
rxReceive pin
baudThe baud rate of the serial port
Note
Either tx or rx may be specified as NC if unused

Member Function Documentation

void mbed::Serial::lock ( void  )
protectedvirtual

Acquire exclusive access to this serial port

Reimplemented from mbed::SerialBase.

void mbed::Serial::unlock ( void  )
protectedvirtual

Release exclusive access to this serial port

Reimplemented from mbed::SerialBase.


The documentation for this class was generated from the following files:
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.