1 /* See Project CHIP LICENSE file for licensing information. */
3 #include <platform/logging/LogV.h>
5 #include <core/CHIPConfig.h>
6 #include <platform/CHIPDeviceConfig.h>
8 #if CHIP_DEVICE_CONFIG_ENABLE_THREAD
9 #include <openthread/platform/logging.h>
12 #include "ti_drivers_config.h"
14 #include <ti/drivers/UART.h>
18 UART_Handle sDebugUartHandle;
19 char sDebugUartBuffer[CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE];
21 extern "C" int cc13x2_26x2LogInit(void)
23 UART_Params uartParams;
27 UART_Params_init(&uartParams);
28 // Most params can be default because we only send data, we don't receive
29 uartParams.baudRate = 115200;
30 // unclear why the UART driver sticks in writing sometimes
31 uartParams.writeTimeout = 10000; // ticks
33 sDebugUartHandle = UART_open(CONFIG_UART_DEBUG, &uartParams);
37 extern "C" void cc13x2_26x2VLog(const char * msg, va_list v)
41 ret = vsnprintf(sDebugUartBuffer, sizeof(sDebugUartBuffer), msg, v);
45 size_t len = (ret + 2U) < sizeof(sDebugUartBuffer) ? (ret + 2) : sizeof(sDebugUartBuffer);
46 sDebugUartBuffer[len - 2] = '\r';
47 sDebugUartBuffer[len - 1] = '\n';
48 sDebugUartBuffer[len] = '\0';
50 UART_write(sDebugUartHandle, sDebugUartBuffer, len);
55 namespace DeviceLayer {
58 * Called whenever a log message is emitted.
60 * Can be overriden by the device logging file
62 void __attribute__((weak)) OnLogOutput(void) {}
64 } // namespace DeviceLayer
71 void LogV(const char * module, uint8_t category, const char * msg, va_list v)
76 cc13x2_26x2VLog(msg, v);
78 chip::DeviceLayer::OnLogOutput();
81 } // namespace Platform
82 } // namespace Logging
86 * LwIP log output function.
88 extern "C" void LwIPLog(const char * msg, ...)
94 cc13x2_26x2VLog(msg, v);
96 chip::DeviceLayer::OnLogOutput();
101 * Platform log output function.
103 extern "C" void cc13x2_26x2Log(const char * msg, ...)
109 cc13x2_26x2VLog(msg, v);
111 chip::DeviceLayer::OnLogOutput();
115 #if CHIP_DEVICE_CONFIG_ENABLE_THREAD
116 extern "C" void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char * aFormat, ...)
123 va_start(v, aFormat);
125 cc13x2_26x2VLog(aFormat, v);
127 chip::DeviceLayer::OnLogOutput();
130 #endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD