mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Embed: (wiki syntax)

« Back to documentation index

Serial Class Reference

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

#include <Serial.h>

Inherits mbed::SerialBase, mbed::Stream, NonCopyable< Serial >, mbed::SerialBase, mbed::Stream, and NonCopyable< Serial >.

Public Member Functions

 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.
 Serial (PinName tx, PinName rx, int baud)
 Create a Serial port, connected to the specified transmit and receive pins, with the specified baud.
bool readable ()
 Determine if there is a character available to read.
bool writeable ()
 Determine if there is space available to write a character.
 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.
 Serial (PinName tx, PinName rx, int baud)
 Create a Serial port, connected to the specified transmit and receive pins, with the specified baud.
bool readable ()
 Determine if there is a character available to read.
bool writeable ()
 Determine if there is space available to write a character.
void baud (int baudrate)
 Set the baud rate of the serial port.
void baud (int baudrate)
 Set the baud rate of the serial port.
void format (int bits=8, Parity parity=SerialBase::None, int stop_bits=1)
 Set the transmission format used by the serial port.
void format (int bits=8, Parity parity=SerialBase::None, int stop_bits=1)
 Set the transmission format used by the serial port.
void attach (Callback< void()> func, IrqType type=RxIrq)
 Attach a function to call whenever a serial interrupt is generated.
void attach (Callback< void()> func, IrqType type=RxIrq)
 Attach a function to call whenever a serial interrupt is generated.
template<typename T >
 MBED_DEPRECATED_SINCE ("mbed-os-5.1","The attach function does not support cv-qualifiers. Replaced by ""attach(callback(obj, method), type).") void attach(T *obj
 Attach a member function to call whenever a serial interrupt is generated.
template<typename T >
 MBED_DEPRECATED_SINCE ("mbed-os-5.1","The attach function does not support cv-qualifiers. Replaced by ""attach(callback(obj, method), type).") void attach(T *obj
 Attach a member function to call whenever a serial interrupt is generated.
void clear_break ()
 Clear a break condition on the serial line NOTE: Should be run at least one frame after set_break is called.
void clear_break ()
 Clear a break condition on the serial line NOTE: Should be run at least one frame after set_break is called.
void send_break ()
 Generate a break condition on the serial line.
void send_break ()
 Generate a break condition on the serial line.
void set_flow_control (Flow type, PinName flow1=NC, PinName flow2=NC)
 Set the flow control type on the serial port.
void set_flow_control (Flow type, PinName flow1=NC, PinName flow2=NC)
 Set the flow control type on the serial port.
int write (const uint8_t *buffer, int length, const event_callback_t &callback, int event=SERIAL_EVENT_TX_COMPLETE)
 Begin asynchronous write using 8bit buffer.
int write (const uint16_t *buffer, int length, const event_callback_t &callback, int event=SERIAL_EVENT_TX_COMPLETE)
 Begin asynchronous write using 16bit buffer.
int write (const uint8_t *buffer, int length, const event_callback_t &callback, int event=SERIAL_EVENT_TX_COMPLETE)
 Begin asynchronous write using 8bit buffer.
int write (const uint16_t *buffer, int length, const event_callback_t &callback, int event=SERIAL_EVENT_TX_COMPLETE)
 Begin asynchronous write using 16bit buffer.
void abort_write ()
 Abort the on-going write transfer.
void abort_write ()
 Abort the on-going write transfer.
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)
 Begin asynchronous reading using 8bit buffer.
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)
 Begin asynchronous reading using 16bit buffer.
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)
 Begin asynchronous reading using 8bit buffer.
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)
 Begin asynchronous reading using 16bit buffer.
void abort_read ()
 Abort the on-going read transfer.
void abort_read ()
 Abort the on-going read transfer.
int set_dma_usage_tx (DMAUsage usage)
 Configure DMA usage suggestion for non-blocking TX transfers.
int set_dma_usage_tx (DMAUsage usage)
 Configure DMA usage suggestion for non-blocking TX transfers.
int set_dma_usage_rx (DMAUsage usage)
 Configure DMA usage suggestion for non-blocking RX transfers.
int set_dma_usage_rx (DMAUsage usage)
 Configure DMA usage suggestion for non-blocking RX transfers.
 MBED_DEPRECATED_SINCE ("mbed-os-5.4","Replaced by FileHandle::seek") virtual off_t lseek(off_t offset
 Move the file position to a given offset from a given location.

Protected Member Functions

virtual void lock ()
 Acquire exclusive access to this serial port.
virtual void unlock ()
 Release exclusive access to this serial port.
virtual void lock ()
 Acquire exclusive access to this serial port.
virtual void unlock ()
 Release exclusive access to this serial port.
virtual int close ()
 Close a file.
virtual int close ()
 Close a file.
virtual ssize_t write (const void *buffer, size_t length)
 Write the contents of a buffer to a file.
virtual ssize_t read (void *buffer, size_t length)
 Read the contents of a file into a buffer.
virtual off_t seek (off_t offset, int whence)
 Move the file position to a given offset from from a given location.
virtual off_t seek (off_t offset, int whence)
 Move the file position to a given offset from from a given location.
virtual off_t tell ()
 Get the file position of the file.
virtual off_t tell ()
 Get the file position of the file.
virtual void rewind ()
 Rewind the file position to the beginning of the file.
virtual void rewind ()
 Rewind the file position to the beginning of the file.
virtual int isatty ()
 Check if the file in an interactive terminal device.
virtual int isatty ()
 Check if the file in an interactive terminal device.
virtual int sync ()
 Flush any buffers associated with the file.
virtual int sync ()
 Flush any buffers associated with the file.
virtual off_t size ()
 Get the size of the file.
virtual off_t size ()
 Get the size of the file.
 MBED_DEPRECATED ("Invalid copy construction of a NonCopyable resource.") NonCopyable(const NonCopyable &)
 NonCopyable copy constructor.
 MBED_DEPRECATED ("Invalid copy assignment of a NonCopyable resource.") NonCopyable &operator
 NonCopyable copy assignment operator.
 MBED_DEPRECATED ("Invalid copy construction of a NonCopyable resource.") NonCopyable(const NonCopyable &)
 NonCopyable copy constructor.
 MBED_DEPRECATED ("Invalid copy assignment of a NonCopyable resource.") NonCopyable &operator
 NonCopyable copy assignment operator.
 MBED_DEPRECATED ("Invalid copy construction of a NonCopyable resource.") NonCopyable(const NonCopyable &)
 NonCopyable copy constructor.
 MBED_DEPRECATED ("Invalid copy assignment of a NonCopyable resource.") NonCopyable &operator
 NonCopyable copy assignment operator.
 MBED_DEPRECATED ("Invalid copy construction of a NonCopyable resource.") NonCopyable(const NonCopyable &)
 NonCopyable copy constructor.
 MBED_DEPRECATED ("Invalid copy assignment of a NonCopyable resource.") NonCopyable &operator
 NonCopyable copy assignment operator.
 MBED_DEPRECATED ("Invalid copy construction of a NonCopyable resource.") NonCopyable(const NonCopyable &)
 NonCopyable copy constructor.
 MBED_DEPRECATED ("Invalid copy assignment of a NonCopyable resource.") NonCopyable &operator
 NonCopyable copy assignment operator.

Private Member Functions

 MBED_DEPRECATED ("Invalid copy construction of a NonCopyable resource.") NonCopyable(const NonCopyable &)
 NonCopyable copy constructor.
 MBED_DEPRECATED ("Invalid copy assignment of a NonCopyable resource.") NonCopyable &operator
 NonCopyable copy assignment operator.

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");
 }

Definition at line 54 of file cmsis/BUILD/mbed/drivers/Serial.h.


Constructor & Destructor Documentation

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 or 9600)
Note:
Either tx or rx may be specified as NC (Not Connected) if unused

Definition at line 24 of file Serial.cpp.

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 (Not Connected) if unused

Definition at line 28 of file Serial.cpp.

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 or 9600)
Note:
Either tx or rx may be specified as NC (Not Connected) if unused
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 (Not Connected) if unused

Member Function Documentation

void abort_read ( void   ) [inherited]

Abort the on-going read transfer.

Definition at line 238 of file SerialBase.cpp.

void abort_read (  ) [inherited]

Abort the on-going read transfer.

void abort_write ( void   ) [inherited]

Abort the on-going write transfer.

Definition at line 228 of file SerialBase.cpp.

void abort_write (  ) [inherited]

Abort the on-going write transfer.

void attach ( Callback< void()>  func,
IrqType  type = RxIrq 
) [inherited]

Attach a function to call whenever a serial interrupt is generated.

Parameters:
funcA pointer to a void function, or 0 to set as none
typeWhich serial interrupt to attach the member function to (Serial::RxIrq for receive, TxIrq for transmit buffer empty)

Definition at line 77 of file SerialBase.cpp.

void attach ( Callback< void()>  func,
IrqType  type = RxIrq 
) [inherited]

Attach a function to call whenever a serial interrupt is generated.

Parameters:
funcA pointer to a void function, or 0 to set as none
typeWhich serial interrupt to attach the member function to (Serial::RxIrq for receive, TxIrq for transmit buffer empty)
void baud ( int  baudrate ) [inherited]

Set the baud rate of the serial port.

Parameters:
baudrateThe baudrate of the serial port (default = 9600).
void baud ( int  baudrate ) [inherited]

Set the baud rate of the serial port.

Parameters:
baudrateThe baudrate of the serial port (default = 9600).

Definition at line 45 of file SerialBase.cpp.

void clear_break (  ) [inherited]

Clear a break condition on the serial line NOTE: Should be run at least one frame after set_break is called.

Definition at line 129 of file SerialBase.cpp.

void clear_break (  ) [inherited]

Clear a break condition on the serial line NOTE: Should be run at least one frame after set_break is called.

int close (  ) [protected, virtual, inherited]

Close a file.

Returns:
0 on success, negative error code on failure

Implements FileHandle.

Definition at line 77 of file Stream.cpp.

virtual int close (  ) [protected, virtual, inherited]

Close a file.

Returns:
0 on success, negative error code on failure

Implements FileHandle.

void format ( int  bits = 8,
Parity  parity = SerialBase::None,
int  stop_bits = 1 
) [inherited]

Set the transmission format used by the serial port.

Parameters:
bitsThe number of bits in a word (5-8; default = 8)
parityThe parity used (SerialBase::None, SerialBase::Odd, SerialBase::Even, SerialBase::Forced1, SerialBase::Forced0; default = SerialBase::None)
stop_bitsThe number of stop bits (1 or 2; default = 1)

Definition at line 53 of file SerialBase.cpp.

void format ( int  bits = 8,
Parity  parity = SerialBase::None,
int  stop_bits = 1 
) [inherited]

Set the transmission format used by the serial port.

Parameters:
bitsThe number of bits in a word (5-8; default = 8)
parityThe parity used (SerialBase::None, SerialBase::Odd, SerialBase::Even, SerialBase::Forced1, SerialBase::Forced0; default = SerialBase::None)
stop_bitsThe number of stop bits (1 or 2; default = 1)
int isatty (  ) [protected, virtual, inherited]

Check if the file in an interactive terminal device.

Returns:
True if the file is a terminal
False if the file is not a terminal
Negative error code on failure

Reimplemented from FileHandle.

Definition at line 130 of file Stream.cpp.

virtual int isatty (  ) [protected, virtual, inherited]

Check if the file in an interactive terminal device.

Returns:
True if the file is a terminal
False if the file is not a terminal
Negative error code on failure

Reimplemented from FileHandle.

void lock ( void   ) [protected, virtual]

Acquire exclusive access to this serial port.

Reimplemented from SerialBase.

Definition at line 44 of file Serial.cpp.

virtual void lock ( void   ) [protected, virtual]

Acquire exclusive access to this serial port.

Reimplemented from SerialBase.

MBED_DEPRECATED ( "Invalid copy assignment of a NonCopyable< FileLike > resource."   ) [protected, inherited]

NonCopyable copy assignment operator.

A compile time warning is issued when this function is used, and a runtime warning is printed when the copy construction of the noncopyable happens.

If you see this warning, your code is probably doing something unspecified. Copying of noncopyable resources can lead to resource leak and random error.

MBED_DEPRECATED ( "Invalid copy construction of a NonCopyable< FileBase > resource."   ) const [protected, inherited]

NonCopyable copy constructor.

A compile time warning is issued when this function is used, and a runtime warning is printed when the copy construction of the noncopyable happens.

If you see this warning, your code is probably doing something unspecified. Copying of noncopyable resources can lead to resource leak and random error.

Definition at line 190 of file cmsis/BUILD/mbed/platform/NonCopyable.h.

MBED_DEPRECATED ( "Invalid copy assignment of a NonCopyable< FileBase > resource."   ) [protected, inherited]

NonCopyable copy assignment operator.

A compile time warning is issued when this function is used, and a runtime warning is printed when the copy construction of the noncopyable happens.

If you see this warning, your code is probably doing something unspecified. Copying of noncopyable resources can lead to resource leak and random error.

MBED_DEPRECATED ( "Invalid copy construction of a NonCopyable< FileHandle > resource."   ) const [protected, inherited]

NonCopyable copy constructor.

A compile time warning is issued when this function is used, and a runtime warning is printed when the copy construction of the noncopyable happens.

If you see this warning, your code is probably doing something unspecified. Copying of noncopyable resources can lead to resource leak and random error.

Definition at line 190 of file cmsis/BUILD/mbed/platform/NonCopyable.h.

MBED_DEPRECATED ( "Invalid copy construction of a NonCopyable< Stream > resource."   ) const [protected, inherited]

NonCopyable copy constructor.

A compile time warning is issued when this function is used, and a runtime warning is printed when the copy construction of the noncopyable happens.

If you see this warning, your code is probably doing something unspecified. Copying of noncopyable resources can lead to resource leak and random error.

Definition at line 190 of file cmsis/BUILD/mbed/platform/NonCopyable.h.

MBED_DEPRECATED ( "Invalid copy assignment of a NonCopyable< Stream > resource."   ) [protected, inherited]

NonCopyable copy assignment operator.

A compile time warning is issued when this function is used, and a runtime warning is printed when the copy construction of the noncopyable happens.

If you see this warning, your code is probably doing something unspecified. Copying of noncopyable resources can lead to resource leak and random error.

MBED_DEPRECATED ( "Invalid copy construction of a NonCopyable< FileLike > resource."   ) const [protected, inherited]

NonCopyable copy constructor.

A compile time warning is issued when this function is used, and a runtime warning is printed when the copy construction of the noncopyable happens.

If you see this warning, your code is probably doing something unspecified. Copying of noncopyable resources can lead to resource leak and random error.

Definition at line 190 of file cmsis/BUILD/mbed/platform/NonCopyable.h.

MBED_DEPRECATED ( "Invalid copy assignment of a NonCopyable< FileHandle > resource."   ) [protected, inherited]

NonCopyable copy assignment operator.

A compile time warning is issued when this function is used, and a runtime warning is printed when the copy construction of the noncopyable happens.

If you see this warning, your code is probably doing something unspecified. Copying of noncopyable resources can lead to resource leak and random error.

MBED_DEPRECATED ( "Invalid copy assignment of a NonCopyable< SerialBase > resource."   ) [protected, inherited]

NonCopyable copy assignment operator.

A compile time warning is issued when this function is used, and a runtime warning is printed when the copy construction of the noncopyable happens.

If you see this warning, your code is probably doing something unspecified. Copying of noncopyable resources can lead to resource leak and random error.

MBED_DEPRECATED ( "Invalid copy construction of a NonCopyable< SerialBase > resource."   ) const [protected, inherited]

NonCopyable copy constructor.

A compile time warning is issued when this function is used, and a runtime warning is printed when the copy construction of the noncopyable happens.

If you see this warning, your code is probably doing something unspecified. Copying of noncopyable resources can lead to resource leak and random error.

Definition at line 190 of file cmsis/BUILD/mbed/platform/NonCopyable.h.

MBED_DEPRECATED_SINCE ( "mbed-os-5.1"  ,
"The attach function does not support cv-qualifiers. Replaced by ""attach(callback(obj, method), type)."   
) [inherited]

Attach a member function to call whenever a serial interrupt is generated.

Parameters:
objpointer to the object to call the member function on
methodpointer to the member function to be called
typeWhich serial interrupt to attach the member function to (Serial::RxIrq for receive, TxIrq for transmit buffer empty)
MBED_DEPRECATED_SINCE ( "mbed-os-5.4"  ,
"Replaced by FileHandle::seek"   
) [inherited]

Move the file position to a given offset from a given location.

Parameters:
offsetThe offset from whence to move to
whenceSEEK_SET for the start of the file, SEEK_CUR for the current file position, or SEEK_END for the end of the file.
Returns:
new file position on success, -1 on failure or unsupported
MBED_DEPRECATED_SINCE ( "mbed-os-5.1"  ,
"The attach function does not support cv-qualifiers. Replaced by ""attach(callback(obj, method), type)."   
) [inherited]

Attach a member function to call whenever a serial interrupt is generated.

Parameters:
objpointer to the object to call the member function on
methodpointer to the member function to be called
typeWhich serial interrupt to attach the member function to (Serial::RxIrq for receive, TxIrq for transmit buffer empty)
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 
) [inherited]

Begin asynchronous reading using 8bit buffer.

The completion invokes registered RX event callback.

This function locks the deep sleep until any event has occurred

Parameters:
bufferThe buffer where received data will be stored
lengthThe buffer length in bytes
callbackThe event callback function
eventThe logical OR of RX events
char_matchThe matching character

Definition at line 266 of file SerialBase.cpp.

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 
) [inherited]

Begin asynchronous reading using 16bit buffer.

The completion invokes registered RX event callback.

This function locks the deep sleep until any event has occurred

Parameters:
bufferThe buffer where received data will be stored
lengthThe buffer length in bytes
callbackThe event callback function
eventThe logical OR of RX events
char_matchThe matching character

Definition at line 276 of file SerialBase.cpp.

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 
) [inherited]

Begin asynchronous reading using 8bit buffer.

The completion invokes registered RX event callback.

This function locks the deep sleep until any event has occurred

Parameters:
bufferThe buffer where received data will be stored
lengthThe buffer length in bytes
callbackThe event callback function
eventThe logical OR of RX events
char_matchThe matching character
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 
) [inherited]

Begin asynchronous reading using 16bit buffer.

The completion invokes registered RX event callback.

This function locks the deep sleep until any event has occurred

Parameters:
bufferThe buffer where received data will be stored
lengthThe buffer length in bytes
callbackThe event callback function
eventThe logical OR of RX events
char_matchThe matching character
ssize_t read ( void *  buffer,
size_t  size 
) [protected, virtual, inherited]

Read the contents of a file into a buffer.

Devices acting as FileHandles should follow POSIX semantics:

* if no data is available, and nonblocking set, return -EAGAIN * if no data is available, and blocking set, wait until some data is available * If any data is available, call returns immediately

Parameters:
bufferThe buffer to read in to
sizeThe number of bytes to read
Returns:
The number of bytes read, 0 at end of file, negative error on failure

Implements FileHandle.

Definition at line 98 of file Stream.cpp.

bool readable (  )

Determine if there is a character available to read.

Returns:
1 if there is a character available to read, 0 otherwise

Reimplemented from SerialBase.

Definition at line 90 of file drivers/Serial.h.

bool readable (  )

Determine if there is a character available to read.

Returns:
1 if there is a character available to read, 0 otherwise

Reimplemented from SerialBase.

Definition at line 90 of file cmsis/BUILD/mbed/drivers/Serial.h.

void rewind (  ) [protected, virtual, inherited]

Rewind the file position to the beginning of the file.

Note:
This is equivalent to seek(0, SEEK_SET)

Reimplemented from FileHandle.

Definition at line 126 of file Stream.cpp.

virtual void rewind (  ) [protected, virtual, inherited]

Rewind the file position to the beginning of the file.

Note:
This is equivalent to seek(0, SEEK_SET)

Reimplemented from FileHandle.

virtual off_t seek ( off_t  offset,
int  whence 
) [protected, virtual, inherited]

Move the file position to a given offset from from a given location.

Parameters:
offsetThe offset from whence to move to
whenceThe start of where to seek SEEK_SET to start from beginning of file, SEEK_CUR to start from current position in file, SEEK_END to start from end of file
Returns:
The new offset of the file, negative error code on failure

Implements FileHandle.

off_t seek ( off_t  offset,
int  whence 
) [protected, virtual, inherited]

Move the file position to a given offset from from a given location.

Parameters:
offsetThe offset from whence to move to
whenceThe start of where to seek SEEK_SET to start from beginning of file, SEEK_CUR to start from current position in file, SEEK_END to start from end of file
Returns:
The new offset of the file, negative error code on failure

Implements FileHandle.

Definition at line 116 of file Stream.cpp.

void send_break (  ) [inherited]

Generate a break condition on the serial line.

Definition at line 136 of file SerialBase.cpp.

void send_break (  ) [inherited]

Generate a break condition on the serial line.

int set_dma_usage_rx ( DMAUsage  usage ) [inherited]

Configure DMA usage suggestion for non-blocking RX transfers.

Parameters:
usageThe usage DMA hint for peripheral
Returns:
Zero if the usage was set, -1 if a transaction is on-going
int set_dma_usage_rx ( DMAUsage  usage ) [inherited]

Configure DMA usage suggestion for non-blocking RX transfers.

Parameters:
usageThe usage DMA hint for peripheral
Returns:
Zero if the usage was set, -1 if a transaction is on-going

Definition at line 257 of file SerialBase.cpp.

int set_dma_usage_tx ( DMAUsage  usage ) [inherited]

Configure DMA usage suggestion for non-blocking TX transfers.

Parameters:
usageThe usage DMA hint for peripheral
Returns:
Zero if the usage was set, -1 if a transaction is on-going
int set_dma_usage_tx ( DMAUsage  usage ) [inherited]

Configure DMA usage suggestion for non-blocking TX transfers.

Parameters:
usageThe usage DMA hint for peripheral
Returns:
Zero if the usage was set, -1 if a transaction is on-going

Definition at line 248 of file SerialBase.cpp.

void set_flow_control ( Flow  type,
PinName  flow1 = NC,
PinName  flow2 = NC 
) [inherited]

Set the flow control type on the serial port.

Parameters:
typethe flow control type (Disabled, RTS, CTS, RTSCTS)
flow1the first flow control pin (RTS for RTS or RTSCTS, CTS for CTS)
flow2the second flow control pin (CTS for RTSCTS)

Reimplemented in UARTSerial, and UARTSerial.

Definition at line 174 of file SerialBase.cpp.

void set_flow_control ( Flow  type,
PinName  flow1 = NC,
PinName  flow2 = NC 
) [inherited]

Set the flow control type on the serial port.

Parameters:
typethe flow control type (Disabled, RTS, CTS, RTSCTS)
flow1the first flow control pin (RTS for RTS or RTSCTS, CTS for CTS)
flow2the second flow control pin (CTS for RTSCTS)

Reimplemented in UARTSerial, and UARTSerial.

off_t size (  ) [protected, virtual, inherited]

Get the size of the file.

Returns:
Size of the file in bytes

Reimplemented from FileHandle.

Definition at line 140 of file Stream.cpp.

virtual off_t size (  ) [protected, virtual, inherited]

Get the size of the file.

Returns:
Size of the file in bytes

Reimplemented from FileHandle.

int sync (  ) [protected, virtual, inherited]

Flush any buffers associated with the file.

Returns:
0 on success, negative error code on failure

Reimplemented from FileHandle.

Definition at line 135 of file Stream.cpp.

virtual int sync (  ) [protected, virtual, inherited]

Flush any buffers associated with the file.

Returns:
0 on success, negative error code on failure

Reimplemented from FileHandle.

off_t tell (  ) [protected, virtual, inherited]

Get the file position of the file.

Note:
This is equivalent to seek(0, SEEK_CUR)
Returns:
The current offset in the file, negative error code on failure

Reimplemented from FileHandle.

Definition at line 121 of file Stream.cpp.

virtual off_t tell (  ) [protected, virtual, inherited]

Get the file position of the file.

Note:
This is equivalent to seek(0, SEEK_CUR)
Returns:
The current offset in the file, negative error code on failure

Reimplemented from FileHandle.

void unlock ( void   ) [protected, virtual]

Release exclusive access to this serial port.

Reimplemented from SerialBase.

Definition at line 49 of file Serial.cpp.

virtual void unlock ( void   ) [protected, virtual]

Release exclusive access to this serial port.

Reimplemented from SerialBase.

int write ( const uint16_t *  buffer,
int  length,
const event_callback_t &  callback,
int  event = SERIAL_EVENT_TX_COMPLETE 
) [inherited]

Begin asynchronous write using 16bit buffer.

The completion invokes registered TX event callback

This function locks the deep sleep until any event has occurred

Parameters:
bufferThe buffer where received data will be stored
lengthThe buffer length in bytes
callbackThe event callback function
eventThe logical OR of TX events
int write ( const uint8_t *  buffer,
int  length,
const event_callback_t &  callback,
int  event = SERIAL_EVENT_TX_COMPLETE 
) [inherited]

Begin asynchronous write using 8bit buffer.

The completion invokes registered TX event callback

This function locks the deep sleep until any event has occurred

Parameters:
bufferThe buffer where received data will be stored
lengthThe buffer length in bytes
callbackThe event callback function
eventThe logical OR of TX events

Definition at line 201 of file SerialBase.cpp.

ssize_t write ( const void *  buffer,
size_t  size 
) [protected, virtual, inherited]

Write the contents of a buffer to a file.

Devices acting as FileHandles should follow POSIX semantics:

* if blocking, block until all data is written * if no data can be written, and nonblocking set, return -EAGAIN * if some data can be written, and nonblocking set, write partial

Parameters:
bufferThe buffer to write from
sizeThe number of bytes to write
Returns:
The number of bytes written, negative error on failure

Implements FileHandle.

Definition at line 82 of file Stream.cpp.

int write ( const uint8_t *  buffer,
int  length,
const event_callback_t &  callback,
int  event = SERIAL_EVENT_TX_COMPLETE 
) [inherited]

Begin asynchronous write using 8bit buffer.

The completion invokes registered TX event callback

This function locks the deep sleep until any event has occurred

Parameters:
bufferThe buffer where received data will be stored
lengthThe buffer length in bytes
callbackThe event callback function
eventThe logical OR of TX events
int write ( const uint16_t *  buffer,
int  length,
const event_callback_t &  callback,
int  event = SERIAL_EVENT_TX_COMPLETE 
) [inherited]

Begin asynchronous write using 16bit buffer.

The completion invokes registered TX event callback

This function locks the deep sleep until any event has occurred

Parameters:
bufferThe buffer where received data will be stored
lengthThe buffer length in bytes
callbackThe event callback function
eventThe logical OR of TX events

Definition at line 210 of file SerialBase.cpp.

bool writeable (  )

Determine if there is space available to write a character.

Returns:
1 if there is space to write a character, 0 otherwise

Reimplemented from SerialBase.

Definition at line 98 of file cmsis/BUILD/mbed/drivers/Serial.h.

bool writeable (  )

Determine if there is space available to write a character.

Returns:
1 if there is space to write a character, 0 otherwise

Reimplemented from SerialBase.

Definition at line 98 of file drivers/Serial.h.