(retarget-io)
Retarget IO

General Description

Macros

#define CY_RETARGET_IO_RSLT_NULL_UART_PTR    (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_BOARD_LIB_RETARGET_IO, 0))
 A null pointer was passed as a function parameter.
 
#define CY_RETARGET_IO_BAUDRATE   (115200)
 UART baud rate.
 
#define CY_RETARGET_IO_CONVERT_LF_TO_CRLF
 Defining this macro enables conversion of line feed (LF) into carriage return followed by line feed (CR & LF) on the output direction (STDOUT). More...
 

Functions

cy_rslt_t cy_retarget_io_init (CySCB_Type *uart)
 UART HAL object used by this library. More...
 
bool cy_retarget_io_is_tx_active (void)
 Checks whether there is data waiting to be written to the serial console. More...
 
void cy_retarget_io_deinit (void)
 Releases the UART interface allowing it to be used for other purposes. More...
 

Macro Definition Documentation

◆ CY_RETARGET_IO_CONVERT_LF_TO_CRLF

#define CY_RETARGET_IO_CONVERT_LF_TO_CRLF

Defining this macro enables conversion of line feed (LF) into carriage return followed by line feed (CR & LF) on the output direction (STDOUT).

You can define this macro through the DEFINES variable in the application Makefile.

Function Documentation

◆ cy_retarget_io_init()

cy_rslt_t cy_retarget_io_init ( CySCB_Type *  uart)

UART HAL object used by this library.

defined(COMPONENT_MTB_HAL)

Initialization function for redirecting low level IO commands to allow sending messages over a UART interface with a configurator generated configuration struct. This will setup the communication interface to allow using printf and related functions.

This function assumes that you've already 1) initialized, and 2) enabled the UART instance using PDL function calls.

When not using the HAL, retarget-io is not thread safe. Consider using printf from a single thread or using a mutex to protect the printf calls.

Parameters
uartPointer to UART object, usually named and defined in device-configurator.
Returns
CY_RSLT_SUCCESS if successfully initialized, else an error if the UART parameter is a null pointer.

◆ cy_retarget_io_is_tx_active()

bool cy_retarget_io_is_tx_active ( void  )

Checks whether there is data waiting to be written to the serial console.

Returns
true if there are pending TX transactions, otherwise false

◆ cy_retarget_io_deinit()

void cy_retarget_io_deinit ( void  )

Releases the UART interface allowing it to be used for other purposes.

After calling this, printf and related functions will no longer work.