SDK4.0
This document shows Ameba SDK 4.0 APIs
Enumerator
UART_EX

uart extended functions More...

Ameba Common

enum  SerialFifoLevel { FifoLv1Byte =0, FifoLvQuarter =1, FifoLvHalf =2, FifoLvFull =3 }
 Define RX FIFO Level: RX interrupt trigger, RTS de-assert trigger. More...
 
void serial_clear_tx (serial_t *obj)
 Clear TX fifo. More...
 
void serial_clear_rx (serial_t *obj)
 Clear RX fifo. More...
 
void serial_send_comp_handler (serial_t *obj, void *handler, uint32_t id)
 set TX complete handler. More...
 
void serial_recv_comp_handler (serial_t *obj, void *handler, uint32_t id)
 set RX complete handler. More...
 
int32_t serial_recv_blocked (serial_t *obj, char *prxbuf, uint32_t len, uint32_t timeout_ms)
 recv target length data use poll mode, with time out. More...
 
int32_t serial_send_blocked (serial_t *obj, char *ptxbuf, uint32_t len, uint32_t timeout_ms)
 send target length data use poll mode, with time out. More...
 
int32_t serial_recv_stream (serial_t *obj, char *prxbuf, uint32_t len)
 recv target length data use interrupt mode. More...
 
int32_t serial_send_stream (serial_t *obj, char *ptxbuf, uint32_t len)
 send target length data use interrupt mode. More...
 
int32_t serial_recv_stream_dma (serial_t *obj, char *prxbuf, uint32_t len)
 recv target length data use DMA mode. More...
 
int32_t serial_send_stream_dma (serial_t *obj, char *ptxbuf, uint32_t len)
 send target length data use DMA mode. More...
 
int32_t serial_send_stream_abort (serial_t *obj)
 stop the sream or steam_dma RX. More...
 
int32_t serial_recv_stream_abort (serial_t *obj)
 stop the sream or steam_dma TX. More...
 
void serial_disable (serial_t *obj)
 disable uart clock and function. More...
 
void serial_enable (serial_t *obj)
 enable uart clock and function. More...
 
int32_t serial_recv_stream_timeout (serial_t *obj, char *prxbuf, uint32_t len, uint32_t timeout_ms, void *force_cs)
 recv target length data use interrupt mode. More...
 
int32_t serial_recv_stream_dma_timeout (serial_t *obj, char *prxbuf, uint32_t len, uint32_t timeout_ms, void *force_cs)
 recv target length data use DMA mode. More...
 

Detailed Description

uart extended functions

Enumeration Type Documentation

Define RX FIFO Level: RX interrupt trigger, RTS de-assert trigger.

Enumerator
FifoLv1Byte 

1-byte

FifoLvQuarter 

4-byte

FifoLvHalf 

8-byte

FifoLvFull 

14-byte

Function Documentation

void serial_clear_rx ( serial_t *  obj)

Clear RX fifo.

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

Clear TX fifo.

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

disable uart clock and function.

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

enable uart clock and function.

Parameters
objuart object define in application software.
Return values
none
int32_t serial_recv_blocked ( serial_t *  obj,
char *  prxbuf,
uint32_t  len,
uint32_t  timeout_ms 
)

recv target length data use poll mode, with time out.

Parameters
objuart object define in application software.
ptxbufbuffer to be written to Tx FIFO.
lennumber of data to be recv.
timeout_mspolling time before timeout.
Return values
return received bytes count
Note
this function is synchronous API.
void serial_recv_comp_handler ( serial_t *  obj,
void *  handler,
uint32_t  id 
)

set RX complete handler.

Parameters
objuart object define in application software.
handlerRX complete callback function.
idRX complete callback function parameter.
Return values
none
Note
this function is used when asynchronous API is used.
int32_t serial_recv_stream ( serial_t *  obj,
char *  prxbuf,
uint32_t  len 
)

recv target length data use interrupt mode.

Parameters
objuart object define in application software.
prxbufbuffer to save data read from UART FIFO.
lennumber of data to be read.
Return values
HAL_Status
Note
this function is asynchronous API.
int32_t serial_recv_stream_abort ( serial_t *  obj)

stop the sream or steam_dma TX.

Parameters
objuart object define in application software.
Return values
HAL_Status
int32_t serial_recv_stream_dma ( serial_t *  obj,
char *  prxbuf,
uint32_t  len 
)

recv target length data use DMA mode.

Parameters
objuart object define in application software.
prxbufbuffer to save data read from UART FIFO.
lennumber of data to be read.
Return values
HAL_Status
Note
this function is asynchronous API.
int32_t serial_recv_stream_dma_timeout ( serial_t *  obj,
char *  prxbuf,
uint32_t  len,
uint32_t  timeout_ms,
void *  force_cs 
)

recv target length data use DMA mode.

Parameters
objuart object define in application software.
prxbufbuffer to save data read from UART FIFO.
lennumber of data to be recv.
timeout_mspolling time before timeout.
force_csforcing context switch function.
Return values
the byte count received before timeout, or error(<0)
Note
this function is asynchronous API.
int32_t serial_recv_stream_timeout ( serial_t *  obj,
char *  prxbuf,
uint32_t  len,
uint32_t  timeout_ms,
void *  force_cs 
)

recv target length data use interrupt mode.

Parameters
objuart object define in application software.
prxbufbuffer to save data read from UART FIFO.
lennumber of data to be recv.
timeout_mspolling time before timeout.
force_csforcing context switch function.
Return values
the byte count received before timeout, or error(<0)
Note
this function is asynchronous API.
int32_t serial_send_blocked ( serial_t *  obj,
char *  ptxbuf,
uint32_t  len,
uint32_t  timeout_ms 
)

send target length data use poll mode, with time out.

Parameters
objuart object define in application software.
ptxbufbuffer to be written to Tx FIFO.
lennumber of data to be send.
timeout_mspolling time before timeout.
Return values
transmitted bytes count
Note
this function is synchronous API.
void serial_send_comp_handler ( serial_t *  obj,
void *  handler,
uint32_t  id 
)

set TX complete handler.

Parameters
objuart object define in application software.
handlerTX complete callback function.
idTX complete callback function parameter.
Return values
none
Note
this function is used when asynchronous API is used.
int32_t serial_send_stream ( serial_t *  obj,
char *  ptxbuf,
uint32_t  len 
)

send target length data use interrupt mode.

Parameters
objuart object define in application software.
ptxbufbuffer to be written to Tx FIFO.
lennumber of data to be send.
Return values
HAL_Status
Note
this function is asynchronous API.
int32_t serial_send_stream_abort ( serial_t *  obj)

stop the sream or steam_dma RX.

Parameters
objuart object define in application software.
Return values
HAL_Status
int32_t serial_send_stream_dma ( serial_t *  obj,
char *  ptxbuf,
uint32_t  len 
)

send target length data use DMA mode.

Parameters
objuart object define in application software.
ptxbufbuffer to be written to Tx FIFO.
lennumber of data to be send.
Return values
HAL_Status
Note
this function is asynchronous API.