SDK4.0
This document shows Ameba SDK 4.0 APIs
LOG_UART

log_uart functions More...

Ameba1 Only

typedef void(* loguart_irq_handler) (uint32_t id, LOG_UART_INT_ID event)
 
typedef struct log_uart_s log_uart_t
 
int32_t log_uart_init (log_uart_t *obj, int baudrate, int data_bits, SerialParity parity, int stop_bits)
 Initialize Realtek log uart. Initialize the required parts of the log uart. i.e. baudrate, data bits, parity, etc. More...
 
void log_uart_free (log_uart_t *obj)
 Release the resources related to Realtek log uart. More...
 
void log_uart_baud (log_uart_t *obj, int baudrate)
 Set the baud rate of log uart. More...
 
void log_uart_format (log_uart_t *obj, int data_bits, SerialParity parity, int stop_bits)
 Set parameters for log uart. including data bits, parity type and stop bits. More...
 
void log_uart_irq_handler (log_uart_t *obj, loguart_irq_handler handler, uint32_t id)
 Set irq handler for log uart. More...
 
void log_uart_irq_set (log_uart_t *obj, LOG_UART_INT_ID irq, uint32_t enable)
 Enable/disable the specific irq indication ID. More...
 
char log_uart_getc (log_uart_t *obj)
 Read one character from log uart. This function will block untill the log uart gets something to read. More...
 
void log_uart_putc (log_uart_t *obj, char c)
 Write one character to log uart. This function will block untill the data is successfully written to log uart. More...
 
int log_uart_readable (log_uart_t *obj)
 Check whether log uart is ready to read data. More...
 
int log_uart_writable (log_uart_t *obj)
 Check whether log uart is ready to write data. More...
 
void log_uart_clear (log_uart_t *obj)
 Clear both data at log uart This function will clear data in both TX FIFO and RX FIFO of log uart. More...
 
void log_uart_clear_tx (log_uart_t *obj)
 Clear TX FIFO of log uart. More...
 
void log_uart_clear_rx (log_uart_t *obj)
 Clear RX FIFO of log uart. More...
 
void log_uart_break_set (log_uart_t *obj)
 Set break control for log uart. More...
 
void log_uart_break_clear (log_uart_t *obj)
 Clear break control for log uart. More...
 
void log_uart_tx_comp_handler (log_uart_t *obj, void *handler, uint32_t id)
 Set the handler for complete TX. More...
 
void log_uart_rx_comp_handler (log_uart_t *obj, void *handler, uint32_t id)
 Set the handler for complete RX. More...
 
void log_uart_line_status_handler (log_uart_t *obj, void *handler, uint32_t id)
 Set the handler for line status. More...
 
int32_t log_uart_recv (log_uart_t *obj, char *prxbuf, uint32_t len, uint32_t timeout_ms)
 Read data from log uart in blocking mode. More...
 
int32_t log_uart_send (log_uart_t *obj, char *ptxbuf, uint32_t len, uint32_t timeout_ms)
 Send data to log uart in blocking mode. More...
 
int32_t log_uart_recv_stream (log_uart_t *obj, char *prxbuf, uint32_t len)
 Read data from log uart in interrupt mode(Non-blocking) More...
 
int32_t log_uart_send_stream (log_uart_t *obj, char *ptxbuf, uint32_t len)
 Send data to log uart in interrupt mode(Non-blocking) More...
 
int32_t log_uart_recv_stream_timeout (log_uart_t *obj, char *prxbuf, uint32_t len, uint32_t timeout_ms, void *force_cs)
 Read data from log uart with a given timeout in interrupt mode(Non-blocking) More...
 
int32_t log_uart_send_stream_abort (log_uart_t *obj)
 Abort interrupt mode of sending data. More...
 
int32_t log_uart_recv_stream_abort (log_uart_t *obj)
 Abort interrupt mode of receiving data. More...
 
void log_uart_disable (log_uart_t *obj)
 Disable log uart. More...
 
void log_uart_enable (log_uart_t *obj)
 Enable log uart. More...
 
uint8_t log_uart_raed_lsr (log_uart_t *obj)
 Read Line-Status register. More...
 
uint8_t log_uart_raed_msr (log_uart_t *obj)
 Read Modem-Status register. More...
 

Detailed Description

log_uart functions

Typedef Documentation

typedef void(* loguart_irq_handler) (uint32_t id, LOG_UART_INT_ID event)

Log uart irq handler function pointer type

Parameters
id: The argument for log uart interrupt handler
event: The log uart interrupt indication ID. More details is shown in hal_log_uart.h

Function Documentation

void log_uart_baud ( log_uart_t *  obj,
int  baudrate 
)

Set the baud rate of log uart.

Parameters
[in]objThe address of log uart object.
[in]baudrateBaud rate of the log uart object.
Returns
None
void log_uart_break_clear ( log_uart_t *  obj)

Clear break control for log uart.

Parameters
[in]objThe address of log uart object.
Returns
None
void log_uart_break_set ( log_uart_t *  obj)

Set break control for log uart.

Parameters
[in]objThe address of log uart object.
Returns
None
void log_uart_clear ( log_uart_t *  obj)

Clear both data at log uart This function will clear data in both TX FIFO and RX FIFO of log uart.

Parameters
[in]objThe address of log uart object.
Returns
None
void log_uart_clear_rx ( log_uart_t *  obj)

Clear RX FIFO of log uart.

Parameters
[in]objThe address of log uart object.
Returns
None
void log_uart_clear_tx ( log_uart_t *  obj)

Clear TX FIFO of log uart.

Parameters
[in]objThe address of log uart object.
Returns
None
void log_uart_disable ( log_uart_t *  obj)

Disable log uart.

Parameters
[in]objThe address of log uart object.
Returns
None.
void log_uart_enable ( log_uart_t *  obj)

Enable log uart.

Parameters
[in]objThe address of log uart object.
Returns
None.
void log_uart_format ( log_uart_t *  obj,
int  data_bits,
SerialParity  parity,
int  stop_bits 
)

Set parameters for log uart. including data bits, parity type and stop bits.

Parameters
[in]objThe address of log uart object.
[in]data_bitsData bits of log uart object.
[in]parityParity type of the log uart object
  • ParityNone, - Do not use parity
  • ParityOdd, - Use odd parity
  • ParityEven, - Use even parity
  • ParityForced1, - Use even parity, the same as ParityEven
  • ParityForced0 - Use odd parity, the same as ParityOdd
[in]stop_bitsThe number of stop bits for the log uart object.
Returns
None
void log_uart_free ( log_uart_t *  obj)

Release the resources related to Realtek log uart.

Parameters
[in]objThe address of log uart object.
Returns
None
char log_uart_getc ( log_uart_t *  obj)

Read one character from log uart. This function will block untill the log uart gets something to read.

Parameters
[in]objThe address of log uart object.
Returns
the character read from log uart
int32_t log_uart_init ( log_uart_t *  obj,
int  baudrate,
int  data_bits,
SerialParity  parity,
int  stop_bits 
)

Initialize Realtek log uart. Initialize the required parts of the log uart. i.e. baudrate, data bits, parity, etc.

Parameters
[in]objThe address of log uart object.
[in]baudrateBaud rate of the log uart object.
[in]data_bitsData bits of the log uart object.
[in]parityParity type of the log uart object
  • ParityNone, - Do not use parity
  • ParityOdd, - Use odd parity
  • ParityEven, - Use even parity
  • ParityForced1, - Use even parity, the same as ParityEven
  • ParityForced0 - Use odd parity, the same as ParityOdd
[in]stop_bitsThe number of stop bits for the log uart object.
Returns
0 if initialization is successful, -1 otherwise
void log_uart_irq_handler ( log_uart_t *  obj,
loguart_irq_handler  handler,
uint32_t  id 
)

Set irq handler for log uart.

Parameters
[in]objThe address of log uart object.
[in]handlerThe interrupt handler for log uart.
[in]idThe argument for log uart interrupt handler.
Returns
None
void log_uart_irq_set ( log_uart_t *  obj,
LOG_UART_INT_ID  irq,
uint32_t  enable 
)

Enable/disable the specific irq indication ID.

Parameters
[in]objThe address of log uart object.
[in]irqThe log uart interrupt indication ID which will be enabled/disabled.
[in]enable1 enable, 0 disable
Returns
None
void log_uart_line_status_handler ( log_uart_t *  obj,
void *  handler,
uint32_t  id 
)

Set the handler for line status.

Parameters
[in]objThe address of log uart object.
[in]handlerThe function which is called when log uart gets an line status indication ID.
[in]idThe parameter for handler.
Returns
None
void log_uart_putc ( log_uart_t *  obj,
char  c 
)

Write one character to log uart. This function will block untill the data is successfully written to log uart.

Parameters
[in]objThe address of log uart object.
[in]cThe one byte data to be written to log uart.
Returns
None
uint8_t log_uart_raed_lsr ( log_uart_t *  obj)

Read Line-Status register.

Returns
value:
  • Bit 0: RX Data Ready
  • Bit 1: Overrun Error
  • Bit 2: Parity Error
  • Bit 3: Framing Error
  • Bit 4: Break Interrupt (received data input is held in 0 state for a longer than a full word tx time)
  • Bit 5: TX FIFO empty (THR empty)
  • Bit 6: TX FIFO empty (THR & TSR both empty)
  • Bit 7: Receiver FIFO Error (parity error, framing error or break indication)
uint8_t log_uart_raed_msr ( log_uart_t *  obj)

Read Modem-Status register.

Returns
value:
  • Bit 0: DCTS, The CTS line has changed its state
  • Bit 1: DDSR, The DSR line has changed its state
  • Bit 2: TERI, RI line has changed its state from low to high state
  • Bit 3: DDCD, DCD line has changed its state
  • Bit 4: Complement of the CTS input
  • Bit 5: Complement of the DSR input
  • Bit 6: Complement of the RI input
  • Bit 7: Complement of the DCD input
int log_uart_readable ( log_uart_t *  obj)

Check whether log uart is ready to read data.

Parameters
[in]objThe address of log uart object.
Returns
1 if there is data at log uart to be read, 0 otherwise
int32_t log_uart_recv ( log_uart_t *  obj,
char *  prxbuf,
uint32_t  len,
uint32_t  timeout_ms 
)

Read data from log uart in blocking mode.

Parameters
[in]objThe address of log uart object.
[out]prxbufThe buffer to store received data.
[in]lenThe maximum length of data to be read
[in]timeout_msBlocking time in ms.
Returns
the length of received data in bytes
int32_t log_uart_recv_stream ( log_uart_t *  obj,
char *  prxbuf,
uint32_t  len 
)

Read data from log uart in interrupt mode(Non-blocking)

Parameters
[in]objThe address of log uart object.
[out]prxbufThe buffer to store received data.
[in]lenThe maximum length of data to be read
Returns
0 if success
int32_t log_uart_recv_stream_abort ( log_uart_t *  obj)

Abort interrupt mode of receiving data.

Parameters
[in]objThe address of log uart object.
Returns
the length of data received from log uart.
int32_t log_uart_recv_stream_timeout ( log_uart_t *  obj,
char *  prxbuf,
uint32_t  len,
uint32_t  timeout_ms,
void *  force_cs 
)

Read data from log uart with a given timeout in interrupt mode(Non-blocking)

Parameters
[in]objThe address of log uart object.
[out]prxbufThe buffer to store received data.
[in]lenThe maximum length of data to be read
[in]timeout_msThe timeout for reading data in ms
[in]force_csUser callback function
Returns
the length in Byte of received data before timeout, or error (< 0)
void log_uart_rx_comp_handler ( log_uart_t *  obj,
void *  handler,
uint32_t  id 
)

Set the handler for complete RX.

Parameters
[in]objThe address of log uart object.
[in]handlerThe function which is called when log uart has finished receving data
[in]idThe parameter for handler.
Returns
None
int32_t log_uart_send ( log_uart_t *  obj,
char *  ptxbuf,
uint32_t  len,
uint32_t  timeout_ms 
)

Send data to log uart in blocking mode.

Parameters
[in]objThe address of log uart object.
[in]ptxbufData buffer to be sent to log uart
[in]lenLength of data to be sent to log uart
[in]timeout_msBlocking time in ms.
Returns
the length of sent data in bytes
int32_t log_uart_send_stream ( log_uart_t *  obj,
char *  ptxbuf,
uint32_t  len 
)

Send data to log uart in interrupt mode(Non-blocking)

Parameters
[in]objThe address of log uart object.
[in]ptxbufData buffer to be sent to log uart
[in]lenLength of data to be sent to log uart
Returns
0 if success
int32_t log_uart_send_stream_abort ( log_uart_t *  obj)

Abort interrupt mode of sending data.

Parameters
[in]objThe address of log uart object.
Returns
the length of data sent to log uart.
void log_uart_tx_comp_handler ( log_uart_t *  obj,
void *  handler,
uint32_t  id 
)

Set the handler for complete TX.

Parameters
[in]objThe address of log uart object.
[in]handlerThe function which is called when log uart has finished transmitting data.
[in]idThe parameter for handler.
Returns
None
int log_uart_writable ( log_uart_t *  obj)

Check whether log uart is ready to write data.

Parameters
[in]objThe address of log uart object.
Returns
1 if log uart is ready for writing, 0 otherwise