You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

128 lines
5.2 KiB

/*
3 years ago
* Copyright : (C) 2022 Phytium Information Technology, Inc.
* All Rights Reserved.
*
* This program is OPEN SOURCE software: you can redistribute it and/or modify it
* under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
* either version 1.0 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the Phytium Public License for more details.
*
*
!59 v0.4.0 更新 * Merge branch 'new_master' into 'new_master' * 发布前修改文档错误,添加配置项 * Merge branch '0.4.0_test' into 'new_master' * 修改部分readme * Merge branch 'test' into 'new_master' * test modified including readme.md sdkconfig ADD ft2004eg64 or 32 d20… * Merge branch 'release_1102' into 'new_master' * 添加例程图片和说明,补全部分例程的配置文件 * Merge branch 'v0.4.0release_11_04' into 'new_master' * V0.4.0release 11 04 * Merge branch '0_4_0_test' into 'new_master' * 完善部分测试例程,如adc,pcie等 * Merge branch 'release_1028' into 'new_master' * GPIO/SPI/SDIO/USB 等例程支持 E2000Q Demo 板,修复部分驱动中的bug * Merge branch 'rtt_1025' into 'new_master' * 以 f 开头重命名系统文件名,增加一键导出 RT-Thread BSP 的脚本,修改 Kconfig 适应 scons * Merge branch 'sync_1021' into 'new_master' * Merge branch 'pub_1021' into sync_1021 * Merge branch 'sata_0926' into 'new_master' * E2000 Sata控制器完善,适配demo板,对can的部分代码进行一些整理 * 新增soft pwm 与 sdk用户使用手册 * 新增soft pwm 与 sdk用户使用手册 * Merge branch 'sync_1019' into 'new_master' * Merge branch 'pub_1019' into sync_1019 * E2000支持USB XHCI, 支持轮询模式下获取键盘输入 * E2000支持USB XHCI, 支持轮询模式下获取键盘输入 * Merge branch 'dev' into 'new_master' * Gmac和Xmac bug解决 * Merge branch 'new_master' into 'new_master' * UART example add flaw control and ddma * Merge branch 'can_loopback_0915' into 'new_master' * 裸机can驱动完善 * Merge branch 'sync_0909' into 'new_master' * Merge branch 'pub_0909' into sync_0909 * Merge branch 'sata_0831' into 'new_master' * 完善Sata和Qspi的接口,增加博雅flash的quad读适配 * Merge branch 'new_master' into 'new_master' * release board commit * Merge branch 'adc_qspi_0824' into 'new_master' * Adc适配Freertos造成的裸机驱动修改 * add cherry usb * Merge branch 'sync_0827' into 'new_master' * Merge branch 'pub_0827' into sync_0827 * Merge branch 'sync' into 'new_master' * Merge branch 'sync' of https://gitlab.phytium.com.cn/zhugengyu/phytium… * Merge branch 'pub' into sync * Merge branch 'pub' into sync * Merge branch 'e2000q_adapt_0815' into 'new_master' * E2000q adapt pwm * 补充E2000测试例程(gpio_test/spi_ddma/spi_loopback),完成FT2004回归测试(sdmmc_cmd) * 补充E2000测试例程(gpio_test/spi_ddma/spi_loopback),完成FT2004回归测试(sdmmc_cmd) * Merge branch 'new_master' into 'new_master' * E2000Q 支持更新 * Merge branch 'readme_v' into 'new_master' * update files * Merge branch 'gitee_v0.3.0' into 'new_master' * !49 v0.3.0 更新 * Merge branch 'E2000_TEST' into 'new_master' * E2000 v0.3 发布 * Merge branch 'v0_2_0_gitee' into 'new_master' * Merge branch '0_2_0' into 'new_master' * build all, before push to gitee 0.2.0 * Merge branch 'gmac_phy_0526' into 'new_master' * 完善gmac驱动,完善裸机lwip测试,适配freertos的lwip测试 * Merge branch 'new_master' into 'new_master' * iic_timer_tacho * Merge branch 'debug_0609' into 'new_master' * 支持汇编调试打印,修改异常打印,增加例程用于异常调试 * Merge branch 'nand_0512' into 'new_master' * Nand 0512 * 重构SDIO驱动,支持SD 2.0协议和DMA读写 * 重构SDIO驱动,支持SD 2.0协议和DMA读写 * 合入Seamphore驱动,完成GDMA驱动重构 * 合入Seamphore驱动,完成GDMA驱动重构 * Merge branch 'pwm_0525' into 'new_master' * 重构CAN驱动,新增E2000 PWM、ADC驱动 * 合入DDMA驱动,新增DDMA+SPI回环例程,更新PR Check list和编码规范 * 合入DDMA驱动,新增DDMA+SPI回环例程,更新PR Check list和编码规范 * Merge branch 'new_master' into 'new_master' * fi2c_slave * Merge branch 'revert-425e915e' into 'new_master' * Revert "Merge branch 'revert' into 'new_master'" * Merge branch 'revert' into 'new_master' * revert version * Merge branch 'fi2c_0429' into 'new_master' * Fi2c 0429 * Merge branch 'new_master' into 'new_master' * add fi2c_master * Merge branch 'xmac_gmac' into 'new_master' * Gmac and Xmac Restruct * Merge branch 'new_gic' into 'new_master' * New gic * Merge branch 'spi_0413' into 'new_master' * 支持 LittleFS 和 Spiffs,新增 SPI 回环测试 * Merge branch '0_1_17' into 'new_master' * !40 Release v0.1.17 * Merge branch 'new_master' into 'new_master' * add uart file * Merge branch '0_1_17' into 'new_master' * v0.1.17发布前覆盖测试 * 解决Issue:I2C 驱动速度无法调节至3.4M * 解决Issue:I2C 驱动速度无法调节至3.4M * Merge branch 'wdt_restruct' into 'new_master' * watchdog驱动重构与验证 * Merge branch 'qspi' into 'new_master' * 重构QSPI驱动,解耦驱动和FLASH关联,完善功能特性支持和测试例程 * 重构芯片引脚控制和GPIO驱动,新增引脚控制相关例程 * 重构芯片引脚控制和GPIO驱动,新增引脚控制相关例程 * Merge branch 'ctest-pr-0317' into 'new_master' * redefine assert and shell cmd to support ctest * Merge branch 'openamp_update' into 'new_master' * Openamp update * Release v0.1.16, Support USB and SATA * Release v0.1.16, Support USB and SATA * Merge branch 'release_0218' into 'new_master' * Release 0.1.16 进行发布例程功能测试,修改许可证为Phytium Public License 1.0 * 合入FUSB和FXHCI驱动,支持通过FATFS读写U盘 * 合入FUSB和FXHCI驱动,支持通过FATFS读写U盘 * Merge branch 'back' into 'new_master' * 修改多核问题,删除glibc * Merge branch 'sata' into 'new_master' * add pcie & sata driver and example test * Merge branch 'rm_some_right' into 'new_master' * Rm some right
2 years ago
* FilePath: fdebug.h
3 years ago
* Date: 2021-04-07 09:53:07
* LastEditTime: 2022-02-17 18:04:58
* Description:  This files is for debug functions
*
* Modify History:
* Ver   Who        Date         Changes
* ----- ------     --------    --------------------------------------
*/
#ifndef BSP_COMMON_FT_DEBUG_H
#define BSP_COMMON_FT_DEBUG_H
#include <stdio.h>
#include "sdkconfig.h"
!59 v0.4.0 更新 * Merge branch &#39;new_master&#39; into &#39;new_master&#39; * 发布前修改文档错误,添加配置项 * Merge branch &#39;0.4.0_test&#39; into &#39;new_master&#39; * 修改部分readme * Merge branch &#39;test&#39; into &#39;new_master&#39; * test modified including readme.md sdkconfig ADD ft2004eg64 or 32 d20… * Merge branch &#39;release_1102&#39; into &#39;new_master&#39; * 添加例程图片和说明,补全部分例程的配置文件 * Merge branch &#39;v0.4.0release_11_04&#39; into &#39;new_master&#39; * V0.4.0release 11 04 * Merge branch &#39;0_4_0_test&#39; into &#39;new_master&#39; * 完善部分测试例程,如adc,pcie等 * Merge branch &#39;release_1028&#39; into &#39;new_master&#39; * GPIO/SPI/SDIO/USB 等例程支持 E2000Q Demo 板,修复部分驱动中的bug * Merge branch &#39;rtt_1025&#39; into &#39;new_master&#39; * 以 f 开头重命名系统文件名,增加一键导出 RT-Thread BSP 的脚本,修改 Kconfig 适应 scons * Merge branch &#39;sync_1021&#39; into &#39;new_master&#39; * Merge branch &#39;pub_1021&#39; into sync_1021 * Merge branch &#39;sata_0926&#39; into &#39;new_master&#39; * E2000 Sata控制器完善,适配demo板,对can的部分代码进行一些整理 * 新增soft pwm 与 sdk用户使用手册 * 新增soft pwm 与 sdk用户使用手册 * Merge branch &#39;sync_1019&#39; into &#39;new_master&#39; * Merge branch &#39;pub_1019&#39; into sync_1019 * E2000支持USB XHCI, 支持轮询模式下获取键盘输入 * E2000支持USB XHCI, 支持轮询模式下获取键盘输入 * Merge branch &#39;dev&#39; into &#39;new_master&#39; * Gmac和Xmac bug解决 * Merge branch &#39;new_master&#39; into &#39;new_master&#39; * UART example add flaw control and ddma * Merge branch &#39;can_loopback_0915&#39; into &#39;new_master&#39; * 裸机can驱动完善 * Merge branch &#39;sync_0909&#39; into &#39;new_master&#39; * Merge branch &#39;pub_0909&#39; into sync_0909 * Merge branch &#39;sata_0831&#39; into &#39;new_master&#39; * 完善Sata和Qspi的接口,增加博雅flash的quad读适配 * Merge branch &#39;new_master&#39; into &#39;new_master&#39; * release board commit * Merge branch &#39;adc_qspi_0824&#39; into &#39;new_master&#39; * Adc适配Freertos造成的裸机驱动修改 * add cherry usb * Merge branch &#39;sync_0827&#39; into &#39;new_master&#39; * Merge branch &#39;pub_0827&#39; into sync_0827 * Merge branch &#39;sync&#39; into &#39;new_master&#39; * Merge branch &#39;sync&#39; of https://gitlab.phytium.com.cn/zhugengyu/phytium… * Merge branch &#39;pub&#39; into sync * Merge branch &#39;pub&#39; into sync * Merge branch &#39;e2000q_adapt_0815&#39; into &#39;new_master&#39; * E2000q adapt pwm * 补充E2000测试例程(gpio_test/spi_ddma/spi_loopback),完成FT2004回归测试(sdmmc_cmd) * 补充E2000测试例程(gpio_test/spi_ddma/spi_loopback),完成FT2004回归测试(sdmmc_cmd) * Merge branch &#39;new_master&#39; into &#39;new_master&#39; * E2000Q 支持更新 * Merge branch &#39;readme_v&#39; into &#39;new_master&#39; * update files * Merge branch &#39;gitee_v0.3.0&#39; into &#39;new_master&#39; * !49 v0.3.0 更新 * Merge branch &#39;E2000_TEST&#39; into &#39;new_master&#39; * E2000 v0.3 发布 * Merge branch &#39;v0_2_0_gitee&#39; into &#39;new_master&#39; * Merge branch &#39;0_2_0&#39; into &#39;new_master&#39; * build all, before push to gitee 0.2.0 * Merge branch &#39;gmac_phy_0526&#39; into &#39;new_master&#39; * 完善gmac驱动,完善裸机lwip测试,适配freertos的lwip测试 * Merge branch &#39;new_master&#39; into &#39;new_master&#39; * iic_timer_tacho * Merge branch &#39;debug_0609&#39; into &#39;new_master&#39; * 支持汇编调试打印,修改异常打印,增加例程用于异常调试 * Merge branch &#39;nand_0512&#39; into &#39;new_master&#39; * Nand 0512 * 重构SDIO驱动,支持SD 2.0协议和DMA读写 * 重构SDIO驱动,支持SD 2.0协议和DMA读写 * 合入Seamphore驱动,完成GDMA驱动重构 * 合入Seamphore驱动,完成GDMA驱动重构 * Merge branch &#39;pwm_0525&#39; into &#39;new_master&#39; * 重构CAN驱动,新增E2000 PWM、ADC驱动 * 合入DDMA驱动,新增DDMA+SPI回环例程,更新PR Check list和编码规范 * 合入DDMA驱动,新增DDMA+SPI回环例程,更新PR Check list和编码规范 * Merge branch &#39;new_master&#39; into &#39;new_master&#39; * fi2c_slave * Merge branch &#39;revert-425e915e&#39; into &#39;new_master&#39; * Revert &#34;Merge branch &#39;revert&#39; into &#39;new_master&#39;&#34; * Merge branch &#39;revert&#39; into &#39;new_master&#39; * revert version * Merge branch &#39;fi2c_0429&#39; into &#39;new_master&#39; * Fi2c 0429 * Merge branch &#39;new_master&#39; into &#39;new_master&#39; * add fi2c_master * Merge branch &#39;xmac_gmac&#39; into &#39;new_master&#39; * Gmac and Xmac Restruct * Merge branch &#39;new_gic&#39; into &#39;new_master&#39; * New gic * Merge branch &#39;spi_0413&#39; into &#39;new_master&#39; * 支持 LittleFS 和 Spiffs,新增 SPI 回环测试 * Merge branch &#39;0_1_17&#39; into &#39;new_master&#39; * !40 Release v0.1.17 * Merge branch &#39;new_master&#39; into &#39;new_master&#39; * add uart file * Merge branch &#39;0_1_17&#39; into &#39;new_master&#39; * v0.1.17发布前覆盖测试 * 解决Issue:I2C 驱动速度无法调节至3.4M * 解决Issue:I2C 驱动速度无法调节至3.4M * Merge branch &#39;wdt_restruct&#39; into &#39;new_master&#39; * watchdog驱动重构与验证 * Merge branch &#39;qspi&#39; into &#39;new_master&#39; * 重构QSPI驱动,解耦驱动和FLASH关联,完善功能特性支持和测试例程 * 重构芯片引脚控制和GPIO驱动,新增引脚控制相关例程 * 重构芯片引脚控制和GPIO驱动,新增引脚控制相关例程 * Merge branch &#39;ctest-pr-0317&#39; into &#39;new_master&#39; * redefine assert and shell cmd to support ctest * Merge branch &#39;openamp_update&#39; into &#39;new_master&#39; * Openamp update * Release v0.1.16, Support USB and SATA * Release v0.1.16, Support USB and SATA * Merge branch &#39;release_0218&#39; into &#39;new_master&#39; * Release 0.1.16 进行发布例程功能测试,修改许可证为Phytium Public License 1.0 * 合入FUSB和FXHCI驱动,支持通过FATFS读写U盘 * 合入FUSB和FXHCI驱动,支持通过FATFS读写U盘 * Merge branch &#39;back&#39; into &#39;new_master&#39; * 修改多核问题,删除glibc * Merge branch &#39;sata&#39; into &#39;new_master&#39; * add pcie &amp; sata driver and example test * Merge branch &#39;rm_some_right&#39; into &#39;new_master&#39; * Rm some right
2 years ago
#include "ftypes.h"
typedef enum
{
FT_LOG_NONE, /* No log output */
FT_LOG_ERROR, /* Critical errors, software module can not recover on its own */
FT_LOG_WARN, /* Error conditions from which recovery measures have been taken */
FT_LOG_INFO, /* Information messages which describe normal flow of events */
FT_LOG_DEBUG, /* Extra information which is not necessary for normal use (values, pointers, sizes, etc). */
FT_LOG_VERBOSE /* Bigger chunks of debugging information, or frequent messages which can potentially flood the output. */
} ft_log_level_t;
#define LOG_COLOR_BLACK "30"
#define LOG_COLOR_RED "31"
#define LOG_COLOR_GREEN "32"
#define LOG_COLOR_BROWN "33"
#define LOG_COLOR_BLUE "34"
#define LOG_COLOR_PURPLE "35"
#define LOG_COLOR_CYAN "36"
#define LOG_COLOR(COLOR) "\033[0;" COLOR "m"
#define LOG_BOLD(COLOR) "\033[1;" COLOR "m"
#define LOG_RESET_COLOR "\033[0m"
#define LOG_COLOR_E LOG_COLOR(LOG_COLOR_RED)
#define LOG_COLOR_W LOG_COLOR(LOG_COLOR_BROWN)
#define LOG_COLOR_I LOG_COLOR(LOG_COLOR_GREEN)
2 years ago
#define LOG_COLOR_D LOG_COLOR(LOG_COLOR_CYAN)
#define LOG_COLOR_V LOG_COLOR(LOG_COLOR_PURPLE)
/* select debug log level */
3 years ago
#ifdef CONFIG_LOG_VERBOS
#define LOG_LOCAL_LEVEL FT_LOG_VERBOSE
3 years ago
#endif
3 years ago
#ifdef CONFIG_LOG_ERROR
#define LOG_LOCAL_LEVEL FT_LOG_ERROR
#endif
#ifdef CONFIG_LOG_WARN
#define LOG_LOCAL_LEVEL FT_LOG_WARN
#endif
#ifdef CONFIG_LOG_INFO
#define LOG_LOCAL_LEVEL FT_LOG_INFO
#endif
#ifdef CONFIG_LOG_DEBUG
#define LOG_LOCAL_LEVEL FT_LOG_DEBUG
#endif
#define LOG_FORMAT(letter, format) LOG_COLOR_##letter " %s: " format LOG_RESET_COLOR "\r\n"
#define PORT_KPRINTF printf
3 years ago
#ifndef CONFIG_LOG_EXTRA_INFO
#define LOG_EARLY_IMPL(tag, format, log_level, log_tag_letter, ...) \
do \
{ \
if (LOG_LOCAL_LEVEL < log_level) \
break; \
PORT_KPRINTF(LOG_FORMAT(log_tag_letter, format), tag, ##__VA_ARGS__); \
} while (0)
3 years ago
#else
2 years ago
#include <string.h>
#define __FILENAME__ (strrchr(__FILE__, '/') ? (strrchr(__FILE__, '/') + 1):__FILE__)
3 years ago
/* print debug information with source file name and source code line num. */
#define LOG_EARLY_IMPL(tag, format, log_level, log_tag_letter, ...) \
do \
{ \
if (LOG_LOCAL_LEVEL < log_level) \
break; \
PORT_KPRINTF(LOG_FORMAT(log_tag_letter, format" @%s:%d"), tag, ##__VA_ARGS__, __FILENAME__, __LINE__); \
} while (0)
#endif
#define EARLY_LOGE(tag, format, ...) LOG_EARLY_IMPL(tag, format, FT_LOG_ERROR, E, ##__VA_ARGS__)
#define EARLY_LOGI(tag, format, ...) LOG_EARLY_IMPL(tag, format, FT_LOG_INFO, I, ##__VA_ARGS__)
#define EARLY_LOGD(tag, format, ...) LOG_EARLY_IMPL(tag, format, FT_LOG_DEBUG, D, ##__VA_ARGS__)
#define EARLY_LOGW(tag, format, ...) LOG_EARLY_IMPL(tag, format, FT_LOG_WARN, W, ##__VA_ARGS__)
#define EARLY_LOGV(tag, format, ...) LOG_EARLY_IMPL(tag, format, FT_LOG_VERBOSE, W, ##__VA_ARGS__)
/* do not compile log if define CONFIG_LOG_NONE */
#ifndef CONFIG_LOG_NONE
#define FT_DEBUG_PRINT_I(TAG, format, ...) EARLY_LOGI(TAG, format, ##__VA_ARGS__)
#define FT_DEBUG_PRINT_E(TAG, format, ...) EARLY_LOGE(TAG, format, ##__VA_ARGS__)
#define FT_DEBUG_PRINT_D(TAG, format, ...) EARLY_LOGD(TAG, format, ##__VA_ARGS__)
#define FT_DEBUG_PRINT_W(TAG, format, ...) EARLY_LOGW(TAG, format, ##__VA_ARGS__)
#define FT_DEBUG_PRINT_V(TAG, format, ...) EARLY_LOGV(TAG, format, ##__VA_ARGS__)
#else
#define FT_DEBUG_PRINT_I(TAG, format, ...)
#define FT_DEBUG_PRINT_E(TAG, format, ...)
#define FT_DEBUG_PRINT_D(TAG, format, ...)
#define FT_DEBUG_PRINT_W(TAG, format, ...)
#define FT_DEBUG_PRINT_V(TAG, format, ...)
#endif
#define FT_RAW_PRINTF(format, ...) PORT_KPRINTF(format, ##__VA_ARGS__)
void FtDumpHexWord(const u32 *ptr, u32 buflen);
void FtDumpHexByte(const u8 *ptr, u32 buflen);
#endif // !