20#ifndef MBED_SERIAL_API_H
21#define MBED_SERIAL_API_H
25#include "hal/buffer.h"
30#define SERIAL_EVENT_TX_SHIFT (2)
31#define SERIAL_EVENT_RX_SHIFT (8)
33#define SERIAL_EVENT_TX_MASK (0x00FC)
34#define SERIAL_EVENT_RX_MASK (0x3F00)
36#define SERIAL_EVENT_ERROR (1 << 1)
43#define SERIAL_EVENT_TX_COMPLETE (1 << (SERIAL_EVENT_TX_SHIFT + 0))
44#define SERIAL_EVENT_TX_ALL (SERIAL_EVENT_TX_COMPLETE)
52#define SERIAL_EVENT_RX_COMPLETE (1 << (SERIAL_EVENT_RX_SHIFT + 0))
53#define SERIAL_EVENT_RX_OVERRUN_ERROR (1 << (SERIAL_EVENT_RX_SHIFT + 1))
54#define SERIAL_EVENT_RX_FRAMING_ERROR (1 << (SERIAL_EVENT_RX_SHIFT + 2))
55#define SERIAL_EVENT_RX_PARITY_ERROR (1 << (SERIAL_EVENT_RX_SHIFT + 3))
56#define SERIAL_EVENT_RX_OVERFLOW (1 << (SERIAL_EVENT_RX_SHIFT + 4))
57#define SERIAL_EVENT_RX_CHARACTER_MATCH (1 << (SERIAL_EVENT_RX_SHIFT + 5))
58#define SERIAL_EVENT_RX_ALL (SERIAL_EVENT_RX_OVERFLOW | SERIAL_EVENT_RX_PARITY_ERROR | \
59 SERIAL_EVENT_RX_FRAMING_ERROR | SERIAL_EVENT_RX_OVERRUN_ERROR | \
60 SERIAL_EVENT_RX_COMPLETE | SERIAL_EVENT_RX_CHARACTER_MATCH)
63#define SERIAL_RESERVED_CHAR_MATCH (255)
87typedef void (*uart_irq_handler)(uint32_t id,
SerialIrq event);
89#if DEVICE_SERIAL_ASYNCH
93 struct serial_s serial;
119 int tx_flow_function;
121 int rx_flow_function;
384#if DEVICE_SERIAL_ASYNCH
void serial_rx_asynch(serial_t *obj, void *rx, size_t rx_length, uint8_t rx_width, uint32_t handler, uint32_t event, uint8_t char_match, DMAUsage hint)
Begin asynchronous RX transfer (enable interrupt for data collecting) The used buffer is specified in...
void serial_rx_abort_asynch(serial_t *obj)
Abort the ongoing RX transaction.
void serial_tx_abort_asynch(serial_t *obj)
Abort the ongoing TX transaction.
int serial_tx_asynch(serial_t *obj, const void *tx, size_t tx_length, uint8_t tx_width, uint32_t handler, uint32_t event, DMAUsage hint)
Begin asynchronous TX transfer.
int serial_irq_handler_asynch(serial_t *obj)
The asynchronous TX and RX handler.
uint8_t serial_tx_active(serial_t *obj)
Attempts to determine if the serial peripheral is already in use for TX.
uint8_t serial_rx_active(serial_t *obj)
Attempts to determine if the serial peripheral is already in use for RX.
int serial_readable(serial_t *obj)
Check if the serial peripheral is readable.
void serial_set_flow_control(serial_t *obj, FlowControl type, PinName rxflow, PinName txflow)
Configure the serial for the flow control.
void serial_putc(serial_t *obj, int c)
Send a character.
void serial_free(serial_t *obj)
Release the serial peripheral, not currently invoked.
void serial_init(serial_t *obj, PinName tx, PinName rx)
Initialize the serial peripheral.
void serial_baud(serial_t *obj, int baudrate)
Configure the baud rate.
void serial_clear(serial_t *obj)
Clear the serial peripheral.
const PinMap * serial_tx_pinmap(void)
Get the pins that support Serial TX.
void serial_init_direct(serial_t *obj, const serial_pinmap_t *pinmap)
Initialize the serial peripheral.
const PinMap * serial_rts_pinmap(void)
Get the pins that support Serial RTS.
void serial_break_clear(serial_t *obj)
Clear the break.
int serial_getc(serial_t *obj)
Get character.
void serial_set_flow_control_direct(serial_t *obj, FlowControl type, const serial_fc_pinmap_t *pinmap)
Configure the serial for the flow control.
void serial_irq_handler(serial_t *obj, uart_irq_handler handler, uint32_t id)
The serial interrupt handler registration.
int serial_writable(serial_t *obj)
Check if the serial peripheral is writable.
void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_bits)
Configure the format.
const PinMap * serial_cts_pinmap(void)
Get the pins that support Serial CTS.
void serial_break_set(serial_t *obj)
Set the break.
void serial_pinout_tx(PinName tx)
Configure the TX pin for UART function.
const PinMap * serial_rx_pinmap(void)
Get the pins that support Serial RX.
void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable)
Configure serial interrupt.
SerialIrq
Serial interrupt sources.
DMAUsage
Enumeration of possible DMA usage hints.
@ TxIrq
Transmit Data Register Empty.
@ RxIrq
Receive Data Register Full.
Generic buffer structure.
Asynch serial HAL structure.
uint8_t char_found
State of the matched character.
uint8_t char_match
Character to be matched.