| | |
| | | /* |
| | | * Copyright (c) 2019-2023 Beijing Hanwei Innovation Technology Ltd. Co. and |
| | | * Copyright (c) 2019-2025 Beijing Hanwei Innovation Technology Ltd. Co. and |
| | | * its subsidiaries and affiliates (collectly called MKSEMI). |
| | | * |
| | | * All rights reserved. |
| | |
| | | (TRACE_LVL_CONFIG_1 >> (4 * (TRACE_MODULE_SE - 8))) & 0xf, |
| | | // SCP03 |
| | | (TRACE_LVL_CONFIG_1 >> (4 * (TRACE_MODULE_SCP03 - 8))) & 0xf, |
| | | // Aliro |
| | | (TRACE_LVL_CONFIG_1 >> (4 * (TRACE_MODULE_ALIRO - 8))) & 0xf, |
| | | }; |
| | | |
| | | const static char *module_name[TRACE_MODULE_NUM] = {"[MAC]", "[PHY]", "[DRV]", "[APP]", "[UWB]", "[UCI]", "[TEST]", |
| | | "[BOOT]", "[OS]", "[FIRA]", "[CCC]", "[SE]", "[SCP03]"}; |
| | | const static char *module_name[TRACE_MODULE_NUM] = {"[MAC]", "[PHY]", "[DRV]", "[APP]", "[UWB]", "[UCI]", "[TEST]", |
| | | "[BOOT]", "[OS]", "[FIRA]", "[CCC]", "[SE]", "[SCP03]", "[ALIRO]"}; |
| | | |
| | | const static char *level_tag[TRACE_LEVEL_NUM] = { |
| | | "[ERROR]", |
| | |
| | | int trace_close(void) |
| | | { |
| | | int ret = 0; |
| | | // flush the trace buffer before close |
| | | trace_flush(); |
| | | |
| | | trace_handle.enabled = 0; |
| | | if ((trace_handle.port == TRACE_PORT_UART0) || (trace_handle.port == TRACE_PORT_UART1)) |
| | | { |
| | |
| | | } |
| | | |
| | | #endif |
| | | |
| | | int trace_printf(uint16_t module, uint8_t level, const char *fmt, ...) |
| | | { |
| | | if (trace_handle.enabled == 0) |
| | |
| | | // uint32_t lock = int_lock(); |
| | | if ((module & TRACE_NO_TIMESTAMP) == 0) |
| | | { |
| | | mk_snprintf(&buf[pre_len], sizeof(buf) - pre_len, "%10u | ", sys_tick_us()); |
| | | mk_snprintf(&buf[pre_len], sizeof(buf) - pre_len, "%10u | ", rtc_us()); |
| | | pre_len = strlen(buf); |
| | | } |
| | | if ((module & TRACE_NO_MODULE_NAME) == 0) |
| | |
| | | } while (1); |
| | | } |
| | | |
| | | #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) |
| | | #pragma clang diagnostic push |
| | | #pragma clang diagnostic ignored "-Wuninitialized" |
| | | #endif |
| | | |
| | | #if BACKTRACE_EN |
| | | void trace_flush(void) |
| | | { |
| | | if ((trace_handle.port == TRACE_PORT_UART0) || (trace_handle.port == TRACE_PORT_UART1)) |
| | | { |
| | | enum UART_DEV_T trace_uart = (trace_handle.port == TRACE_PORT_UART0) ? UART_ID0 : UART_ID1; |
| | | while (uart_tx_in_progress(trace_uart)) |
| | | while (uart_tx_fifo_is_empty(trace_uart) == false) |
| | | { |
| | | } |
| | | } |
| | |
| | | trace_handle.sending = false; |
| | | int_unlock(lock); |
| | | } |
| | | |
| | | #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) |
| | | #pragma clang diagnostic push |
| | | #pragma clang diagnostic ignored "-Wuninitialized" |
| | | #endif |
| | | |
| | | #if BACKTRACE_EN |
| | | |
| | | static const char trace_new_line[] = TRACE_NEW_LINE; |
| | | |
| | |
| | | trace_output_blocking(separate_line, sizeof(separate_line) - 1); |
| | | |
| | | // Timestamp |
| | | len += mk_snprintf(&trace_handle.tx_buf[len], sizeof(trace_handle.tx_buf) - (uint32_t)len, "%10d | " TRACE_NEW_LINE, sys_tick_us()); |
| | | len += mk_snprintf(&trace_handle.tx_buf[len], sizeof(trace_handle.tx_buf) - (uint32_t)len, "%10d | " TRACE_NEW_LINE, rtc_us()); |
| | | |
| | | // Title and PC |
| | | len += mk_snprintf(&trace_handle.tx_buf[len], sizeof(trace_handle.tx_buf) - (uint32_t)len, TRACE_NEW_LINE "### ASSERT @ 0x%08X ###" TRACE_NEW_LINE, |
| | |
| | | uint32_t *stack; |
| | | |
| | | // Timestamp |
| | | len += mk_snprintf(&trace_handle.tx_buf[len], sizeof(trace_handle.tx_buf) - (uint32_t)len, "%10d | " TRACE_NEW_LINE, sys_tick_us()); |
| | | len += mk_snprintf(&trace_handle.tx_buf[len], sizeof(trace_handle.tx_buf) - (uint32_t)len, "%10d | " TRACE_NEW_LINE, rtc_us()); |
| | | |
| | | // Title |
| | | len += mk_snprintf(&trace_handle.tx_buf[len], sizeof(trace_handle.tx_buf) - (uint32_t)len, |