Hi, Francesco,
I think you misunderstand the Debug console mechanism, for TWR-K65F10M board, there are two processor, one is the K65F, another is K20, the USB port of K20 communicates with PC so that you can debug and print, and K20 communicates with K65 via JTAG so that you can debug K65, while the K20 communicate with K65 via UART so taht the K65 can printf() to PC.
In conclusion, the K65 use UART to communicate with K20, K20 use USB to communicate with PC so that the K65 can print something. The USB CDC protocl is implemented on K20 instead of K65, K65 just uses UART driver to communicate with K20, so there is not application code about USB CDC protocol on K65 side.
Hope it can help you.
BR
Xiangjun Rong
/* See fsl_debug_console.h for documentation of this function. */
status_t DbgConsole_Init(uint32_t baseAddr, uint32_t baudRate, uint8_t device, uint32_t clkSrcFreq)
{
if (s_debugConsole.type != DEBUG_CONSOLE_DEVICE_TYPE_NONE)
{
return kStatus_Fail;
}
/* Set debug console to initialized to avoid duplicated initialized operation. */
s_debugConsole.type = device;
/* Switch between different device. */
switch (device)
{
#if defined(FSL_FEATURE_SOC_UART_COUNT) && (FSL_FEATURE_SOC_UART_COUNT > 0)
case DEBUG_CONSOLE_DEVICE_TYPE_UART:
{
uart_config_t uart_config;
s_debugConsole.base = (UART_Type *)baseAddr;
UART_GetDefaultConfig(&uart_config);
uart_config.baudRate_Bps = baudRate;
/* Enable clock and initial UART module follow user configure structure. */
UART_Init(s_debugConsole.base, &uart_config, clkSrcFreq);
UART_EnableTx(s_debugConsole.base, true);
UART_EnableRx(s_debugConsole.base, true);
/* Set the function pointer for send and receive for this kind of device. */
s_debugConsole.ops.tx_union.UART_PutChar = UART_WriteBlocking;
s_debugConsole.ops.rx_union.UART_GetChar = UART_ReadBlocking;
}
break;
#endif /* FSL_FEATURE_SOC_UART_COUNT */
#if defined(FSL_FEATURE_SOC_LPSCI_COUNT) && (FSL_FEATURE_SOC_LPSCI_COUNT > 0)
case DEBUG_CONSOLE_DEVICE_TYPE_LPSCI:
{
lpsci_config_t lpsci_config;
s_debugConsole.base = (UART0_Type *)baseAddr;
LPSCI_GetDefaultConfig(&lpsci_config);
lpsci_config.baudRate_Bps = baudRate;
/* Enable clock and initial UART module follow user configure structure. */
LPSCI_Init(s_debugConsole.base, &lpsci_config, clkSrcFreq);
LPSCI_EnableTx(s_debugConsole.base, true);
LPSCI_EnableRx(s_debugConsole.base, true);
/* Set the function pointer for send and receive for this kind of device. */
s_debugConsole.ops.tx_union.LPSCI_PutChar = LPSCI_WriteBlocking;
s_debugConsole.ops.rx_union.LPSCI_GetChar = LPSCI_ReadBlocking;
}
break;
#endif /* FSL_FEATURE_SOC_LPSCI_COUNT */
#if defined(FSL_FEATURE_SOC_LPUART_COUNT) && (FSL_FEATURE_SOC_LPUART_COUNT > 0)
case DEBUG_CONSOLE_DEVICE_TYPE_LPUART:
{
lpuart_config_t lpuart_config;
s_debugConsole.base = (LPUART_Type *)baseAddr;
LPUART_GetDefaultConfig(&lpuart_config);
lpuart_config.baudRate_Bps = baudRate;
/* Enable clock and initial UART module follow user configure structure. */
LPUART_Init(s_debugConsole.base, &lpuart_config, clkSrcFreq);
LPUART_EnableTx(s_debugConsole.base, true);
LPUART_EnableRx(s_debugConsole.base, true);
/* Set the function pointer for send and receive for this kind of device. */
s_debugConsole.ops.tx_union.LPUART_PutChar = LPUART_WriteBlocking;
s_debugConsole.ops.rx_union.LPUART_GetChar = LPUART_ReadBlocking;
}
break;
#endif /* FSL_FEATURE_SOC_LPUART_COUNT */
/* If new device is required as the low level device for debug console,
* Add the case branch and add the preprocessor macro to judge whether
* this kind of device exist in this SOC. */
default:
/* Device identified is invalid, return invalid device error code. */
return kStatus_InvalidArgument;
}
return kStatus_Success;
}