20 #ifndef MBED_SERIAL_API_H 21 #define MBED_SERIAL_API_H 25 #include "hal/buffer.h" 26 #include "hal/dma_api.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) 87 typedef void (*uart_irq_handler)(uint32_t id,
SerialIrq event);
89 #if DEVICE_SERIAL_ASYNCH 93 struct serial_s serial;
347 #if DEVICE_SERIAL_ASYNCH 368 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);
382 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);
const PinMap * serial_tx_pinmap(void)
Get the pins that support Serial TX.
void serial_baud(serial_t *obj, int baudrate)
Configure the baud rate.
Generic buffer structure.
void serial_tx_abort_asynch(serial_t *obj)
Abort the ongoing TX transaction.
Transmit Data Register Empty.
void serial_break_clear(serial_t *obj)
Clear the break.
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...
int serial_writable(serial_t *obj)
Check if the serial peripheral is writable.
int serial_getc(serial_t *obj)
Get character.
const PinMap * serial_cts_pinmap(void)
Get the pins that support Serial CTS.
int serial_irq_handler_asynch(serial_t *obj)
The asynchronous TX and RX handler.
uint8_t char_match
Character to be matched.
void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_bits)
Configure the format.
void serial_free(serial_t *obj)
Release the serial peripheral, not currently invoked.
SerialIrq
Serial interrupt sources.
void serial_rx_abort_asynch(serial_t *obj)
Abort the ongoing RX transaction.
void serial_init(serial_t *obj, PinName tx, PinName rx)
Initialize the serial peripheral.
void serial_irq_handler(serial_t *obj, uart_irq_handler handler, uint32_t id)
The serial interrupt handler registration.
Receive Data Register Full.
const PinMap * serial_rts_pinmap(void)
Get the pins that support Serial RTS.
void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable)
Configure serial interrupt.
const PinMap * serial_rx_pinmap(void)
Get the pins that support Serial RX.
void serial_set_flow_control(serial_t *obj, FlowControl type, PinName rxflow, PinName txflow)
Configure the serial for the flow control.
Asynch serial HAL structure.
uint8_t serial_rx_active(serial_t *obj)
Attempts to determine if the serial peripheral is already in use for RX.
uint8_t char_found
State of the matched character.
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.
void serial_clear(serial_t *obj)
Clear the serial peripheral.
void serial_break_set(serial_t *obj)
Set the break.
void serial_pinout_tx(PinName tx)
Configure the TX pin for UART function.
uint8_t serial_tx_active(serial_t *obj)
Attempts to determine if the serial peripheral is already in use for TX.
void serial_putc(serial_t *obj, int c)
Send a character.
int serial_readable(serial_t *obj)
Check if the serial peripheral is readable.