mbed library sources

Fork of mbed-src by mbed official

Embed: (wiki syntax)

« Back to documentation index

Serial Configuration Functions

Serial Configuration Functions

Functions

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

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
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 configure its specifieds pins.

Parameters:
objThe serial object
txThe TX pin
rxThe RX pin
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 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 used for TX
void serial_putc ( serial_t obj,
int  c 
)

Put 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.
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
txflowThe rx pin
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.