LOG_UART
Ameba SDK » HAL

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] | obj | The address of log uart object.
  [in] | baudrate | Baud 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] | obj | The address of log uart object.

Returns
  None

void log_uart_break_set | ( | log_uart_t * | obj | ) |

Set break control for log uart.

Parameters

  [in] | obj | The 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] | obj | The address of log uart object.

Returns
  None

void log_uart_clear_rx | ( | log_uart_t * | obj | ) |

Clear RX FIFO of log uart.

Parameters

  [in] | obj | The address of log uart object.

Returns
  None

void log_uart_clear_tx | ( | log_uart_t * | obj | ) |

Clear TX FIFO of log uart.

Parameters

  [in] | obj | The address of log uart object.

Returns
  None

void log_uart_disable | ( | log_uart_t * | obj | ) |

Disable log uart.

Parameters

  [in] | obj | The address of log uart object.

Returns
  None.

void log_uart_enable | ( | log_uart_t * | obj | ) |

Enable log uart.

Parameters

  [in] | obj | The 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] | obj | The address of log uart object.
  [in] | data_bits | Data bits of log uart object.

  [in]

  parity

  Parity 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_bits | The 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] | obj | The 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] | obj | The 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] | obj | The address of log uart object.
  [in] | baudrate | Baud rate of the log uart object.
  [in] | data_bits | Data bits of the log uart object.

  [in]

  parity

  Parity 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_bits | The 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] | obj | The address of log uart object.
  [in] | handler | The interrupt handler for log uart.
  [in] | id | The 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] | obj | The address of log uart object.
  [in] | irq | The log uart interrupt indication ID which will be enabled/disabled.
  [in] | enable | 1 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] | obj | The address of log uart object.
  [in] | handler | The function which is called when log uart gets an line status indication ID.
  [in] | id | The 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] | obj | The address of log uart object.
  [in] | c | The 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] | obj | The 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] | obj | The address of log uart object.
  [out] | prxbuf | The buffer to store received data.
  [in] | len | The maximum length of data to be read
  [in] | timeout_ms | Blocking 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] | obj | The address of log uart object.
  [out] | prxbuf | The buffer to store received data.
  [in] | len | The 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] | obj | The 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] | obj | The address of log uart object.
  [out] | prxbuf | The buffer to store received data.
  [in] | len | The maximum length of data to be read
  [in] | timeout_ms | The timeout for reading data in ms
  [in] | force_cs | User 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] | obj | The address of log uart object.
  [in] | handler | The function which is called when log uart has finished receving data
  [in] | id | The 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] | obj | The address of log uart object.
  [in] | ptxbuf | Data buffer to be sent to log uart
  [in] | len | Length of data to be sent to log uart
  [in] | timeout_ms | Blocking 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] | obj | The address of log uart object.
  [in] | ptxbuf | Data buffer to be sent to log uart
  [in] | len | Length 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] | obj | The 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] | obj | The address of log uart object.
  [in] | handler | The function which is called when log uart has finished transmitting data.
  [in] | id | The parameter for handler.

Returns
  None

int log_uart_writable | ( | log_uart_t * | obj | ) |

Check whether log uart is ready to write data.

Parameters

  [in] | obj | The address of log uart object.

Returns
  1 if log uart is ready for writing, 0 otherwise