SDK3.5
This document shows Ameba SDK 3.5 APIs
Enumerator
UART

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...
 

Detailed Description

uart functions

Enumeration Type Documentation

UART FlowControl mode used by serial_set_flow_control.

Enumerator
FlowControlNone 

none RTS/CTS

FlowControlRTS 

RTS enable

FlowControlCTS 

CTS enable

FlowControlRTSCTS 

RTS/CTS enable

enum SerialIrq

UART Interrupt enable/disable used by serial_irq_set.

Enumerator
RxIrq 

RX IRQ enable/disable

TxIrq 

TX IRQ enable/disable

UART Parity mode used by serial_format.

Enumerator
ParityNone 

parity disable

ParityOdd 

odd parity enable

ParityEven 

even paroty enable

ParityForced1 

same action with ParityOdd

ParityForced0 

same action with ParityEven

Function Documentation

void serial_baud ( serial_t *  obj,
int  baudrate 
)

Set UART device baudrate.

Parameters
objuart object define in application software.
baudrateBaud Rate Val, like 115200 (unit is HZ).
Return values
none
void serial_break_clear ( serial_t *  obj)

disable UART break contol function.

Parameters
objuart object define in application software.
Return values
none
void serial_break_set ( serial_t *  obj)

enable UART break contol function.

Parameters
objuart object define in application software.
Return values
none
void serial_clear ( serial_t *  obj)

Clear Rx fifo.

Parameters
objuart object define in application software.
Return values
none
void serial_format ( serial_t *  obj,
int  data_bits,
SerialParity  parity,
int  stop_bits 
)

Set UART format.

Parameters
objuart object define in application software.
data_bitsdata bits, this parameter can be one of the following values:
  • 7
  • 8
paritythis parameter can be one of the following values:
  • ParityNone
  • ParityOdd
  • ParityEven
  • ParityForced1: same action with ParityOdd
  • ParityForced0: same action with ParityEven
stop_bitsthis parameter can be one of the following values:
  • 2
  • 1
Return values
none
void serial_free ( serial_t *  obj)

Deinitializes the UART device, include clock/function/interrupt/UART registers.

Parameters
objuart object define in application software.
Return values
none
int serial_getc ( serial_t *  obj)

get one byte from UART.

Parameters
objuart object define in application software.
Return values
received character
Note
this function is asynchronous API.
void serial_init ( serial_t *  obj,
PinName  tx,
PinName  rx 
)

Initializes the UART device, include clock/function/interrupt/UART registers.

Parameters
objuart object define in application software.
txTx PinName according to pinmux spec.
rxRx PinName according to pinmux spec.
Return values
none
void serial_irq_handler ( serial_t *  obj,
uart_irq_handler  handler,
uint32_t  id 
)

Set UART interrupt hander if needed.

Parameters
objuart object define in application software.
handlerinterrupt callback function
idinterrupt callback parameter
Return values
none
void serial_irq_set ( serial_t *  obj,
SerialIrq  irq,
uint32_t  enable 
)

Enable/Disable UART interrupt.

Parameters
objuart object define in application software.
irqTx or Rx interrupt, this parameter can be one of the following values:
  • RxIrq
  • TxIrq
enablethis parameter can be one of the following values:
  • 0 disable
  • 1 enable
Return values
none
void serial_pinout_tx ( PinName  tx)

set tx pinmux.

Parameters
txTx PinName according to pinmux spec.
Return values
none
void serial_putc ( serial_t *  obj,
int  c 
)

send one byte use UART.

Parameters
objuart object define in application software.
cthe data to transmit.
Return values
none
Note
this function is asynchronous API.
int serial_readable ( serial_t *  obj)

check if there is data in rx fifo.

Parameters
objuart object define in application software.
Return values
1TRUE
0FALSE
void serial_set_flow_control ( serial_t *  obj,
FlowControl  type,
PinName  rxflow,
PinName  txflow 
)

uart autoflow contol setting.

Parameters
objuart object define in application software.
typeautoflow control type.
rxflowRTS pin.
txflowCTS pin.
Return values
none
int serial_writable ( serial_t *  obj)

check if write data to tx fifo is permitted.

Parameters
objuart object define in application software.
Return values
1TRUE
0FALSE