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_init(tx, rx, baudrate) cy_retarget_io_init_fc(tx, rx, NC, NC, baudrate) |
| UART HAL object used by this library. More... | |
| #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_fc (cyhal_gpio_t tx, cyhal_gpio_t rx, cyhal_gpio_t cts, cyhal_gpio_t rts, uint32_t baudrate) |
| Initialization function for redirecting low level IO commands to allow sending messages over a UART interface with flow control. More... | |
| cy_rslt_t | cy_retarget_io_init_hal (void) |
| Initialization function for redirecting low level IO commands to allow sending messages over a UART interface with a configurator generated configuration struct. 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... | |
| cy_rslt_t | cy_retarget_io_change_baud_rate (uint32_t baud_rate, uint32_t *actual_baud) |
| Changes the UART baud rate for the retarget-io interface. More... | |
| #define cy_retarget_io_init | ( | tx, | |
| rx, | |||
| baudrate | |||
| ) | cy_retarget_io_init_fc(tx, rx, NC, NC, baudrate) |
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. This will setup the communication interface to allow using printf and related functions.
In an RTOS environment, this function must be called after the RTOS has been initialized.
| tx | UART TX pin, if no TX pin use NC |
| rx | UART RX pin, if no RX pin use NC |
| baudrate | UART baudrate |
| #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.
| cy_rslt_t cy_retarget_io_init_fc | ( | cyhal_gpio_t | tx, |
| cyhal_gpio_t | rx, | ||
| cyhal_gpio_t | cts, | ||
| cyhal_gpio_t | rts, | ||
| uint32_t | baudrate | ||
| ) |
Initialization function for redirecting low level IO commands to allow sending messages over a UART interface with flow control.
This will setup the communication interface to allow using printf and related functions.
In an RTOS environment, this function must be called after the RTOS has been initialized.
| tx | UART TX pin, if no TX pin use NC |
| rx | UART RX pin, if no RX pin use NC |
| cts | UART CTS pin, if no CTS pin use NC |
| rts | UART RTS pin, if no RTS pin use NC |
| baudrate | UART baudrate |
| cy_rslt_t cy_retarget_io_init_hal | ( | void | ) |
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 initialized cy_retarget_io_uart_obj using some other mechanism.
In an RTOS environment, this function must be called after the RTOS has been initialized.
| bool cy_retarget_io_is_tx_active | ( | void | ) |
Checks whether there is data waiting to be written to the serial console.
| 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.
| cy_rslt_t cy_retarget_io_change_baud_rate | ( | uint32_t | baud_rate, |
| uint32_t * | actual_baud | ||
| ) |
Changes the UART baud rate for the retarget-io interface.
This function allows dynamic baud rate changes during runtime using the MTB-HAL framework. It operates on the UART object that was previously initialized with cy_retarget_io_init(), so no UART object parameter is needed.
The function uses the MTB-HAL baud rate setting capability to automatically determine and configure the optimal peripheral clock divider and oversample values required to achieve the target baud rate with minimal error. This leverages the HAL's built-in expertise for accurate baud rate configuration across different hardware platforms.
| baud_rate | Desired baud rate (e.g., 9600, 115200, 230400) |
| actual_baud | Pointer to store the actual baud rate achieved by the hardware, or NULL if the actual baud rate is not needed |