SDK4.0 This document shows Ameba SDK 4.0 APIs

- Main Page
- Modules
- Data Structures
- Files

Enumerator
UART_EX
Ameba SDK » HAL

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

enum SerialFifoLevel

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

  obj | uart object define in application software.

Return values

  none |

void serial_clear_tx | ( | serial_t * | obj | ) |

Clear TX fifo.

Parameters

  obj | uart object define in application software.

Return values

  none |

void serial_disable | ( | serial_t * | obj | ) |

disable uart clock and function.

Parameters

  obj | uart object define in application software.

Return values

  none |

void serial_enable | ( | serial_t * | obj | ) |

enable uart clock and function.

Parameters

  obj | uart 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

  obj | uart object define in application software.
  ptxbuf | buffer to be written to Tx FIFO.
  len | number of data to be recv.
  timeout_ms | polling 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

  obj | uart object define in application software.
  handler | RX complete callback function.
  id | RX 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

  obj | uart object define in application software.
  prxbuf | buffer to save data read from UART FIFO.
  len | number 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

  obj | uart 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

  obj | uart object define in application software.
  prxbuf | buffer to save data read from UART FIFO.
  len | number 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

  obj | uart object define in application software.
  prxbuf | buffer to save data read from UART FIFO.
  len | number of data to be recv.
  timeout_ms | polling time before timeout.
  force_cs | forcing 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

  obj | uart object define in application software.
  prxbuf | buffer to save data read from UART FIFO.
  len | number of data to be recv.
  timeout_ms | polling time before timeout.
  force_cs | forcing 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

  obj | uart object define in application software.
  ptxbuf | buffer to be written to Tx FIFO.
  len | number of data to be send.
  timeout_ms | polling 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

  obj | uart object define in application software.
  handler | TX complete callback function.
  id | TX 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

  obj | uart object define in application software.
  ptxbuf | buffer to be written to Tx FIFO.
  len | number 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

  obj | uart 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

  obj | uart object define in application software.
  ptxbuf | buffer to be written to Tx FIFO.
  len | number of data to be send.

Return values

  | HAL_Status

Note
  this function is asynchronous API.