This commit is contained in:
huxi
2025-12-03 11:12:34 +08:00
parent c23ae4f24c
commit bc195654bf
8163 changed files with 3799544 additions and 92 deletions
+27
View File
@@ -0,0 +1,27 @@
#include <assert.h>
#include "printf.h"
void __assert_func(const char *file, int line, const char *func, const char *_e)
{
printf("\n\n ******************* ASSERT -> %s, %d, %s, %s \n", file, line, func, _e);
while (1);
}
void __assert_func_cmpt(const char *file, int line, const char *func, const char *_e)
{
printf("\n\n ******************* ASSERT -> %s, %d, %s, %s \n", file, line, func, _e);
}
void __assert_fail(const char *__assertion, const char *__file,
unsigned int __line, const char *__function)
{
printf("\n\n ******************* ASSERT -> %s, %s, %u, %s \n", __assertion, __file, __line, __function);
}
/* void __assert(const char *__assertion, const char *__file, unsigned int __line, const char *__function) */
void __assert(const char *__assertion, int __line, const char *__function)
{
printf("\n\n ******************* ASSERT -> %s, %d, %s \n", __assertion, __line, __function);
while (1);
}
+76
View File
@@ -0,0 +1,76 @@
#ifdef SUPPORT_MS_EXTENSIONS
#pragma bss_seg(".debug.data.bss")
#pragma data_seg(".debug.data")
#pragma const_seg(".debug.text.const")
#pragma code_seg(".debug.text")
#endif
#include "app_config.h"
#include "typedef.h"
#if CONFIG_DEBUG_ENABLE == 0
int putchar(int a)
{
return a;
}
int puts(const char *out)
{
return 0;
}
int printf(const char *format, ...)
{
return 0;
}
void put_buf(const u8 *buf, int len)
{
}
void put_u8hex(u8 dat)
{
}
void put_u16hex(u16 dat)
{
}
void put_u32hex(u32 dat)
{
}
void put_float(double fv)
{
}
void log_print(int level, const char *tag, const char *format, ...)
{
}
#if CONFIG_DEBUG_LITE_ENABLE==0
void log_putbyte(char c)
{
}
#endif /* #ifndef CONFIG_DEBUG_LITE_ENABLE */
int assert_printf(const char *format, ...)
{
/* extern void mem_unfree_dump(); */
/* mem_unfree_dump(); */
cpu_assert_debug();
return 0;
}
#endif
+80
View File
@@ -0,0 +1,80 @@
#ifdef SUPPORT_MS_EXTENSIONS
#pragma bss_seg(".debug_lite.data.bss")
#pragma data_seg(".debug_lite.data")
#pragma const_seg(".debug_lite.text.const")
#pragma code_seg(".debug_lite.text")
#endif
#include "app_config.h"
#include "typedef.h"
#if CONFIG_DEBUG_LITE_ENABLE
extern void putbyte(char a);
#define putbyte_lite putbyte
void log_putbyte(char c)
{
putbyte_lite(c);
}
void puts_lite(const char *out)
{
if (out != NULL) {
while (*out != '\0') {
putbyte_lite(*out);
out++;
}
}
}
int printf_lite(const char *format, ...)
{
va_list args;
va_start(args, format);
int ret = print(NULL, 0, format, args);
va_end(args);
return ret;
}
void put_buf_lite(void *_buf, u32 len)
{
if (_buf != NULL) {
u8 *buf = (u8 *)_buf;
printf_lite("\n0x%x\n", buf);
for (int i = 0; i < len; i++) {
if (((i % 16) == 0) && (i != 0)) {
putbyte_lite('\n');
}
printf_lite("%x", buf[i]);
putbyte_lite(' ');
}
putbyte_lite('\n');
}
}
#else
void puts_lite(const char *out)
{
}
void put_buf_lite(void *_buf, u32 len)
{
}
int printf_lite(const char *format, ...)
{
return 0;
}
#endif /* #ifdef CONFIG_DEBUG_LITE_ENABLE */
+124
View File
@@ -0,0 +1,124 @@
#ifdef SUPPORT_MS_EXTENSIONS
#pragma bss_seg(".debug_uart_config.data.bss")
#pragma data_seg(".debug_uart_config.data")
#pragma const_seg(".debug_uart_config.text.const")
#pragma code_seg(".debug_uart_config.text")
#endif
#include "app_config.h"
#include "cpu/includes.h"
#include "gpio_config.h"
#if CONFIG_DEBUG_ENABLE || CONFIG_DEBUG_LITE_ENABLE
#define DEBUG_UART_NUM 0
static u8 uart_mode = 0; //0:typical putbyte, 1:exception putbyte
void debug_uart_init()
{
struct uart_config debug_uart_config = {
.baud_rate = TCFG_DEBUG_UART_BAUDRATE,
.tx_pin = TCFG_DEBUG_UART_TX_PIN,
.rx_pin = -1,
};
//br29 uart0无dma
#if 0//def CONFIG_CPU_BR29
JL_PORTA->OUT |= BIT(5);
JL_PORTA->DIR &= ~BIT(5);
JL_OMAP->PA5_OUT = FO_UART0_TX;
JL_UART0->TX_CON0 = BIT(13);
JL_UART0->TX_CON0 &= ~BIT(0);
JL_UART0->TX_CON0 |= BIT(13);
JL_UART0->BAUD = (12000000 / TCFG_DEBUG_UART_BAUDRATE) / 4 - 1;
JL_UART0->TX_CON0 |= BIT(13) | BIT(0);
JL_UART0->BUF = ' ';
#else
uart_init(DEBUG_UART_NUM, &debug_uart_config);
#endif
}
static void __putbyte(char a)
{
/* if(a == '\n'){ */
/* uart_putbyte(DEBUG_UART_NUM, '\r'); */
/* } */
#if 0
int i = 0;
while ((JL_UART0->TX_CON0 & BIT(15)) == 0) {
i++;
if (i > 100000) {
break;
}
};
JL_UART0->TX_CON0 |= BIT(13);
__asm__ volatile("csync");
JL_UART0->BUF = a;
#else
uart_log_putbyte(DEBUG_UART_NUM, a);
#endif
}
/* --------------------------------------------------------------------------*/
/**
* @brief 通用打印putbyte函数,用于SDK调试
*
* @param a char
*/
/* ----------------------------------------------------------------------------*/
void putbyte(char a)
{
#if 0//def CONFIG_CPU_BR29
if (!(JL_UART0->CON0 & BIT(0))) {
return;
}
u32 i = 0x10000;
while (((JL_UART0->CON0 & BIT(15)) == 0) && (0 != i)) { //TX IDLE
i--;
}
JL_UART0->CON0 |= BIT(13); //清Tx pending
JL_UART0->BUF = a;
__asm__ volatile("csync");
#else
if (uart_mode == 0) {
__putbyte(a);
}
#endif
}
/* --------------------------------------------------------------------------*/
/**
* @brief 特俗场景putbyte函数,暂用于异常服务函数
* 调用此函数后,通用putbyte函数会停用,防止打印冲突。
* @param a char
*/
/* ----------------------------------------------------------------------------*/
//excpt默认使用内部打印函数,使用uart0,放RAM。
//若出现异常无打印情况,考虑打开此函数,放Flash。
#if 0
void excpt_putbyte(char a)
{
uart_mode = 1;
__putbyte(a);
}
#endif
#else
void putbyte(char a)
{
}
#endif