Mbed OS Reference
Loading...
Searching...
No Matches
Serial Configuration Functions

Modules

 Serial hal tests
 The Serial HAL tests ensure driver conformance to defined behavior.
 

Functions

void serial_init (serial_t *obj, PinName tx, PinName rx)
 Initialize the serial peripheral. More...
 
void serial_init_direct (serial_t *obj, const serial_pinmap_t *pinmap)
 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...
 
void serial_set_flow_control_direct (serial_t *obj, FlowControl type, const serial_fc_pinmap_t *pinmap)
 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

Defined behavior

Undefined behavior

Function Documentation

◆ serial_init()

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

◆ serial_init_direct()

void serial_init_direct ( serial_t obj,
const serial_pinmap_t pinmap 
)

Initialize the serial peripheral.

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

Parameters
objThe serial object
pinmappointer to structure which holds static pinmap

◆ serial_free()

void serial_free ( serial_t obj)

Release the serial peripheral, not currently invoked.

It requires further resource management.

Parameters
objThe serial object

◆ serial_baud()

void serial_baud ( serial_t obj,
int  baudrate 
)

Configure the baud rate.

Parameters
objThe serial object
baudrateThe baud rate to be configured

◆ serial_format()

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

◆ serial_irq_handler()

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 function which will be invoked when the interrupt fires. The handler function pointer must be common among all serial instances.
idThe SerialBase object. This shall be passed to handler when it's invoked for this serial instance.

◆ serial_irq_set()

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

◆ serial_getc()

int serial_getc ( serial_t obj)

Get character.

This is a blocking call, waiting for a character

Parameters
objThe serial object

◆ serial_putc()

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

◆ serial_readable()

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

◆ serial_writable()

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.

◆ serial_clear()

void serial_clear ( serial_t obj)

Clear the serial peripheral.

Parameters
objThe serial object

◆ serial_break_set()

void serial_break_set ( serial_t obj)

Set the break.

Parameters
objThe serial object

◆ serial_break_clear()

void serial_break_clear ( serial_t obj)

Clear the break.

Parameters
objThe serial object

◆ serial_pinout_tx()

void serial_pinout_tx ( PinName  tx)

Configure the TX pin for UART function.

Parameters
txThe pin name used for TX

◆ serial_set_flow_control()

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

◆ serial_set_flow_control_direct()

void serial_set_flow_control_direct ( serial_t obj,
FlowControl  type,
const serial_fc_pinmap_t pinmap 
)

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.
pinmapPointer to structure which holds static pinmap

◆ serial_tx_pinmap()

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

◆ serial_rx_pinmap()

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

◆ serial_cts_pinmap()

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

◆ serial_rts_pinmap()

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