Mistake on this page?
Report an issue in GitHub or email us
Functions
Serial Configuration Functions

Functions

void serial_init (serial_t *obj, PinName tx, PinName rx)
 Initialize the serial peripheral. More...
 
void serial_free (serial_t *obj)
 Release the serial peripheral, not currently invoked. More...
 
void serial_baud (serial_t *obj, int baudrate)
 Configure the baud rate. More...
 
void serial_format (serial_t *obj, int data_bits, SerialParity parity, int stop_bits)
 Configure the format. More...
 
void serial_irq_handler (serial_t *obj, uart_irq_handler handler, uint32_t id)
 The serial interrupt handler registration. More...
 
void serial_irq_set (serial_t *obj, SerialIrq irq, uint32_t enable)
 Configure serial interrupt. More...
 
int serial_getc (serial_t *obj)
 Get character. More...
 
void serial_putc (serial_t *obj, int c)
 Send a character. More...
 
int serial_readable (serial_t *obj)
 Check if the serial peripheral is readable. More...
 
int serial_writable (serial_t *obj)
 Check if the serial peripheral is writable. More...
 
void serial_clear (serial_t *obj)
 Clear the serial peripheral. More...
 
void serial_break_set (serial_t *obj)
 Set the break. More...
 
void serial_break_clear (serial_t *obj)
 Clear the break. More...
 
void serial_pinout_tx (PinName tx)
 Configure the TX pin for UART function. More...
 
void serial_set_flow_control (serial_t *obj, FlowControl type, PinName rxflow, PinName txflow)
 Configure the serial for the flow control. More...
 
const PinMapserial_tx_pinmap (void)
 Get the pins that support Serial TX. More...
 
const PinMapserial_rx_pinmap (void)
 Get the pins that support Serial RX. More...
 
const PinMapserial_cts_pinmap (void)
 Get the pins that support Serial CTS. More...
 
const PinMapserial_rts_pinmap (void)
 Get the pins that support Serial RTS. More...
 

Detailed Description

Function Documentation

void serial_baud ( serial_t obj,
int  baudrate 
)

Configure the baud rate.

Parameters
objThe serial object
baudrateThe baud rate to be configured
void serial_break_clear ( serial_t obj)

Clear the break.

Parameters
objThe serial object
void serial_break_set ( serial_t obj)

Set the break.

Parameters
objThe serial object
void serial_clear ( serial_t obj)

Clear the serial peripheral.

Parameters
objThe serial object
const PinMap* serial_cts_pinmap ( void  )

Get the pins that support Serial CTS.

Return a PinMap array of pins that support Serial CTS. The array is terminated with {NC, NC, 0}.

Returns
PinMap array
void serial_format ( serial_t obj,
int  data_bits,
SerialParity  parity,
int  stop_bits 
)

Configure the format.

Set the number of bits, parity and the number of stop bits

Parameters
objThe serial object
data_bitsThe number of data bits
parityThe parity
stop_bitsThe number of stop bits
void serial_free ( serial_t obj)

Release the serial peripheral, not currently invoked.

It requires further resource management.

Parameters
objThe serial object
int serial_getc ( serial_t obj)

Get character.

This is a blocking call, waiting for a character

Parameters
objThe serial object
void serial_init ( serial_t obj,
PinName  tx,
PinName  rx 
)

Initialize the serial peripheral.

It sets the default parameters for serial peripheral, and configures its specifieds pins.

Parameters
objThe serial object
txThe TX pin name
rxThe RX pin name
void serial_irq_handler ( serial_t obj,
uart_irq_handler  handler,
uint32_t  id 
)

The serial interrupt handler registration.

Parameters
objThe serial object
handlerThe interrupt handler which will be invoked when the interrupt fires
idThe SerialBase object
void serial_irq_set ( serial_t obj,
SerialIrq  irq,
uint32_t  enable 
)

Configure serial interrupt.

This function is used for word-approach

Parameters
objThe serial object
irqThe serial IRQ type (RX or TX)
enableSet to non-zero to enable events, or zero to disable them
void serial_pinout_tx ( PinName  tx)

Configure the TX pin for UART function.

Parameters
txThe pin name used for TX
void serial_putc ( serial_t obj,
int  c 
)

Send a character.

This is a blocking call, waiting for a peripheral to be available for writing

Parameters
objThe serial object
cThe character to be sent
int serial_readable ( serial_t obj)

Check if the serial peripheral is readable.

Parameters
objThe serial object
Returns
Non-zero value if a character can be read, 0 if nothing to read
const PinMap* serial_rts_pinmap ( void  )

Get the pins that support Serial RTS.

Return a PinMap array of pins that support Serial RTS. The array is terminated with {NC, NC, 0}.

Returns
PinMap array
const PinMap* serial_rx_pinmap ( void  )

Get the pins that support Serial RX.

Return a PinMap array of pins that support Serial RX. The array is terminated with {NC, NC, 0}.

Returns
PinMap array
void serial_set_flow_control ( serial_t obj,
FlowControl  type,
PinName  rxflow,
PinName  txflow 
)

Configure the serial for the flow control.

It sets flow control in the hardware if a serial peripheral supports it, otherwise software emulation is used.

Parameters
objThe serial object
typeThe type of the flow control. Look at the available FlowControl types.
rxflowThe TX pin name
txflowThe RX pin name
const PinMap* serial_tx_pinmap ( void  )

Get the pins that support Serial TX.

Return a PinMap array of pins that support Serial TX. The array is terminated with {NC, NC, 0}.

Returns
PinMap array
int serial_writable ( serial_t obj)

Check if the serial peripheral is writable.

Parameters
objThe serial object
Returns
Non-zero value if a character can be written, 0 otherwise.
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.