nxp-mcuxpresso / mcux-sdk-examples

MCUXpresso SDK Examples
Other
48 stars 24 forks source link

Configure PRINTF macro to use drivers\fsl_uart_freertos.c #24

Open escherstair opened 5 months ago

escherstair commented 5 months ago

Almost every SDK examples uses PRINTF macro to forward debug messages. As an example https://github.com/nxp-mcuxpresso/mcux-sdk-examples/blob/e69523c33fbf902d3e49963eca5372678efa69fc/evkbimxrt1050/freertos_examples/freertos_hello/freertos_hello.c#L65

This macro is expanded based on SDK_DEBUGCONSOLE https://github.com/nxp-mcuxpresso/mcux-sdk/blob/78064ea443c7f4523e995e4b7f4ef8b9bfb47974/utilities/debug_console/fsl_debug_console.h#L39-L42

But when DEBUGCONSOLE_REDIRECT_TO_SDK is selected, the implementation follows this chain: PRINTF >> DbgConsole_Printf >> ... >> SerialManager_WriteBlocking https://github.com/nxp-mcuxpresso/mcux-sdk/blob/78064ea443c7f4523e995e4b7f4ef8b9bfb47974/components/serial_manager/fsl_component_serial_manager.c#L1713-L1720 and then Serial_UartWrite https://github.com/nxp-mcuxpresso/mcux-sdk/blob/78064ea443c7f4523e995e4b7f4ef8b9bfb47974/components/serial_manager/fsl_component_serial_port_uart.c#L287 then HAL_UartSendBlocking https://github.com/nxp-mcuxpresso/mcux-sdk/blob/78064ea443c7f4523e995e4b7f4ef8b9bfb47974/components/uart/fsl_adapter_iuart.c#L327 and this falls to UART_WriteBlocking https://github.com/nxp-mcuxpresso/mcux-sdk/blob/78064ea443c7f4523e995e4b7f4ef8b9bfb47974/drivers/iuart/fsl_uart.c#L681

I would like knowing if NXP designed this kind of macro expansion so that is there an easy way to have it falling back to some functions from FreeRTOS implementation https://github.com/nxp-mcuxpresso/mcux-sdk/blob/78064ea443c7f4523e995e4b7f4ef8b9bfb47974/drivers/iuart/fsl_uart_freertos.c