SDK3.5
This document shows Ameba SDK 3.5 APIs
|
uart functions More...
Ameba Common | |
enum | SerialParity { ParityNone = 0, ParityOdd = 1, ParityEven = 2, ParityForced1 = 3, ParityForced0 = 4 } |
UART Parity mode used by serial_format. More... | |
enum | SerialIrq { RxIrq, TxIrq } |
UART Interrupt enable/disable used by serial_irq_set. More... | |
enum | FlowControl { FlowControlNone, FlowControlRTS, FlowControlCTS, FlowControlRTSCTS } |
UART FlowControl mode used by serial_set_flow_control. More... | |
typedef void(* | uart_irq_handler) (uint32_t id, SerialIrq event) |
typedef struct serial_s | serial_t |
void | serial_init (serial_t *obj, PinName tx, PinName rx) |
Initializes the UART device, include clock/function/interrupt/UART registers. More... | |
void | serial_free (serial_t *obj) |
Deinitializes the UART device, include clock/function/interrupt/UART registers. More... | |
void | serial_baud (serial_t *obj, int baudrate) |
Set UART device baudrate. More... | |
void | serial_format (serial_t *obj, int data_bits, SerialParity parity, int stop_bits) |
Set UART format. More... | |
void | serial_irq_handler (serial_t *obj, uart_irq_handler handler, uint32_t id) |
Set UART interrupt hander if needed. More... | |
void | serial_irq_set (serial_t *obj, SerialIrq irq, uint32_t enable) |
Enable/Disable UART interrupt. More... | |
int | serial_getc (serial_t *obj) |
get one byte from UART. More... | |
void | serial_putc (serial_t *obj, int c) |
send one byte use UART. More... | |
int | serial_readable (serial_t *obj) |
check if there is data in rx fifo. More... | |
int | serial_writable (serial_t *obj) |
check if write data to tx fifo is permitted. More... | |
void | serial_clear (serial_t *obj) |
Clear Rx fifo. More... | |
void | serial_break_set (serial_t *obj) |
enable UART break contol function. More... | |
void | serial_break_clear (serial_t *obj) |
disable UART break contol function. More... | |
void | serial_pinout_tx (PinName tx) |
set tx pinmux. More... | |
void | serial_set_flow_control (serial_t *obj, FlowControl type, PinName rxflow, PinName txflow) |
uart autoflow contol setting. More... | |
uart functions
enum FlowControl |
enum SerialIrq |
enum SerialParity |
void serial_baud | ( | serial_t * | obj, |
int | baudrate | ||
) |
Set UART device baudrate.
obj | uart object define in application software. |
baudrate | Baud Rate Val, like 115200 (unit is HZ). |
none |
void serial_break_clear | ( | serial_t * | obj | ) |
disable UART break contol function.
obj | uart object define in application software. |
none |
void serial_break_set | ( | serial_t * | obj | ) |
enable UART break contol function.
obj | uart object define in application software. |
none |
void serial_clear | ( | serial_t * | obj | ) |
Clear Rx fifo.
obj | uart object define in application software. |
none |
void serial_format | ( | serial_t * | obj, |
int | data_bits, | ||
SerialParity | parity, | ||
int | stop_bits | ||
) |
Set UART format.
obj | uart object define in application software. |
data_bits | data bits, this parameter can be one of the following values:
|
parity | this parameter can be one of the following values:
|
stop_bits | this parameter can be one of the following values:
|
none |
void serial_free | ( | serial_t * | obj | ) |
Deinitializes the UART device, include clock/function/interrupt/UART registers.
obj | uart object define in application software. |
none |
int serial_getc | ( | serial_t * | obj | ) |
get one byte from UART.
obj | uart object define in application software. |
received character |
void serial_init | ( | serial_t * | obj, |
PinName | tx, | ||
PinName | rx | ||
) |
Initializes the UART device, include clock/function/interrupt/UART registers.
obj | uart object define in application software. |
tx | Tx PinName according to pinmux spec. |
rx | Rx PinName according to pinmux spec. |
none |
void serial_irq_handler | ( | serial_t * | obj, |
uart_irq_handler | handler, | ||
uint32_t | id | ||
) |
Set UART interrupt hander if needed.
obj | uart object define in application software. |
handler | interrupt callback function |
id | interrupt callback parameter |
none |
void serial_irq_set | ( | serial_t * | obj, |
SerialIrq | irq, | ||
uint32_t | enable | ||
) |
Enable/Disable UART interrupt.
obj | uart object define in application software. |
irq | Tx or Rx interrupt, this parameter can be one of the following values:
|
enable | this parameter can be one of the following values:
|
none |
void serial_pinout_tx | ( | PinName | tx | ) |
set tx pinmux.
tx | Tx PinName according to pinmux spec. |
none |
void serial_putc | ( | serial_t * | obj, |
int | c | ||
) |
send one byte use UART.
obj | uart object define in application software. |
c | the data to transmit. |
none |
int serial_readable | ( | serial_t * | obj | ) |
check if there is data in rx fifo.
obj | uart object define in application software. |
1 | TRUE |
0 | FALSE |
void serial_set_flow_control | ( | serial_t * | obj, |
FlowControl | type, | ||
PinName | rxflow, | ||
PinName | txflow | ||
) |
uart autoflow contol setting.
obj | uart object define in application software. |
type | autoflow control type. |
rxflow | RTS pin. |
txflow | CTS pin. |
none |
int serial_writable | ( | serial_t * | obj | ) |
check if write data to tx fifo is permitted.
obj | uart object define in application software. |
1 | TRUE |
0 | FALSE |