From 2d59fe031038e94dd626f3b172653bcb9bab9a2d Mon Sep 17 00:00:00 2001 From: armink Date: Mon, 29 Oct 2018 09:49:12 +0800 Subject: [DeviceDriver] Add power management device driver. --- examples/pm/timer_app.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 examples/pm/timer_app.c (limited to 'examples') diff --git a/examples/pm/timer_app.c b/examples/pm/timer_app.c new file mode 100644 index 0000000000..73faf52d0a --- /dev/null +++ b/examples/pm/timer_app.c @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2018-08-07 Tanek first implementation + */ + +#include +#include +#include + +#ifndef RT_USING_TIMER_SOFT + #error "Please enable soft timer feature!" +#endif + +#define TIMER_APP_DEFAULT_TICK (RT_TICK_PER_SECOND * 2) + +#ifdef RT_USING_PM + +static rt_timer_t timer1; + +static void _timeout_entry(void *parameter) +{ + rt_kprintf("current tick: %ld\n", rt_tick_get()); +} + +static int timer_app_init(void) +{ + timer1 = rt_timer_create("timer_app", + _timeout_entry, + RT_NULL, + TIMER_APP_DEFAULT_TICK, + RT_TIMER_FLAG_PERIODIC | RT_TIMER_FLAG_SOFT_TIMER); + if (timer1 != RT_NULL) + { + rt_timer_start(timer1); + + /* keep in timer mode */ + rt_pm_request(PM_SLEEP_MODE_TIMER); + + return 0; + } + else + { + return -1; + } +} +INIT_EXPORT_APP(timer_app_init); + +#endif /* RT_USING_PM */ + -- cgit v1.3.1 From 12a803bcc90fde7ca74a7a1d295d7929fe9b1ab3 Mon Sep 17 00:00:00 2001 From: armink Date: Tue, 30 Oct 2018 09:00:30 +0800 Subject: [component] Add ulog logger basic component. --- components/utilities/Kconfig | 180 ++++ components/utilities/ulog/SConscript | 16 + components/utilities/ulog/backend/console_be.c | 56 ++ components/utilities/ulog/syslog/syslog.c | 260 ++++++ components/utilities/ulog/syslog/syslog.h | 100 ++ components/utilities/ulog/ulog.c | 1152 ++++++++++++++++++++++++ components/utilities/ulog/ulog.h | 95 ++ components/utilities/ulog/ulog_def.h | 189 ++++ examples/ulog/ulog_example.c | 93 ++ 9 files changed, 2141 insertions(+) create mode 100644 components/utilities/ulog/SConscript create mode 100644 components/utilities/ulog/backend/console_be.c create mode 100644 components/utilities/ulog/syslog/syslog.c create mode 100644 components/utilities/ulog/syslog/syslog.h create mode 100644 components/utilities/ulog/ulog.c create mode 100644 components/utilities/ulog/ulog.h create mode 100644 components/utilities/ulog/ulog_def.h create mode 100644 examples/ulog/ulog_example.c (limited to 'examples') diff --git a/components/utilities/Kconfig b/components/utilities/Kconfig index 09ab2cfe8e..45e0791c9e 100644 --- a/components/utilities/Kconfig +++ b/components/utilities/Kconfig @@ -46,4 +46,184 @@ config RT_USING_RYM bool "Enable Ymodem" default n +config RT_USING_ULOG + bool "Enable ulog" + default n + + if RT_USING_ULOG + if !ULOG_USING_SYSLOG + choice + prompt "The static output log level." + default ULOG_OUTPUT_LVL_DEBUG + help + When the log level is less than this option and it will stop output. + These log will not compile into ROM when using LOG_X api. + NOTE: It's not available on syslog mode. + config ULOG_OUTPUT_LVL_ASSERT + bool "Assert" + config ULOG_OUTPUT_LVL_ERROR + bool "Error" + config ULOG_OUTPUT_LVL_WARNING + bool "Warning" + config ULOG_OUTPUT_LVL_INFO + bool "Information" + config ULOG_OUTPUT_LVL_DEBUG + bool "Debug" + endchoice + endif + + if ULOG_USING_SYSLOG + choice + prompt "The static output log level." + default ULOG_OUTPUT_LVL_DEBUG + help + When the log level is less than this option and it will stop output. + These log will not compile into ROM when using LOG_X api. + NOTE: It's not available on syslog mode. + config ULOG_OUTPUT_LVL_EMERG + bool "EMERG" + config ULOG_OUTPUT_LVL_ALERT + bool "ALERT" + config ULOG_OUTPUT_LVL_CRIT + bool "CRIT" + config ULOG_OUTPUT_LVL_ERROR + bool "ERR" + config ULOG_OUTPUT_LVL_WARNING + bool "WARNING" + config ULOG_OUTPUT_LVL_NOTICE + bool "NOTICE" + config ULOG_OUTPUT_LVL_INFO + bool "INFO" + config ULOG_OUTPUT_LVL_DEBUG + bool "DEBUG" + endchoice + endif + + config ULOG_OUTPUT_LVL + int + default 0 if ULOG_OUTPUT_LVL_ASSERT + default 0 if ULOG_OUTPUT_LVL_EMERG + default 1 if ULOG_OUTPUT_LVL_ALERT + default 2 if ULOG_OUTPUT_LVL_CRIT + default 3 if ULOG_OUTPUT_LVL_ERROR + default 4 if ULOG_OUTPUT_LVL_WARNING + default 5 if ULOG_OUTPUT_LVL_NOTICE + default 6 if ULOG_OUTPUT_LVL_INFO + default 7 if ULOG_OUTPUT_LVL_DEBUG + default 7 + + config ULOG_USING_ISR_LOG + bool "Enable ISR log." + default n + help + The log output API can using in ISR (Interrupt Service Routines) also. + + config ULOG_ASSERT_ENABLE + bool "Enable assert check." + default y + + config ULOG_LINE_BUF_SIZE + int "The log's max width." + default 128 + help + The buffer size for every line log. + + config ULOG_USING_ASYNC_OUTPUT + bool "Enable async output mode." + default n + help + When enable asynchronous output mode. The log output is not immediately and the log will stored to buffer. + The another thread (Such as idle) will read the buffer and output the log. So it will using more RAM. + + if ULOG_USING_ASYNC_OUTPUT + config ULOG_ASYNC_OUTPUT_BUF_SIZE + int "The async output buffer size." + default 2048 + + config ULOG_ASYNC_OUTPUT_BY_THREAD + bool "Enable async output by thread." + default y + help + This thread will output the asynchronous logs. The logs can output by other user thread when this option is disable. + + if ULOG_ASYNC_OUTPUT_BY_THREAD + + config ULOG_ASYNC_OUTPUT_THREAD_STACK + int "The async output thread stack size." + default 1024 + + config ULOG_ASYNC_OUTPUT_THREAD_PRIORITY + int "The async output thread stack priority." + range 0 RT_THREAD_PRIORITY_MAX + default 30 + + endif + endif + + menu "log format" + config ULOG_OUTPUT_FLOAT + bool "Enable float number support." + select RT_USING_LIBC + default n + help + The default formater is using rt_vsnprint and it not supported float number. + When enable this option then it will enable libc. The formater will change to vsnprint on libc. + + if !ULOG_USING_SYSLOG + config ULOG_USING_COLOR + bool "Enable color log." + default y + help + The log will has different color by level. + endif + + config ULOG_OUTPUT_TIME + bool "Enable time information." + default y + + config ULOG_TIME_USING_TIMESTAMP + bool "Enable timestamp format for time." + default n + select RT_USING_LIBC + depends on ULOG_OUTPUT_TIME + + config ULOG_OUTPUT_LEVEL + bool "Enable level information." + default y + + config ULOG_OUTPUT_TAG + bool "Enable tag information." + default y + + config ULOG_OUTPUT_THREAD_NAME + bool "Enable thread information." + default n + endmenu + + config ULOG_BACKEND_USING_CONSOLE + bool "Enable console backend." + default y + help + The low level output using rt_kprintf(). + + config ULOG_USING_FILTER + bool "Enable runtime log filter." + default n + help + It will enable the log filter. + Such as level filter, log tag filter, log kw filter and tag's level filter. + + config ULOG_USING_SYSLOG + bool "Enable syslog format log and API." + select ULOG_OUTPUT_TIME + select ULOG_USING_FILTER + default n + + config ULOG_SW_VERSION_NUM + int + default 0x00100 + help + sfotware module version number + endif + endmenu diff --git a/components/utilities/ulog/SConscript b/components/utilities/ulog/SConscript new file mode 100644 index 0000000000..03ea1b5528 --- /dev/null +++ b/components/utilities/ulog/SConscript @@ -0,0 +1,16 @@ +from building import * + +cwd = GetCurrentDir() +src = Glob('*.c') +path = [cwd] + +if GetDepend('ULOG_BACKEND_USING_CONSOLE'): + src += ['backend/console_be.c'] + +if GetDepend('ULOG_USING_SYSLOG'): + path += [cwd + '/syslog'] + src += Glob('syslog/*.c') + +group = DefineGroup('Utilities', src, depend = ['RT_USING_ULOG'], CPPPATH = path) + +Return('group') diff --git a/components/utilities/ulog/backend/console_be.c b/components/utilities/ulog/backend/console_be.c new file mode 100644 index 0000000000..b2ed3d565d --- /dev/null +++ b/components/utilities/ulog/backend/console_be.c @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2018-09-04 armink the first version + */ + +#include +#include + +#ifdef ULOG_BACKEND_USING_CONSOLE + +#if defined(ULOG_ASYNC_OUTPUT_BY_THREAD) && ULOG_ASYNC_OUTPUT_THREAD_STACK < 384 +#error "The thread stack size must more than 384 when using async output by thread (ULOG_ASYNC_OUTPUT_BY_THREAD)" +#endif + +static struct ulog_backend console; + +void ulog_console_backend_output(struct ulog_backend *backend, rt_uint32_t level, const char *tag, rt_bool_t is_raw, + const char *log, size_t len) +{ + rt_device_t dev = rt_console_get_device(); + +#ifdef RT_USING_DEVICE + if (dev == RT_NULL) + { + rt_hw_console_output(log); + } + else + { + rt_uint16_t old_flag = dev->open_flag; + + dev->open_flag |= RT_DEVICE_FLAG_STREAM; + rt_device_write(dev, 0, log, len); + dev->open_flag = old_flag; + } +#else + rt_hw_console_output(log); +#endif + +} + +int ulog_console_backend_init(void) +{ + console.output = ulog_console_backend_output; + + ulog_backend_register(&console, "console", RT_TRUE); + + return 0; +} +INIT_COMPONENT_EXPORT(ulog_console_backend_init); + +#endif /* ULOG_BACKEND_USING_CONSOLE */ diff --git a/components/utilities/ulog/syslog/syslog.c b/components/utilities/ulog/syslog/syslog.c new file mode 100644 index 0000000000..0df99c77f2 --- /dev/null +++ b/components/utilities/ulog/syslog/syslog.c @@ -0,0 +1,260 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2018-09-07 armink the first version + */ + +#include +#include +#include +#include "syslog.h" + +#ifdef ULOG_OUTPUT_FLOAT +#include +#endif + +/* + * reference: + * http://pubs.opengroup.org/onlinepubs/7908799/xsh/syslog.h.html + * https://www.gnu.org/software/libc/manual/html_node/Submitting-Syslog-Messages.html + * http://man7.org/linux/man-pages/man3/syslog.3.html + */ + +#ifdef ULOG_USING_SYSLOG + +#ifndef ULOG_SYSLOG_IDENT_MAX_LEN +#define ULOG_SYSLOG_IDENT_MAX_LEN ULOG_FILTER_TAG_MAX_LEN +#endif + +static char local_ident[ULOG_SYSLOG_IDENT_MAX_LEN + 1]; +static int local_facility = LOG_USER; +static int local_option = LOG_USER; +static rt_bool_t is_open = RT_FALSE; + +/** + * open connection to syslog + * + * @param ident is an arbitrary identification string which future syslog invocations will prefix to each message. + * @param option is not using on ulog. + * @param facility is the default facility code for this connection. + */ +void openlog(const char *ident, int option, int facility) +{ + rt_base_t level; + + ulog_init(); + + level = rt_hw_interrupt_disable(); + + rt_memset(local_ident, 0, sizeof(local_ident)); + if (ident) + { + rt_strncpy(local_ident, ident, ULOG_SYSLOG_IDENT_MAX_LEN); + } + else + { + rt_strncpy(local_ident, "rtt", ULOG_SYSLOG_IDENT_MAX_LEN); + } + + local_option = option; + + if (facility) + { + local_facility = facility; + } + else + { + /* default facility is LOG_USER */ + local_facility = LOG_USER; + } + /* output all level log */ + setlogmask(LOG_UPTO(LOG_DEBUG)); + + is_open = RT_TRUE; + + rt_hw_interrupt_enable(level); + +} + +/** + * This is functionally identical to syslog. + * + * @param priority log priority, can be generated by the macro LOG_MAKEPRI + * @param format log format + * @param args log arguments + */ +void vsyslog(int priority, const char *format, va_list args) +{ + if (LOG_FAC(priority) == 0) + { + /* using local facility */ + priority |= local_facility; + } + + ulog_voutput(priority, local_ident, format, args); +} + +/** + * generates a log message + * + * @param priority log priority, can be generated by the macro LOG_MAKEPRI + * @param format log format, like printf() + */ +void syslog(int priority, const char *format, ...) +{ + va_list args; + + if (!is_open) + { + openlog(0, 0, 0); + } + /* args point to the first variable parameter */ + va_start(args, format); + + vsyslog(priority, format, args); + + va_end(args); +} + +/** + * close the syslog + */ +void closelog(void) +{ + ulog_deinit(); + + is_open = RT_FALSE; +} + +/** + * set log priority mask + * + * @param mask The log priority mask which generate by macro LOG_MASK and LOG_UPTO. + * + * @return This function returns the previous log priority mask. + */ +int setlogmask(int mask) +{ + static int old_mask = 0; + int return_mask = old_mask; + + ulog_tag_lvl_filter_set(local_ident, mask); + + old_mask = mask; + + return return_mask; +} + +static const char *get_month_str(uint8_t month) +{ + switch(month) + { + case 1: return "Jan"; + case 2: return "Feb"; + case 3: return "Mar"; + case 4: return "Apr"; + case 5: return "May"; + case 6: return "June"; + case 7: return "July"; + case 8: return "Aug"; + case 9: return "Sept"; + case 10: return "Oct"; + case 11: return "Nov"; + case 12: return "Dec"; + default: return "Unknown"; + } +} + +RT_WEAK rt_size_t syslog_formater(char *log_buf, int level, const char *tag, const char *format, va_list args) +{ + extern size_t ulog_strcpy(size_t cur_len, char *dst, const char *src); + + rt_size_t log_len = 0, newline_len = rt_strlen(ULOG_NEWLINE_SIGN); + int fmt_result; + + RT_ASSERT(log_buf); + RT_ASSERT(LOG_PRI(level) <= LOG_DEBUG); + RT_ASSERT(tag); + RT_ASSERT(format); + + /* add time and priority (level) info */ + { + time_t now = time(RT_NULL); + struct tm *tm, tm_tmp; + + tm = gmtime_r(&now, &tm_tmp); + +#ifdef ULOG_OUTPUT_LEVEL + rt_snprintf(log_buf + log_len, ULOG_LINE_BUF_SIZE - log_len, "<%d>%s%3d %02d:%02d:%02d", level, + get_month_str(tm->tm_mon + 1), tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, rt_tick_get() % 1000); +#else + rt_snprintf(log_buf + log_len, ULOG_LINE_BUF_SIZE - log_len, "%s%3d %02d:%02d:%02d", + get_month_str(tm->tm_mon + 1), tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, rt_tick_get() % 1000); +#endif /* ULOG_OUTPUT_LEVEL */ + + log_len += rt_strlen(log_buf + log_len); + } + +#ifdef ULOG_OUTPUT_TAG + /* add identification (tag) info */ + { + log_len += ulog_strcpy(log_len, log_buf + log_len, " "); + log_len += ulog_strcpy(log_len, log_buf + log_len, tag); + } +#endif /* ULOG_OUTPUT_TAG */ + +#ifdef ULOG_OUTPUT_THREAD_NAME + /* add thread info */ + { + log_len += ulog_strcpy(log_len, log_buf + log_len, " "); + /* is not in interrupt context */ + if (rt_interrupt_get_nest() == 0) + { + log_len += ulog_strcpy(log_len, log_buf + log_len, rt_thread_self()->name); + } + else + { + log_len += ulog_strcpy(log_len, log_buf + log_len, "ISR"); + } + } +#endif /* ULOG_OUTPUT_THREAD_NAME */ + + log_len += ulog_strcpy(log_len, log_buf + log_len, ": "); + +#ifdef ULOG_OUTPUT_FLOAT + fmt_result = vsnprintf(log_buf + log_len, ULOG_LINE_BUF_SIZE - log_len, format, args); +#else + fmt_result = rt_vsnprintf(log_buf + log_len, ULOG_LINE_BUF_SIZE - log_len, format, args); +#endif /* ULOG_OUTPUT_FLOAT */ + + /* calculate log length */ + if ((log_len + fmt_result <= ULOG_LINE_BUF_SIZE) && (fmt_result > -1)) + { + log_len += fmt_result; + } + else + { + /* using max length */ + log_len = ULOG_LINE_BUF_SIZE; + } + + /* overflow check and reserve some space for newline sign */ + if (log_len + newline_len > ULOG_LINE_BUF_SIZE) + { + /* using max length */ + log_len = ULOG_LINE_BUF_SIZE; + /* reserve some space for newline sign */ + log_len -= newline_len; + } + + /* package newline sign */ + log_len += ulog_strcpy(log_len, log_buf + log_len, ULOG_NEWLINE_SIGN); + + return log_len; +} + +#endif /* ULOG_USING_SYSLOG */ diff --git a/components/utilities/ulog/syslog/syslog.h b/components/utilities/ulog/syslog/syslog.h new file mode 100644 index 0000000000..43eec7125f --- /dev/null +++ b/components/utilities/ulog/syslog/syslog.h @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2018-09-07 armink the first version + */ + +#ifndef _SYSLOG_H_ +#define _SYSLOG_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * priorities/facilities are encoded into a single 32-bit quantity, where the + * bottom 3 bits are the priority (0-7) and the top 28 bits are the facility + * (0-big number). Both the priorities and the facilities map roughly + * one-to-one to strings in the syslogd(8) source code. This mapping is + * included in this file. + * + * priorities (these are ordered) + */ +#define LOG_EMERG 0 /* system is unusable */ +#define LOG_ALERT 1 /* action must be taken immediately */ +#define LOG_CRIT 2 /* critical conditions */ +#define LOG_ERR 3 /* error conditions */ +#define LOG_WARNING 4 /* warning conditions */ +#define LOG_NOTICE 5 /* normal but significant condition */ +#define LOG_INFO 6 /* informational */ +#define LOG_DEBUG 7 /* debug-level messages */ + +#define LOG_PRIMASK 0x07 + +#define LOG_PRI(p) ((p) & LOG_PRIMASK) +#define LOG_MAKEPRI(fac, pri) (((fac) << 3) | (pri)) + +/* facility codes */ +#define LOG_KERN (0<<3) /* kernel messages */ +#define LOG_USER (1<<3) /* random user-level messages */ +#define LOG_MAIL (2<<3) /* mail system */ +#define LOG_DAEMON (3<<3) /* system daemons */ +#define LOG_AUTH (4<<3) /* security/authorization messages */ +#define LOG_SYSLOG (5<<3) /* messages generated internally by syslogd */ +#define LOG_LPR (6<<3) /* line printer subsystem */ +#define LOG_NEWS (7<<3) /* network news subsystem */ +#define LOG_UUCP (8<<3) /* UUCP subsystem */ +#define LOG_CRON (9<<3) /* clock daemon */ +#define LOG_AUTHPRIV (10<<3) /* security/authorization messages (private) */ + +/* other codes through 15 reserved for system use */ +#define LOG_LOCAL0 (16<<3) /* reserved for local use */ +#define LOG_LOCAL1 (17<<3) /* reserved for local use */ +#define LOG_LOCAL2 (18<<3) /* reserved for local use */ +#define LOG_LOCAL3 (19<<3) /* reserved for local use */ +#define LOG_LOCAL4 (20<<3) /* reserved for local use */ +#define LOG_LOCAL5 (21<<3) /* reserved for local use */ +#define LOG_LOCAL6 (22<<3) /* reserved for local use */ +#define LOG_LOCAL7 (23<<3) /* reserved for local use */ + +#define LOG_NFACILITIES 24 /* current number of facilities */ +#define LOG_FACMASK 0x03f8 /* mask to extract facility part */ +/* facility of pri */ +#define LOG_FAC(p) (((p) & LOG_FACMASK) >> 3) + +/* + * arguments to setlogmask. + */ +#define LOG_MASK(pri) (1 << (pri)) /* mask for one priority */ +#define LOG_UPTO(pri) ((1 << ((pri)+1)) - 1) /* all priorities through pri */ + +/* + * Option flags for openlog. + * + * LOG_ODELAY no longer does anything. + * LOG_NDELAY is the inverse of what it used to be. + */ +#define LOG_PID 0x01 /* log the pid with each message */ +#define LOG_CONS 0x02 /* log on the console if errors in sending */ +#define LOG_ODELAY 0x04 /* delay open until first syslog() (default) */ +#define LOG_NDELAY 0x08 /* don't delay open */ +#define LOG_NOWAIT 0x10 /* don't wait for console forks: DEPRECATED */ +#define LOG_PERROR 0x20 /* log to stderr as well */ + +#include + +void closelog(void); +void openlog(const char *ident, int option, int facility); +int setlogmask(int mask); +void syslog(int priority, const char *format, ...); +void vsyslog(int priority, const char *format, va_list args); + +#ifdef __cplusplus +} +#endif + +#endif /* _SYSLOG_H_ */ diff --git a/components/utilities/ulog/ulog.c b/components/utilities/ulog/ulog.c new file mode 100644 index 0000000000..2f950fe0d9 --- /dev/null +++ b/components/utilities/ulog/ulog.c @@ -0,0 +1,1152 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2018-08-25 armink the first version + */ + +#include +#include "ulog.h" +#include "rthw.h" + +#ifdef ULOG_USING_SYSLOG +#include +#endif + +#ifdef ULOG_OUTPUT_FLOAT +#include +#endif + +#ifdef ULOG_TIME_USING_TIMESTAMP +#include +#endif + +#ifdef ULOG_USING_ASYNC_OUTPUT +#include +#endif + +#ifdef RT_USING_ULOG + +/* the number which is max stored line logs */ +#ifndef ULOG_ASYNC_OUTPUT_STORE_LINES +#define ULOG_ASYNC_OUTPUT_STORE_LINES (ULOG_ASYNC_OUTPUT_BUF_SIZE * 3 / 2 / ULOG_LINE_BUF_SIZE) +#endif + +#ifdef ULOG_USING_COLOR +/** + * CSI(Control Sequence Introducer/Initiator) sign + * more information on https://en.wikipedia.org/wiki/ANSI_escape_code + */ +#define CSI_START "\033[" +#define CSI_END "\033[0m" +/* output log front color */ +#define F_BLACK "30m" +#define F_RED "31m" +#define F_GREEN "32m" +#define F_YELLOW "33m" +#define F_BLUE "34m" +#define F_MAGENTA "35m" +#define F_CYAN "36m" +#define F_WHITE "37m" + +/* output log default color definition */ +#ifndef ULOG_COLOR_DEBUG +#define ULOG_COLOR_DEBUG NULL +#endif +#ifndef ULOG_COLOR_INFO +#define ULOG_COLOR_INFO (F_GREEN) +#endif +#ifndef ULOG_COLOR_WARN +#define ULOG_COLOR_WARN (F_YELLOW) +#endif +#ifndef ULOG_COLOR_ERROR +#define ULOG_COLOR_ERROR (F_RED) +#endif +#ifndef ULOG_COLOR_ASSERT +#define ULOG_COLOR_ASSERT (F_MAGENTA) +#endif +#endif /* ULOG_USING_COLOR */ + +#if ULOG_LINE_BUF_SIZE < 80 +#error "the log line buffer size must more than 80" +#endif + +/* tag's level filter */ +struct tag_lvl_filter +{ + char tag[ULOG_FILTER_TAG_MAX_LEN + 1]; + rt_uint32_t level; + rt_slist_t list; +}; +typedef struct tag_lvl_filter *tag_lvl_filter_t; + +struct rt_ulog +{ + rt_bool_t init_ok; + struct rt_mutex output_locker; + /* all backends */ + rt_slist_t backend_list; + /* the thread log's line buffer */ + char log_buf_th[ULOG_LINE_BUF_SIZE]; + +#ifdef ULOG_USING_ISR_LOG + /* the ISR log's line buffer */ + rt_base_t output_locker_isr_lvl; + char log_buf_isr[ULOG_LINE_BUF_SIZE]; +#endif /* ULOG_USING_ISR_LOG */ + +#ifdef ULOG_USING_ASYNC_OUTPUT + rt_rbb_t async_rbb; + rt_thread_t async_th; + struct rt_semaphore async_notice; +#endif + +#ifdef ULOG_USING_FILTER + struct + { + /* all tag's level filter */ + rt_slist_t tag_lvl_list; + /* global filter level, tag and keyword */ + rt_uint32_t level; + char tag[ULOG_FILTER_TAG_MAX_LEN + 1]; + char keyword[ULOG_FILTER_KW_MAX_LEN + 1]; + } filter; +#endif /* ULOG_USING_FILTER */ +}; + +/* level output info */ +static const char * const level_output_info[] = +{ + "A/", + NULL, + NULL, + "E/", + "W/", + NULL, + "I/", + "D/", +}; + +#ifdef ULOG_USING_COLOR +/* color output info */ +static const char * const color_output_info[] = +{ + ULOG_COLOR_ASSERT, + NULL, + NULL, + ULOG_COLOR_ERROR, + ULOG_COLOR_WARN, + NULL, + ULOG_COLOR_INFO, + ULOG_COLOR_DEBUG, +}; +#endif /* ULOG_USING_COLOR */ + +/* ulog local object */ +static struct rt_ulog ulog = { 0 }; + +size_t ulog_strcpy(size_t cur_len, char *dst, const char *src) +{ + const char *src_old = src; + + RT_ASSERT(dst); + RT_ASSERT(src); + + while (*src != 0) + { + /* make sure destination has enough space */ + if (cur_len++ <= ULOG_LINE_BUF_SIZE) + { + *dst++ = *src++; + } + else + { + break; + } + } + return src - src_old; +} + +static void output_unlock(void) +{ + /* is in thread context */ + if (rt_interrupt_get_nest() == 0) + { + rt_mutex_release(&ulog.output_locker); + } + else + { +#ifdef ULOG_USING_ISR_LOG + rt_hw_interrupt_enable(ulog.output_locker_isr_lvl); +#endif + } +} + +static void output_lock(void) +{ + /* is in thread context */ + if (rt_interrupt_get_nest() == 0) + { + rt_mutex_take(&ulog.output_locker, RT_WAITING_FOREVER); + } + else + { +#ifdef ULOG_USING_ISR_LOG + ulog.output_locker_isr_lvl = rt_hw_interrupt_disable(); +#endif + } +} + +static char *get_log_buf(void) +{ + /* is in thread context */ + if (rt_interrupt_get_nest() == 0) + { + return ulog.log_buf_th; + } + else + { +#ifdef ULOG_USING_ISR_LOG + return ulog.log_buf_isr; +#else + rt_kprintf("Error: Current mode not supported run in ISR. Please enable ULOG_USING_ISR_LOG.\n"); + return NULL; +#endif + } +} + +RT_WEAK rt_size_t ulog_formater(char *log_buf, rt_uint32_t level, const char *tag, const char *format, va_list args) +{ + rt_size_t log_len = 0, newline_len = rt_strlen(ULOG_NEWLINE_SIGN); + int fmt_result; + + RT_ASSERT(log_buf); + RT_ASSERT(level <= LOG_LVL_DBG); + RT_ASSERT(tag); + RT_ASSERT(format); + +#ifdef ULOG_USING_COLOR + /* add CSI start sign and color info */ + if (color_output_info[level]) + { + log_len += ulog_strcpy(log_len, log_buf + log_len, CSI_START); + log_len += ulog_strcpy(log_len, log_buf + log_len, color_output_info[level]); + } +#endif /* ULOG_USING_COLOR */ + +#ifdef ULOG_OUTPUT_TIME + /* add time info */ + { +#ifdef ULOG_TIME_USING_TIMESTAMP + time_t now = time(NULL); + struct tm *tm, tm_tmp; + + tm = gmtime_r(&now, &tm_tmp); + +#ifdef RT_USING_SOFT_RTC + rt_snprintf(log_buf + log_len, ULOG_LINE_BUF_SIZE - log_len, "%02d-%02d %02d:%02d:%02d.%03d", tm->tm_mon + 1, + tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, rt_tick_get() % 1000); +#else + rt_snprintf(log_buf + log_len, ULOG_LINE_BUF_SIZE - log_len, "%02d-%02d %02d:%02d:%02d", tm->tm_mon + 1, + tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); +#endif /* RT_USING_SOFT_RTC */ + +#else + rt_snprintf(log_buf + log_len, ULOG_LINE_BUF_SIZE - log_len, "[%d]", rt_tick_get()); +#endif /* ULOG_TIME_USING_TIMESTAMP */ + + log_len += rt_strlen(log_buf + log_len); + } +#endif /* ULOG_OUTPUT_TIME */ + +#ifdef ULOG_OUTPUT_LEVEL + +#ifdef ULOG_OUTPUT_TIME + log_len += ulog_strcpy(log_len, log_buf + log_len, " "); +#endif + + /* add level info */ + log_len += ulog_strcpy(log_len, log_buf + log_len, level_output_info[level]); +#endif /* ULOG_OUTPUT_LEVEL */ + +#ifdef ULOG_OUTPUT_TAG + +#if !defined(ULOG_OUTPUT_LEVEL) && defined(ULOG_OUTPUT_TIME) + log_len += ulog_strcpy(log_len, log_buf + log_len, " "); +#endif + + /* add tag info */ + log_len += ulog_strcpy(log_len, log_buf + log_len, tag); +#endif /* ULOG_OUTPUT_TAG */ + +#ifdef ULOG_OUTPUT_THREAD_NAME + /* add thread info */ + { + +#if defined(ULOG_OUTPUT_TIME) || defined(ULOG_OUTPUT_LEVEL) || defined(ULOG_OUTPUT_TAG) + log_len += ulog_strcpy(log_len, log_buf + log_len, " "); +#endif + + /* is not in interrupt context */ + if (rt_interrupt_get_nest() == 0) + { + log_len += ulog_strcpy(log_len, log_buf + log_len, rt_thread_self()->name); + } + else + { + log_len += ulog_strcpy(log_len, log_buf + log_len, "ISR"); + } + } +#endif /* ULOG_OUTPUT_THREAD_NAME */ + + log_len += ulog_strcpy(log_len, log_buf + log_len, ": "); + +#ifdef ULOG_OUTPUT_FLOAT + fmt_result = vsnprintf(log_buf + log_len, ULOG_LINE_BUF_SIZE - log_len, format, args); +#else + fmt_result = rt_vsnprintf(log_buf + log_len, ULOG_LINE_BUF_SIZE - log_len, format, args); +#endif /* ULOG_OUTPUT_FLOAT */ + + /* calculate log length */ + if ((log_len + fmt_result <= ULOG_LINE_BUF_SIZE) && (fmt_result > -1)) + { + log_len += fmt_result; + } + else + { + /* using max length */ + log_len = ULOG_LINE_BUF_SIZE; + } + + /* overflow check and reserve some space for CSI end sign and newline sign */ +#ifdef ULOG_USING_COLOR + if (log_len + (sizeof(CSI_END) - 1) + newline_len > ULOG_LINE_BUF_SIZE) + { + /* using max length */ + log_len = ULOG_LINE_BUF_SIZE; + /* reserve some space for CSI end sign */ + log_len -= (sizeof(CSI_END) - 1); +#else + if (log_len + newline_len > ULOG_LINE_BUF_SIZE) + { + /* using max length */ + log_len = ULOG_LINE_BUF_SIZE; +#endif /* ULOG_USING_COLOR */ + /* reserve some space for newline sign */ + log_len -= newline_len; + } + + /* package newline sign */ + log_len += ulog_strcpy(log_len, log_buf + log_len, ULOG_NEWLINE_SIGN); + +#ifdef ULOG_USING_COLOR + /* add CSI end sign */ + if (color_output_info[level]) + { + log_len += ulog_strcpy(log_len, log_buf + log_len, CSI_END); + } +#endif /* ULOG_USING_COLOR */ + + return log_len; +} + +void ulog_output_to_all_backend(rt_uint32_t level, const char *tag, rt_bool_t is_raw, const char *log, rt_size_t size) +{ + rt_slist_t *node; + ulog_backend_t backend; + + if (!ulog.init_ok) + return; + + /* output for all backends */ + for (node = rt_slist_first(&ulog.backend_list); node; node = rt_slist_next(node)) + { + backend = rt_slist_entry(node, struct ulog_backend, list); +#if !defined(ULOG_USING_COLOR) || defined(ULOG_USING_SYSLOG) + backend->output(backend, level, tag, is_raw, log, size); +#else + if (backend->support_color) + { + backend->output(backend, level, tag, is_raw, log, size); + } + else + { + /* recalculate the log start address and log size when backend not supported color */ + rt_size_t color_info_len = rt_strlen(color_output_info[level]); + if (color_info_len) + { + rt_size_t color_hdr_len = rt_strlen(CSI_START) + color_info_len; + + log += color_hdr_len; + size -= (color_hdr_len + (sizeof(CSI_END) - 1)); + } + backend->output(backend, level, tag, is_raw, log, size); + } +#endif /* !defined(ULOG_USING_COLOR) || defined(ULOG_USING_SYSLOG) */ + } +} + +static void do_output(rt_uint32_t level, const char *tag, rt_bool_t is_raw, const char *log_buf, rt_size_t log_len) +{ +#ifdef ULOG_USING_ASYNC_OUTPUT + rt_rbb_blk_t log_blk; + ulog_frame_t log_frame; + + /* allocate log frame */ + log_blk = rt_rbb_blk_alloc(ulog.async_rbb, RT_ALIGN(sizeof(struct ulog_frame) + log_len, RT_ALIGN_SIZE)); + if (log_blk) + { + /* package the log frame */ + log_frame = (ulog_frame_t) log_blk->buf; + log_frame->magic = ULOG_FRAME_MAGIC; + log_frame->is_raw = is_raw; + log_frame->level = level; + log_frame->log_len = log_len; + log_frame->tag = tag; + log_frame->log = (const char *)log_blk->buf + sizeof(struct ulog_frame); + /* copy log data */ + rt_memcpy(log_blk->buf + sizeof(struct ulog_frame), log_buf, log_len); + /* put the block */ + rt_rbb_blk_put(log_blk); + /* send a notice */ + rt_sem_release(&ulog.async_notice); + } + else + { + static rt_bool_t already_output = RT_FALSE; + if (already_output == RT_FALSE) + { + rt_kprintf("Warning: There is no enough buffer for saving async log," + " please increase the ULOG_ASYNC_OUTPUT_BUF_SIZE option.\n"); + already_output = RT_TRUE; + } + } +#else + /* is in thread context */ + if (rt_interrupt_get_nest() == 0) + { + /* output to all backends */ + ulog_output_to_all_backend(level, tag, is_raw, log_buf, log_len); + } + else + { +#ifdef ULOG_BACKEND_USING_CONSOLE + /* We can't ensure that all backends support ISR context output. + * So only using rt_kprintf when context is ISR */ + extern void ulog_console_backend_output(struct ulog_backend *backend, rt_uint32_t level, const char *tag, + rt_bool_t is_raw, const char *log, size_t len); + ulog_console_backend_output(NULL, level, tag, is_raw, log_buf, log_len); +#endif /* ULOG_BACKEND_USING_CONSOLE */ + } +#endif /* ULOG_USING_ASYNC_OUTPUT */ +} + +/** + * output the log by variable argument list + * + * @param level level + * @param tag tag + * @param format output format + * @param args variable argument list + */ +void ulog_voutput(rt_uint32_t level, const char *tag, const char *format, va_list args) +{ + char *log_buf = NULL; + rt_size_t log_len = 0; + +#ifndef ULOG_USING_SYSLOG + RT_ASSERT(level <= LOG_LVL_DBG); +#else + RT_ASSERT(LOG_PRI(level) <= LOG_DEBUG); +#endif /* ULOG_USING_SYSLOG */ + + RT_ASSERT(tag); + RT_ASSERT(format); + + if (!ulog.init_ok) + { + return; + } + +#ifdef ULOG_USING_FILTER + /* level filter */ +#ifndef ULOG_USING_SYSLOG + if (level > ulog.filter.level || level > ulog_tag_lvl_filter_get(tag)) + { + return; + } +#else + if (((LOG_MASK(LOG_PRI(level)) & ulog.filter.level) == 0) + || ((LOG_MASK(LOG_PRI(level)) & ulog_tag_lvl_filter_get(tag)) == 0)) + { + return; + } +#endif /* ULOG_USING_SYSLOG */ + else if (!rt_strstr(tag, ulog.filter.tag)) + { + /* tag filter */ + return; + } +#endif /* ULOG_USING_FILTER */ + + /* get log buffer */ + log_buf = get_log_buf(); + + /* lock output */ + output_lock(); + +#ifndef ULOG_USING_SYSLOG + log_len = ulog_formater(log_buf, level, tag, format, args); +#else + extern rt_size_t syslog_formater(char *log_buf, rt_uint8_t level, const char *tag, const char *format, va_list args); + log_len = syslog_formater(log_buf, level, tag, format, args); +#endif /* ULOG_USING_SYSLOG */ + +#ifdef ULOG_USING_FILTER + /* keyword filter */ + if (ulog.filter.keyword[0] != '\0') + { + /* add string end sign */ + log_buf[log_len] = '\0'; + /* find the keyword */ + if (!rt_strstr(log_buf, ulog.filter.keyword)) + { + /* unlock output */ + output_unlock(); + return; + } + } +#endif /* ULOG_USING_FILTER */ + /* do log output */ + do_output(level, tag, RT_FALSE, log_buf, log_len); + + /* unlock output */ + output_unlock(); +} + +/** + * output the log + * + * @param level level + * @param tag tag + * @param format output format + * @param ... args + */ +void ulog_output(rt_uint32_t level, const char *tag, const char *format, ...) +{ + va_list args; + + /* args point to the first variable parameter */ + va_start(args, format); + + ulog_voutput(level, tag, format, args); + + va_end(args); +} + +/** + * output RAW string format log + * + * @param format output format + * @param ... args + */ +void ulog_raw(const char *format, ...) +{ + rt_size_t log_len = 0; + char *log_buf = NULL; + va_list args; + int fmt_result; + + RT_ASSERT(ulog.init_ok); + + /* get log buffer */ + log_buf = get_log_buf(); + + /* lock output */ + output_lock(); + /* args point to the first variable parameter */ + va_start(args, format); + +#ifdef ULOG_OUTPUT_FLOAT + fmt_result = vsnprintf(log_buf, ULOG_LINE_BUF_SIZE, format, args); +#else + fmt_result = rt_vsnprintf(log_buf, ULOG_LINE_BUF_SIZE, format, args); +#endif /* ULOG_OUTPUT_FLOAT */ + + va_end(args); + + /* calculate log length */ + if ((fmt_result > -1) && (fmt_result <= ULOG_LINE_BUF_SIZE)) + { + log_len = fmt_result; + } + else + { + log_len = ULOG_LINE_BUF_SIZE; + } + + /* do log output */ + do_output(LOG_LVL_DBG, NULL, RT_TRUE, log_buf, log_len); + + /* unlock output */ + output_unlock(); +} + +/** + * dump the hex format data to log + * + * @param name name for hex object, it will show on log header + * @param width hex number for every line, such as: 16, 32 + * @param buf hex buffer + * @param size buffer size + */ +void ulog_hexdump(const char *name, rt_size_t width, rt_uint8_t *buf, rt_size_t size) +{ +#define __is_print(ch) ((unsigned int)((ch) - ' ') < 127u - ' ') + + rt_size_t i, j; + rt_size_t log_len = 0; + char *log_buf = NULL, dump_string[8]; + int fmt_result; + + RT_ASSERT(ulog.init_ok); + + /* get log buffer */ + log_buf = get_log_buf(); + + /* lock output */ + output_lock(); + + for (i = 0, log_len = 0; i < size; i += width) + { + /* package header */ + fmt_result = rt_snprintf(log_buf, ULOG_LINE_BUF_SIZE, "D/HEX %s: %04X-%04X: ", name, i, i + width); + /* calculate log length */ + if ((fmt_result > -1) && (fmt_result <= ULOG_LINE_BUF_SIZE)) + { + log_len = fmt_result; + } + else + { + log_len = ULOG_LINE_BUF_SIZE; + } + /* dump hex */ + for (j = 0; j < width; j++) + { + if (i + j < size) + { + rt_snprintf(dump_string, sizeof(dump_string), "%02X ", buf[i + j]); + } + else + { + rt_strncpy(dump_string, " ", sizeof(dump_string)); + } + log_len += ulog_strcpy(log_len, log_buf + log_len, dump_string); + if ((j + 1) % 8 == 0) + { + log_len += ulog_strcpy(log_len, log_buf + log_len, " "); + } + } + log_len += ulog_strcpy(log_len, log_buf + log_len, " "); + /* dump char for hex */ + for (j = 0; j < width; j++) + { + if (i + j < size) + { + rt_snprintf(dump_string, sizeof(dump_string), "%c", __is_print(buf[i + j]) ? buf[i + j] : '.'); + log_len += ulog_strcpy(log_len, log_buf + log_len, dump_string); + } + } + /* overflow check and reserve some space for newline sign */ + if (log_len + rt_strlen(ULOG_NEWLINE_SIGN) > ULOG_LINE_BUF_SIZE) + { + log_len = ULOG_LINE_BUF_SIZE - rt_strlen(ULOG_NEWLINE_SIGN); + } + /* package newline sign */ + log_len += ulog_strcpy(log_len, log_buf + log_len, ULOG_NEWLINE_SIGN); + /* do log output */ + do_output(LOG_LVL_DBG, NULL, RT_TRUE, log_buf, log_len); + } + /* unlock output */ + output_unlock(); +} + +#ifdef ULOG_USING_FILTER +/** + * Set the filter's level by different tag. + * The log on this tag which level is less than it will stop output. + * + * example: + * // the example tag log enter silent mode + * ulog_set_filter_lvl("example", LOG_FILTER_LVL_SILENT); + * // the example tag log which level is less than INFO level will stop output + * ulog_set_filter_lvl("example", LOG_LVL_INFO); + * // remove example tag's level filter, all level log will resume output + * ulog_set_filter_lvl("example", LOG_FILTER_LVL_ALL); + * + * @param tag log tag + * @param level The filter level. When the level is LOG_FILTER_LVL_SILENT, the log enter silent mode. + * When the level is LOG_FILTER_LVL_ALL, it will remove this tag's level filer. + * Then all level log will resume output. + * + * @return 0: success + * -5: no memory + */ +int ulog_tag_lvl_filter_set(const char *tag, rt_uint32_t level) +{ + rt_slist_t *node; + tag_lvl_filter_t tag_lvl = NULL; + int result = RT_EOK; + + RT_ASSERT(level <= LOG_FILTER_LVL_ALL); + + if (!ulog.init_ok) + return result; + + /* lock output */ + output_lock(); + /* find the tag in list */ + for (node = rt_slist_first(&ulog.filter.tag_lvl_list); node; node = rt_slist_next(node)) + { + tag_lvl = rt_slist_entry(node, struct tag_lvl_filter, list); + if (!rt_strncmp(tag_lvl->tag, tag, ULOG_FILTER_TAG_MAX_LEN)) + { + break; + } + else + { + tag_lvl = NULL; + } + } + /* find OK */ + if (tag_lvl) + { + if (level == LOG_FILTER_LVL_ALL) + { + /* remove current tag's level filter when input level is the lowest level */ + rt_slist_remove(&ulog.filter.tag_lvl_list, &tag_lvl->list); + } + else + { + /* update level */ + tag_lvl->level = level; + } + } + else + { + /* only add the new tag's level filer when level is not LOG_FILTER_LVL_ALL */ + if (level != LOG_FILTER_LVL_ALL) + { + /* new a tag's level filter */ + tag_lvl = (tag_lvl_filter_t)rt_malloc(sizeof(struct tag_lvl_filter)); + if (tag_lvl) + { + rt_memset(tag_lvl->tag, 0 , sizeof(tag_lvl->tag)); + rt_strncpy(tag_lvl->tag, tag, ULOG_FILTER_TAG_MAX_LEN); + tag_lvl->level = level; + rt_slist_append(&ulog.filter.tag_lvl_list, &tag_lvl->list); + } + else + { + result = -RT_ENOMEM; + } + } + } + /* unlock output */ + output_unlock(); + + return result; +} + +/** + * get the level on tag's level filer + * + * @param tag log tag + * + * @return It will return the lowest level when tag was not found. + * Other level will return when tag was found. + */ +rt_uint32_t ulog_tag_lvl_filter_get(const char *tag) +{ + rt_slist_t *node; + tag_lvl_filter_t tag_lvl = NULL; + rt_uint32_t level = LOG_FILTER_LVL_ALL; + + if (!ulog.init_ok) + return level; + + /* lock output */ + output_lock(); + /* find the tag in list */ + for (node = rt_slist_first(&ulog.filter.tag_lvl_list); node; node = rt_slist_next(node)) + { + tag_lvl = rt_slist_entry(node, struct tag_lvl_filter, list); + if (!rt_strncmp(tag_lvl->tag, tag, ULOG_FILTER_TAG_MAX_LEN)) + { + level = tag_lvl->level; + break; + } + } + /* unlock output */ + output_unlock(); + + return level; +} + +/** + * set log global filter level + * + * @param level log level: LOG_LVL_ASSERT, LOG_LVL_ERROR, LOG_LVL_WARNING, LOG_LVL_INFO, LOG_LVL_DBG + * LOG_FILTER_LVL_SILENT: disable all log output, except assert level + * LOG_FILTER_LVL_ALL: enable all log output + */ +void ulog_global_filter_lvl_set(rt_uint32_t level) +{ + RT_ASSERT(level <= LOG_FILTER_LVL_ALL); + + ulog.filter.level = level; +} + +/** + * set log global filter tag + * + * @param tag tag + */ +void ulog_global_filter_tag_set(const char *tag) +{ + RT_ASSERT(tag); + + rt_strncpy(ulog.filter.tag, tag, ULOG_FILTER_TAG_MAX_LEN); +} + +/** + * set log global filter keyword + * + * @param keyword keyword + */ +void ulog_global_filter_kw_set(const char *keyword) +{ + RT_ASSERT(keyword); + + rt_strncpy(ulog.filter.keyword, keyword, ULOG_FILTER_KW_MAX_LEN); +} + +#if defined(RT_USING_FINSH) && defined(FINSH_USING_MSH) +#include + +static void ulog_tag_lvl(uint8_t argc, char **argv) +{ + if (argc > 2) + { + if ((atoi(argv[2]) <= LOG_FILTER_LVL_ALL) && (atoi(argv[2]) >= 0)) + { + ulog_tag_lvl_filter_set(argv[1], atoi(argv[2])); + } + else + { + rt_kprintf("Please input correct level (0-%d).\n", LOG_FILTER_LVL_ALL); + } + } + else + { + rt_kprintf("Please input: ulog_tag_lvl .\n"); +#ifndef ULOG_USING_SYSLOG + rt_kprintf("Assert : 0\n"); + rt_kprintf("Error : 3\n"); + rt_kprintf("Warning : 4\n"); + rt_kprintf("Info : 6\n"); + rt_kprintf("Debug : 7\n"); +#else + rt_kprintf("EMERG : 1 (1 << 0)\n"); + rt_kprintf("ALERT : 2 (1 << 1)\n"); + rt_kprintf("CRIT : 4 (1 << 2)\n"); + rt_kprintf("ERR : 8 (1 << 3)\n"); + rt_kprintf("WARNING : 16 (1 << 4)\n"); + rt_kprintf("NOTICE : 32 (1 << 5)\n"); + rt_kprintf("INFO : 64 (1 << 6)\n"); + rt_kprintf("DEBUG : 128 (1 << 7)\n"); +#endif /* ULOG_USING_SYSLOG */ + } +} +MSH_CMD_EXPORT(ulog_tag_lvl, Set ulog filter level by different tag.); + +static void ulog_lvl(uint8_t argc, char **argv) +{ + if (argc > 1) + { + if ((atoi(argv[1]) <= LOG_FILTER_LVL_ALL) && (atoi(argv[1]) >= 0)) + { + ulog_global_filter_lvl_set(atoi(argv[1])); + } + else + { + rt_kprintf("Please input correct level (0-%d).\n", LOG_FILTER_LVL_ALL); + } + } + else + { + rt_kprintf("Please input: ulog_lvl .\n"); +#ifndef ULOG_USING_SYSLOG + rt_kprintf("Assert : 0\n"); + rt_kprintf("Error : 3\n"); + rt_kprintf("Warning : 4\n"); + rt_kprintf("Info : 6\n"); + rt_kprintf("Debug : 7\n"); +#else + rt_kprintf("EMERG : 1 (1 << 0)\n"); + rt_kprintf("ALERT : 2 (1 << 1)\n"); + rt_kprintf("CRIT : 4 (1 << 2)\n"); + rt_kprintf("ERR : 8 (1 << 3)\n"); + rt_kprintf("WARNING : 16 (1 << 4)\n"); + rt_kprintf("NOTICE : 32 (1 << 5)\n"); + rt_kprintf("INFO : 64 (1 << 6)\n"); + rt_kprintf("DEBUG : 128 (1 << 7)\n"); +#endif /* ULOG_USING_SYSLOG */ + } +} +MSH_CMD_EXPORT(ulog_lvl, Set ulog global filter level.); + +static void ulog_tag(uint8_t argc, char **argv) +{ + if (argc > 1) + { + if (rt_strlen(argv[1]) <= ULOG_FILTER_TAG_MAX_LEN) + { + ulog_global_filter_tag_set(argv[1]); + } + else + { + rt_kprintf("The tag length is too long. Max is %d.\n", ULOG_FILTER_TAG_MAX_LEN); + } + } + else + { + ulog_global_filter_tag_set(""); + } +} +MSH_CMD_EXPORT(ulog_tag, Set ulog global filter tag); + +static void ulog_kw(uint8_t argc, char **argv) +{ + if (argc > 1) + { + if (rt_strlen(argv[1]) <= ULOG_FILTER_KW_MAX_LEN) + { + ulog_global_filter_kw_set(argv[1]); + } + else + { + rt_kprintf("The keyword length is too long. Max is %d.\n", ULOG_FILTER_KW_MAX_LEN); + } + } + else + { + ulog_global_filter_kw_set(""); + } +} +MSH_CMD_EXPORT(ulog_kw, Set ulog global filter keyword); +#endif /* defined(RT_USING_FINSH) && defined(FINSH_USING_MSH) */ +#endif /* ULOG_USING_FILTER */ + +rt_err_t ulog_backend_register(ulog_backend_t backend, const char *name, rt_bool_t support_color) +{ + rt_base_t level; + + RT_ASSERT(backend); + RT_ASSERT(name); + RT_ASSERT(ulog.init_ok); + RT_ASSERT(backend->output); + + if (backend->init) + { + backend->init(backend); + } + + backend->support_color = support_color; + rt_memcpy(backend->name, name, RT_NAME_MAX); + + level = rt_hw_interrupt_disable(); + rt_slist_append(&ulog.backend_list, &backend->list); + rt_hw_interrupt_enable(level); + + return RT_EOK; +} + +rt_err_t ulog_backend_unregister(ulog_backend_t backend) +{ + rt_base_t level; + + RT_ASSERT(backend); + RT_ASSERT(ulog.init_ok); + + level = rt_hw_interrupt_disable(); + rt_slist_remove(&ulog.backend_list, &backend->list); + rt_hw_interrupt_enable(level); + + return RT_EOK; +} + +#ifdef ULOG_USING_ASYNC_OUTPUT +/** + * asynchronous output logs to all backends + * + * @note you must call this function when ULOG_ASYNC_OUTPUT_BY_THREAD is disable + */ +void ulog_async_output(void) +{ + rt_rbb_blk_t log_blk; + ulog_frame_t log_frame; + + while ((log_blk = rt_rbb_blk_get(ulog.async_rbb)) != NULL) + { + log_frame = (ulog_frame_t) log_blk->buf; + if (log_frame->magic == ULOG_FRAME_MAGIC) + { + /* output to all backends */ + ulog_output_to_all_backend(log_frame->level, log_frame->tag, log_frame->is_raw, log_frame->log, + log_frame->log_len); + } + rt_rbb_blk_free(ulog.async_rbb, log_blk); + } +} + +/** + * waiting for get asynchronous output log + * + * @param time the waiting time + */ +void ulog_async_waiting_log(rt_int32_t time) +{ + rt_sem_control(&ulog.async_notice, RT_IPC_CMD_RESET, RT_NULL); + rt_sem_take(&ulog.async_notice, time); +} + +static void async_output_thread_entry(void *param) +{ + while (1) + { + ulog_async_waiting_log(RT_WAITING_FOREVER); + ulog_async_output(); + } +} +#endif /* ULOG_USING_ASYNC_OUTPUT */ + +/** + * flush all backends's log + */ +void ulog_flush(void) +{ + rt_slist_t *node; + ulog_backend_t backend; + + if (!ulog.init_ok) + return; + +#ifdef ULOG_USING_ASYNC_OUTPUT + ulog_async_output(); +#endif + + /* flush all backends */ + for (node = rt_slist_first(&ulog.backend_list); node; node = rt_slist_next(node)) + { + backend = rt_slist_entry(node, struct ulog_backend, list); + if (backend->flush) + { + backend->flush(backend); + } + } +} + +int ulog_init(void) +{ + if (ulog.init_ok) + return 0; + + rt_mutex_init(&ulog.output_locker, "ulog lock", RT_IPC_FLAG_FIFO); + rt_slist_init(&ulog.backend_list); + +#ifdef ULOG_USING_FILTER + rt_slist_init(&ulog.filter.tag_lvl_list); +#endif + +#ifdef ULOG_USING_ASYNC_OUTPUT + RT_ASSERT(ULOG_ASYNC_OUTPUT_STORE_LINES >= 2); + /* async output ring block buffer */ + ulog.async_rbb = rt_rbb_create(RT_ALIGN(ULOG_ASYNC_OUTPUT_BUF_SIZE, RT_ALIGN_SIZE), ULOG_ASYNC_OUTPUT_STORE_LINES); + if (ulog.async_rbb == NULL) + { + rt_kprintf("Error: ulog init failed! No memory for async rbb.\n"); + rt_mutex_detach(&ulog.output_locker); + return -RT_ENOMEM; + } + /* async output thread */ + ulog.async_th = rt_thread_create("ulog_async", async_output_thread_entry, &ulog, ULOG_ASYNC_OUTPUT_THREAD_STACK, + ULOG_ASYNC_OUTPUT_THREAD_PRIORITY, 20); + if (ulog.async_th == NULL) + { + rt_kprintf("Error: ulog init failed! No memory for async output thread.\n"); + rt_mutex_detach(&ulog.output_locker); + rt_rbb_destroy(ulog.async_rbb); + return -RT_ENOMEM; + } + + rt_sem_init(&ulog.async_notice, "ulog", 0, RT_IPC_FLAG_FIFO); + /* async output thread startup */ + rt_thread_startup(ulog.async_th); + +#endif /* ULOG_USING_ASYNC_OUTPUT */ + +#ifdef ULOG_USING_FILTER + ulog_global_filter_lvl_set(LOG_FILTER_LVL_ALL); +#endif + + ulog.init_ok = RT_TRUE; + + return 0; +} +INIT_PREV_EXPORT(ulog_init); + +void ulog_deinit(void) +{ + rt_slist_t *node; + ulog_backend_t backend; + + if (!ulog.init_ok) + return; + + /* deinit all backends */ + for (node = rt_slist_first(&ulog.backend_list); node; node = rt_slist_next(node)) + { + backend = rt_slist_entry(node, struct ulog_backend, list); + if (backend->deinit) + { + backend->deinit(backend); + } + } + +#ifdef ULOG_USING_FILTER + /* deinit tag's level filter */ + { + tag_lvl_filter_t tag_lvl; + for (node = rt_slist_first(&ulog.filter.tag_lvl_list); node; node = rt_slist_next(node)) + { + tag_lvl = rt_slist_entry(node, struct tag_lvl_filter, list); + rt_free(tag_lvl); + } + } +#endif /* ULOG_USING_FILTER */ + + rt_mutex_detach(&ulog.output_locker); + +#ifdef ULOG_USING_ASYNC_OUTPUT + rt_rbb_destroy(ulog.async_rbb); + rt_thread_delete(ulog.async_th); +#endif + + ulog.init_ok = RT_FALSE; +} + +#endif /* RT_USING_ULOG */ diff --git a/components/utilities/ulog/ulog.h b/components/utilities/ulog/ulog.h new file mode 100644 index 0000000000..85b76c9cdd --- /dev/null +++ b/components/utilities/ulog/ulog.h @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2018-08-25 armink the first version + */ + +#ifndef _ULOG_H_ +#define _ULOG_H_ + +#include +#include "ulog_def.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define ULOG_VERSION_STR "0.1.0" + +/* + * ulog init and deint + */ +int ulog_init(void); +void ulog_deinit(void); + +/* + * output different level log by LOG_X API + * + * NOTE: The `LOG_TAG` and `LOG_LVL` must be defined before including the when you want to use LOG_X API. + * + * #define LOG_TAG "example" + * #define LOG_LVL LOG_LVL_DBG + * #include + * + * Then you can using LOG_X API to output log + * + * LOG_D("this is a debug log!"); + * LOG_E("this is a error log!"); + */ +#define LOG_E(...) ulog_e(LOG_TAG, __VA_ARGS__) +#define LOG_W(...) ulog_w(LOG_TAG, __VA_ARGS__) +#define LOG_I(...) ulog_i(LOG_TAG, __VA_ARGS__) +#define LOG_D(...) ulog_d(LOG_TAG, __VA_ARGS__) +#define LOG_RAW(...) ulog_raw(__VA_ARGS__) + +/* + * backend register and unregister + */ +rt_err_t ulog_backend_register(ulog_backend_t backend, const char *name, rt_bool_t support_color); +rt_err_t ulog_backend_unregister(ulog_backend_t backend); + +#ifdef ULOG_USING_FILTER +/* + * log filter setting + */ +int ulog_tag_lvl_filter_set(const char *tag, rt_uint32_t level); +rt_uint32_t ulog_tag_lvl_filter_get(const char *tag); +void ulog_global_filter_lvl_set(rt_uint32_t level); +void ulog_global_filter_tag_set(const char *tag); +void ulog_global_filter_kw_set(const char *keyword); +#endif /* ULOG_USING_FILTER */ + +/* + * flush all backends's log + */ +void ulog_flush(void); + +#ifdef ULOG_USING_ASYNC_OUTPUT +/* + * asynchronous output API + */ +void ulog_async_output(void); +void ulog_async_waiting_log(rt_int32_t time); +#endif + +/* + * dump the hex format data to log + */ +void ulog_hexdump(const char *name, rt_size_t width, rt_uint8_t *buf, rt_size_t size); + +/* + * Another log output API. This API is difficult to use than LOG_X API. + */ +void ulog_voutput(rt_uint32_t level, const char *tag, const char *format, va_list args); +void ulog_output(rt_uint32_t level, const char *tag, const char *format, ...); +void ulog_raw(const char *format, ...); + +#ifdef __cplusplus +} +#endif + +#endif /* _ULOG_H_ */ diff --git a/components/utilities/ulog/ulog_def.h b/components/utilities/ulog/ulog_def.h new file mode 100644 index 0000000000..64962fd5c4 --- /dev/null +++ b/components/utilities/ulog/ulog_def.h @@ -0,0 +1,189 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2018-08-25 armink the first version + */ +#ifndef _ULOG_DEF_H_ +#define _ULOG_DEF_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* logger level, the number is compatible for syslog */ +#define LOG_LVL_ASSERT 0 +#define LOG_LVL_ERROR 3 +#define LOG_LVL_WARNING 4 +#define LOG_LVL_INFO 6 +#define LOG_LVL_DBG 7 + +/* the output silent level and all level for filter setting */ +#ifndef ULOG_USING_SYSLOG +#define LOG_FILTER_LVL_SILENT 0 +#define LOG_FILTER_LVL_ALL 7 +#else +#define LOG_FILTER_LVL_SILENT 1 +#define LOG_FILTER_LVL_ALL 255 +#endif /* ULOG_USING_SYSLOG */ + +/* compatible for rtdbg */ +#undef LOG_D +#undef LOG_I +#undef LOG_W +#undef LOG_E +#undef LOG_RAW +#undef DBG_ERROR +#undef DBG_WARNING +#undef DBG_INFO +#undef DBG_LOG +#define DBG_ERROR LOG_LVL_ERROR +#define DBG_WARNING LOG_LVL_WARNING +#define DBG_INFO LOG_LVL_INFO +#define DBG_LOG LOG_LVL_DBG + +#if !defined(LOG_TAG) + /* compatible for rtdbg */ + #if defined(DBG_SECTION_NAME) + #define LOG_TAG DBG_SECTION_NAME + #else + #define LOG_TAG "NO_TAG" + #endif +#endif /* !defined(LOG_TAG) */ + +#if !defined(LOG_LVL) + /* compatible for rtdbg */ + #if defined(DBG_LEVEL) + #define LOG_LVL DBG_LEVEL + #else + #define LOG_LVL LOG_LVL_DBG + #endif +#endif /* !defined(LOG_LVL) */ + +#if (LOG_LVL >= LOG_LVL_DBG) && (ULOG_OUTPUT_LVL >= LOG_LVL_DBG) + #define ulog_d(TAG, ...) ulog_output(LOG_LVL_DBG, TAG, __VA_ARGS__) +#else + #define ulog_d(TAG, ...) +#endif /* (LOG_LVL >= LOG_LVL_DBG) && (ULOG_OUTPUT_LVL >= LOG_LVL_DBG) */ + +#if (LOG_LVL >= LOG_LVL_INFO) && (ULOG_OUTPUT_LVL >= LOG_LVL_INFO) + #define ulog_i(TAG, ...) ulog_output(LOG_LVL_INFO, TAG, __VA_ARGS__) +#else + #define ulog_i(TAG, ...) +#endif /* (LOG_LVL >= LOG_LVL_INFO) && (ULOG_OUTPUT_LVL >= LOG_LVL_INFO) */ + +#if (LOG_LVL >= LOG_LVL_WARNING) && (ULOG_OUTPUT_LVL >= LOG_LVL_WARNING) + #define ulog_w(TAG, ...) ulog_output(LOG_LVL_WARNING, TAG, __VA_ARGS__) +#else + #define ulog_w(TAG, ...) +#endif /* (LOG_LVL >= LOG_LVL_WARNING) && (ULOG_OUTPUT_LVL >= LOG_LVL_WARNING) */ + +#if (LOG_LVL >= LOG_LVL_ERROR) && (ULOG_OUTPUT_LVL >= LOG_LVL_ERROR) + #define ulog_e(TAG, ...) ulog_output(LOG_LVL_ERROR, TAG, __VA_ARGS__) +#else + #define ulog_e(TAG, ...) +#endif /* (LOG_LVL >= LOG_LVL_ERROR) && (ULOG_OUTPUT_LVL >= LOG_LVL_ERROR) */ + +/* assert for developer. */ +#ifdef ULOG_ASSERT_ENABLE + #define ULOG_ASSERT(EXPR) \ + if (!(EXPR)) \ + { \ + ulog_output(LOG_LVL_ASSERT, LOG_TAG, "(%s) has assert failed at %s:%ld.", #EXPR, __FUNCTION__, __LINE__); \ + ulog_flush(); \ + while (1); \ + } +#else + #define ULOG_ASSERT(EXPR) +#endif + +/* ASSERT API definition */ +#if !defined(ASSERT) + #define ASSERT ULOG_ASSERT +#endif + +/* compatible for elog */ +#undef assert +#undef log_e +#undef log_w +#undef log_i +#undef log_d +#undef log_v +#undef ELOG_LVL_ASSERT +#undef ELOG_LVL_ERROR +#undef ELOG_LVL_WARN +#undef ELOG_LVL_INFO +#undef ELOG_LVL_DEBUG +#undef ELOG_LVL_VERBOSE +#define assert ASSERT +#define log_e LOG_E +#define log_w LOG_W +#define log_i LOG_I +#define log_d LOG_D +#define log_v LOG_D +#define log_raw LOG_RAW +#define ELOG_LVL_ASSERT LOG_LVL_ASSERT +#define ELOG_LVL_ERROR LOG_LVL_ERROR +#define ELOG_LVL_WARN LOG_LVL_WARNING +#define ELOG_LVL_INFO LOG_LVL_INFO +#define ELOG_LVL_DEBUG LOG_LVL_DBG +#define ELOG_LVL_VERBOSE LOG_LVL_DBG + +/* setting static output log level */ +#ifndef ULOG_OUTPUT_LVL +#define ULOG_OUTPUT_LVL LOG_LVL_DBG +#endif + +/* buffer size for every line's log */ +#ifndef ULOG_LINE_BUF_SIZE +#define ULOG_LINE_BUF_SIZE 128 +#endif + +/* output filter's tag max length */ +#ifndef ULOG_FILTER_TAG_MAX_LEN +#define ULOG_FILTER_TAG_MAX_LEN 23 +#endif + +/* output filter's keyword max length */ +#ifndef ULOG_FILTER_KW_MAX_LEN +#define ULOG_FILTER_KW_MAX_LEN 15 +#endif + +#ifndef ULOG_NEWLINE_SIGN +#define ULOG_NEWLINE_SIGN "\r\n" +#endif + +#define ULOG_FRAME_MAGIC 0x10 + +struct ulog_frame +{ + /* magic word is 0x10 ('lo') */ + rt_uint32_t magic:8; + rt_uint32_t is_raw:1; + rt_uint32_t log_len:23; + rt_uint32_t level; + const char *log; + const char *tag; +}; +typedef struct ulog_frame *ulog_frame_t; + +struct ulog_backend +{ + char name[RT_NAME_MAX]; + rt_bool_t support_color; + void (*init) (struct ulog_backend *backend); + void (*output)(struct ulog_backend *backend, rt_uint32_t level, const char *tag, rt_bool_t is_raw, const char *log, size_t len); + void (*flush) (struct ulog_backend *backend); + void (*deinit)(struct ulog_backend *backend); + rt_slist_t list; +}; +typedef struct ulog_backend *ulog_backend_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _ULOG_DEF_H_ */ diff --git a/examples/ulog/ulog_example.c b/examples/ulog/ulog_example.c new file mode 100644 index 0000000000..88572f5152 --- /dev/null +++ b/examples/ulog/ulog_example.c @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2018-08-02 armink the first version + */ + +#include +#include + +#ifndef ULOG_USING_SYSLOG +#define LOG_TAG "example" +#define LOG_LVL LOG_LVL_DBG +#include +#else +#include +#endif /* ULOG_USING_SYSLOG */ + +void ulog_example(void) +{ + int count = 0; + +#ifdef ULOG_USING_SYSLOG + openlog("example1", 0, 0); +#endif + + while (count++ < 50) + { +#ifndef ULOG_USING_SYSLOG + /* output different level log by LOG_X API */ + LOG_D("LOG_D(%d): RT-Thread is an open source IoT operating system from China.", count); + LOG_I("LOG_I(%d): RT-Thread is an open source IoT operating system from China.", count); + LOG_W("LOG_W(%d): RT-Thread is an open source IoT operating system from China.", count); + LOG_E("LOG_E(%d): RT-Thread is an open source IoT operating system from China.", count); + ulog_d("test", "ulog_d(%d): RT-Thread is an open source IoT operating system from China.", count); + ulog_i("test", "ulog_i(%d): RT-Thread is an open source IoT operating system from China.", count); + ulog_w("test", "ulog_w(%d): RT-Thread is an open source IoT operating system from China.", count); + ulog_e("test", "ulog_e(%d): RT-Thread is an open source IoT operating system from China.", count); + +#ifdef ULOG_USING_FILTER + if (count == 20) + { + /* Set the global filer level is INFO. All of DEBUG log will stop output */ + ulog_global_filter_lvl_set(LOG_LVL_INFO); + /* Set the test tag's level filter's level is ERROR. The DEBUG, INFO, WARNING log will stop output. */ + ulog_tag_lvl_filter_set("test", LOG_LVL_ERROR); + } + else if (count == 30) + { + /* Set the example tag's level filter's level is LOG_FILTER_LVL_SILENT, the log enter silent mode. */ + ulog_tag_lvl_filter_set("example", LOG_FILTER_LVL_SILENT); + /* Set the test tag's level filter's level is WARNING. The DEBUG, INFO log will stop output. */ + ulog_tag_lvl_filter_set("test", LOG_LVL_WARNING); + } + else if (count == 40) + { + /* Set the test tag's level filter's level is LOG_FILTER_LVL_ALL. All level log will resume output. */ + ulog_tag_lvl_filter_set("test", LOG_FILTER_LVL_ALL); + /* Set the global filer level is LOG_FILTER_LVL_ALL. All level log will resume output */ + ulog_global_filter_lvl_set(LOG_FILTER_LVL_ALL); + } +#endif /* ULOG_USING_FILTER */ + +#else + /* output different priority log by syslog API */ + syslog(LOG_INFO, "syslog(%d) LOG_INFO: RT-Thread is an open source IoT operating system from China.", count); + syslog(LOG_DEBUG, "syslog(%d) LOG_DEBUG: RT-Thread is an open source IoT operating system from China.", count); + syslog(LOG_WARNING, "syslog(%d) LOG_WARNING: RT-Thread is an open source IoT operating system from China.", count); + syslog(LOG_ERR, "syslog(%d) LOG_ERR: RT-Thread is an open source IoT operating system from China.", count); + syslog(LOG_INFO | LOG_MAIL, "syslog(%d) LOG_INFO | LOG_MAIL: RT-Thread is an open source IoT operating system from China.", count); + syslog(LOG_DEBUG | LOG_DAEMON, "syslog(%d) LOG_DEBUG | LOG_DAEMON: RT-Thread is an open source IoT operating system from China.", count); + syslog(LOG_WARNING | LOG_AUTH, "syslog(%d) LOG_WARNING | LOG_AUTH: RT-Thread is an open source IoT operating system from China.", count); + syslog(LOG_ERR | LOG_SYSLOG, "syslog(%d) LOG_ERR | LOG_SYSLOG: RT-Thread is an open source IoT operating system from China.", count); + + if (count == 20) + { + /* Set log priority mask. Only output ERR and WARNING log. */ + setlogmask(LOG_MASK(LOG_ERR) | LOG_MASK(LOG_WARNING)); + } + else if (count == 40) + { + /* Set log priority mask. The log which level is less than ERROR will stop output. */ + setlogmask(LOG_UPTO(LOG_ERR)); + } +#endif /* ULOG_USING_SYSLOG */ + + rt_thread_delay(rt_tick_from_millisecond(rand() % 1000)); + } +} +MSH_CMD_EXPORT(ulog_example, run ulog example) -- cgit v1.3.1 From 6c62f5d9fef1fca6ded9a3ed5c4954bd2eae9ecd Mon Sep 17 00:00:00 2001 From: MurphyZhao Date: Mon, 5 Nov 2018 14:34:40 +0800 Subject: [examples][network] 更新 tcp client & server 例程 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MurphyZhao --- examples/network/tcpclient.c | 211 ++++++++++++++++++++++++++--------- examples/network/tcpserver.c | 254 +++++++++++++++++++++++++++++++------------ 2 files changed, 344 insertions(+), 121 deletions(-) (limited to 'examples') diff --git a/examples/network/tcpclient.c b/examples/network/tcpclient.c index 20d14baebb..793c71258a 100644 --- a/examples/network/tcpclient.c +++ b/examples/network/tcpclient.c @@ -1,27 +1,60 @@ #include +#include +#if !defined(SAL_USING_POSIX) +#error "Please enable SAL_USING_POSIX!" +#else +#include +#include +#endif #include /* 使用BSD socket,需要包含socket.h头文件 */ #include "netdb.h" +#define DEBUG_TCP_CLIENT + +#define DBG_ENABLE +#define DBG_SECTION_NAME "TCP" +#ifdef DEBUG_TCP_CLIENT +#define DBG_LEVEL DBG_LOG +#else +#define DBG_LEVEL DBG_INFO /* DBG_ERROR */ +#endif +#define DBG_COLOR +#include + #define BUFSZ 1024 +static int started = 0; +static int is_running = 0; +static char url[256]; +static int port = 8080; static const char send_data[] = "This is TCP Client from RT-Thread."; /* 发送用到的数据 */ -void tcpclient(const char *url, int port) + +static void tcpclient(void *arg) { int ret; char *recv_data; - struct hostent *host; - int sock, bytes_received; + int bytes_received; + int sock = -1; + struct hostent *host = RT_NULL; struct sockaddr_in server_addr; + struct timeval timeout; + fd_set readset; + /* 通过函数入口参数url获得host地址(如果是域名,会做域名解析) */ host = gethostbyname(url); + if (host == RT_NULL) + { + LOG_E("Get host by name failed!"); + return; + } /* 分配用于存放接收数据的缓冲 */ recv_data = rt_malloc(BUFSZ); if (recv_data == RT_NULL) { - rt_kprintf("No memory\n"); + LOG_E("No memory"); return; } @@ -29,11 +62,8 @@ void tcpclient(const char *url, int port) if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == -1) { /* 创建socket失败 */ - rt_kprintf("Socket error\n"); - - /* 释放接收缓冲 */ - rt_free(recv_data); - return; + LOG_E("Create socket error"); + goto __exit; } /* 初始化预连接的服务端地址 */ @@ -46,78 +76,159 @@ void tcpclient(const char *url, int port) if (connect(sock, (struct sockaddr *)&server_addr, sizeof(struct sockaddr)) == -1) { /* 连接失败 */ - rt_kprintf("Connect fail!\n"); - closesocket(sock); - - /*释放接收缓冲 */ - rt_free(recv_data); - return; + LOG_E("Connect fail!"); + goto __exit; } - while (1) + started = 1; + is_running = 1; + + timeout.tv_sec = 3; + timeout.tv_usec = 0; + + while (is_running) { + FD_ZERO(&readset); + FD_SET(sock, &readset); + + /* Wait for read */ + if (select(sock + 1, &readset, RT_NULL, RT_NULL, &timeout) == 0) + continue; + /* 从sock连接中接收最大BUFSZ - 1字节数据 */ bytes_received = recv(sock, recv_data, BUFSZ - 1, 0); if (bytes_received < 0) { /* 接收失败,关闭这个连接 */ - closesocket(sock); - rt_kprintf("\nreceived error,close the socket.\r\n"); - - /* 释放接收缓冲 */ - rt_free(recv_data); - break; + LOG_E("Received error, close the socket."); + goto __exit; } else if (bytes_received == 0) { /* 打印recv函数返回值为0的警告信息 */ - rt_kprintf("\nReceived warning,recv function return 0.\r\n"); - + LOG_W("Received warning, recv function return 0."); continue; } - - /* 有接收到数据,把末端清零 */ - recv_data[bytes_received] = '\0'; - - if (strcmp(recv_data, "q") == 0 || strcmp(recv_data, "Q") == 0) - { - /* 如果是首字母是q或Q,关闭这个连接 */ - closesocket(sock); - rt_kprintf("\n got a 'q' or 'Q',close the socket.\r\n"); - - /* 释放接收缓冲 */ - rt_free(recv_data); - break; - } else { - /* 在控制终端显示收到的数据 */ - rt_kprintf("\nReceived data = %s ", recv_data); + /* 有接收到数据,把末端清零 */ + recv_data[bytes_received] = '\0'; + + if (rt_strcmp(recv_data, "q") == 0 || rt_strcmp(recv_data, "Q") == 0) + { + /* 如果是首字母是q或Q,关闭这个连接 */ + LOG_I("Got a 'q' or 'Q', close the socket."); + goto __exit; + } + else + { + /* 在控制终端显示收到的数据 */ + LOG_D("Received data = %s", recv_data); + } } /* 发送数据到sock连接 */ - ret = send(sock, send_data, strlen(send_data), 0); + ret = send(sock, send_data, rt_strlen(send_data), 0); if (ret < 0) { /* 接收失败,关闭这个连接 */ - closesocket(sock); - rt_kprintf("\nsend error,close the socket.\r\n"); - - rt_free(recv_data); - break; + LOG_I("send error, close the socket."); + goto __exit; } else if (ret == 0) { /* 打印send函数返回值为0的警告信息 */ - rt_kprintf("\n Send warning,send function return 0.\r\n"); + LOG_W("Send warning, send function return 0."); + } + } + +__exit: + if (recv_data) + { + rt_free(recv_data); + recv_data = RT_NULL; + } + if (sock >= 0) + { + closesocket(sock); + sock = -1; + } + started = 0; + is_running = 0; + return; +} + +static void usage(void) +{ + LOG_I("Usage: tcpclient -h -p "); + LOG_I(" tcpclient --stop"); + LOG_I(" tcpclient --help"); + LOG_I(""); + LOG_I("Miscellaneous:"); + LOG_I(" -h Specify host address"); + LOG_I(" -p Specify the host port number"); + LOG_I(" --stop Stop tcpclient program"); + LOG_I(" --help Print help information"); +} + +static void tcpclient_test(int argc, char** argv) +{ + rt_thread_t tid; + + if (argc == 1 || argc > 5) + { + LOG_I("Please check the command you entered!\n"); + goto __usage; + } + else + { + if (rt_strcmp(argv[1], "--help") == 0) + { + goto __usage; + } + else if (rt_strcmp(argv[1], "--stop") == 0) + { + is_running = 0; + return; + } + else if (rt_strcmp(argv[1], "-h") == 0 && rt_strcmp(argv[3], "-p") == 0) + { + if (started) + { + LOG_I("The tcpclient has started!"); + LOG_I("Please stop tcpclient firstly, by: tcpclient --stop"); + return; + } + + if (rt_strlen(argv[2]) > sizeof(url)) + { + LOG_E("The input url is too long, max %d bytes!", sizeof(url)); + return; + } + rt_memset(url, 0x0, sizeof(url)); + rt_strncpy(url, argv[2], rt_strlen(argv[2])); + port = atoi(argv[4]); + } + else + { + goto __usage; } } + tid = rt_thread_create("tcp_client", + tcpclient, RT_NULL, + 2048, RT_THREAD_PRIORITY_MAX/3, 20); + if (tid != RT_NULL) + { + rt_thread_startup(tid); + } return; + +__usage: + usage(); } #ifdef RT_USING_FINSH -#include -/* 输出tcpclient函数到finsh shell中 */ -FINSH_FUNCTION_EXPORT(tcpclient, startup tcp client); +MSH_CMD_EXPORT_ALIAS(tcpclient_test, tcpclient, + Start a tcp client. Help: tcpclient --help); #endif diff --git a/examples/network/tcpserver.c b/examples/network/tcpserver.c index 97292449a0..1e068451b4 100644 --- a/examples/network/tcpserver.c +++ b/examples/network/tcpserver.c @@ -1,151 +1,263 @@ #include +#include +#if !defined(SAL_USING_POSIX) +#error "Please enable SAL_USING_POSIX!" +#else +#include +#include +#endif #include /* 使用BSD socket,需要包含socket.h头文件 */ #include "netdb.h" +#define DEBUG_TCP_SERVER + +#define DBG_ENABLE +#define DBG_SECTION_NAME "TCP" +#ifdef DEBUG_TCP_SERVER +#define DBG_LEVEL DBG_LOG +#else +#define DBG_LEVEL DBG_INFO /* DBG_ERROR */ +#endif +#define DBG_COLOR +#include + #define BUFSZ (1024) +static int started = 0; +static int is_running = 0; +static int port = 5000; static const char send_data[] = "This is TCP Server from RT-Thread."; /* 发送用到的数据 */ -static void tcpserv(void *parameter) + +static void tcpserv(void *arg) { + int ret; char *recv_data; /* 用于接收的指针,后面会做一次动态分配以请求可用内存 */ - socklen_t sin_size; int sock, connected, bytes_received; struct sockaddr_in server_addr, client_addr; - rt_bool_t stop = RT_FALSE; /* 停止标志 */ - int ret; + + struct timeval timeout; + fd_set readset, readset_c; + socklen_t sin_size = sizeof(struct sockaddr_in); recv_data = rt_malloc(BUFSZ + 1); /* 分配接收用的数据缓冲 */ if (recv_data == RT_NULL) { - rt_kprintf("No memory\n"); + LOG_E("No memory"); return; } /* 一个socket在使用前,需要预先创建出来,指定SOCK_STREAM为TCP的socket */ - if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == -1) + if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) { - /* 创建失败的错误处理 */ - rt_kprintf("Socket error\n"); - - /* 释放已分配的接收缓冲 */ - rt_free(recv_data); - return; + LOG_E("Create socket error"); + goto __exit; } /* 初始化服务端地址 */ server_addr.sin_family = AF_INET; - server_addr.sin_port = htons(5000); /* 服务端工作的端口 */ + server_addr.sin_port = htons(port); /* 服务端工作的端口 */ server_addr.sin_addr.s_addr = INADDR_ANY; - rt_memset(&(server_addr.sin_zero), 0, sizeof(server_addr.sin_zero)); + rt_memset(&(server_addr.sin_zero), 0x0, sizeof(server_addr.sin_zero)); /* 绑定socket到服务端地址 */ if (bind(sock, (struct sockaddr *)&server_addr, sizeof(struct sockaddr)) == -1) { - /* 绑定失败 */ - rt_kprintf("Unable to bind\n"); - - /* 释放已分配的接收缓冲 */ - rt_free(recv_data); - return; + LOG_E("Unable to bind"); + goto __exit; } /* 在socket上进行监听 */ - if (listen(sock, 5) == -1) + if (listen(sock, 10) == -1) { - rt_kprintf("Listen error\n"); - - /* release recv buffer */ - rt_free(recv_data); - return; + LOG_E("Listen error"); + goto __exit; } - rt_kprintf("\nTCPServer Waiting for client on port 5000...\n"); - while (stop != RT_TRUE) + LOG_I("\nTCPServer Waiting for client on port %d...\n", port); + + started = 1; + is_running = 1; + + timeout.tv_sec = 3; + timeout.tv_usec = 0; + + while (is_running) { - sin_size = sizeof(struct sockaddr_in); + FD_ZERO(&readset); + FD_SET(sock, &readset); + + LOG_I("Waiting for a new connection..."); + + /* Wait for read or write */ + if (select(sock + 1, &readset, RT_NULL, RT_NULL, &timeout) == 0) + continue; /* 接受一个客户端连接socket的请求,这个函数调用是阻塞式的 */ connected = accept(sock, (struct sockaddr *)&client_addr, &sin_size); /* 返回的是连接成功的socket */ if (connected < 0) { - rt_kprintf("accept connection failed! errno = %d\n", errno); + LOG_E("accept connection failed! errno = %d", errno); continue; } /* 接受返回的client_addr指向了客户端的地址信息 */ - rt_kprintf("I got a connection from (%s , %d)\n", + LOG_I("I got a connection from (%s , %d)\n", inet_ntoa(client_addr.sin_addr), ntohs(client_addr.sin_port)); /* 客户端连接的处理 */ - while (1) + while (is_running) { - /* 发送数据到connected socket */ - ret = send(connected, send_data, strlen(send_data), 0); - if (ret < 0) - { - /* 发送失败,关闭这个连接 */ - closesocket(connected); - rt_kprintf("\nsend error,close the socket.\r\n"); - break; - } - else if (ret == 0) - { - /* 打印send函数返回值为0的警告信息 */ - rt_kprintf("\n Send warning,send function return 0.\r\n"); - } + FD_ZERO(&readset_c); + FD_SET(connected, &readset_c); + + /* Wait for read or write */ + if (select(connected + 1, &readset_c, RT_NULL, RT_NULL, &timeout) == 0) + continue; /* 从connected socket中接收数据,接收buffer是1024大小,但并不一定能够收到1024大小的数据 */ bytes_received = recv(connected, recv_data, BUFSZ, 0); if (bytes_received < 0) { - /* 接收失败,关闭这个connected socket */ + LOG_E("Received error, close the connect."); closesocket(connected); + connected = -1; break; } else if (bytes_received == 0) { /* 打印recv函数返回值为0的警告信息 */ - rt_kprintf("\nReceived warning,recv function return 0.\r\n"); - closesocket(connected); - break; + LOG_W("Received warning, recv function return 0."); + continue; } - - /* 有接收到数据,把末端清零 */ - recv_data[bytes_received] = '\0'; - if (strcmp(recv_data, "q") == 0 || strcmp(recv_data, "Q") == 0) + else { - /* 如果是首字母是q或Q,关闭这个连接 */ - closesocket(connected); - break; + /* 有接收到数据,把末端清零 */ + recv_data[bytes_received] = '\0'; + if (strcmp(recv_data, "q") == 0 || strcmp(recv_data, "Q") == 0) + { + /* 如果是首字母是q或Q,关闭这个连接 */ + LOG_I("Got a 'q' or 'Q', close the connect."); + closesocket(connected); + connected = -1; + break; + } + else if (strcmp(recv_data, "exit") == 0) + { + /* 如果接收的是exit,则关闭整个服务端 */ + closesocket(connected); + connected = -1; + goto __exit; + } + else + { + /* 在控制终端显示收到的数据 */ + LOG_D("Received data = %s", recv_data); + } } - else if (strcmp(recv_data, "exit") == 0) + + /* 发送数据到connected socket */ + ret = send(connected, send_data, rt_strlen(send_data), 0); + if (ret < 0) { - /* 如果接收的是exit,则关闭整个服务端 */ + LOG_E("send error, close the connect."); closesocket(connected); - stop = RT_TRUE; + connected = -1; break; } - else + else if (ret == 0) { - /* 在控制终端显示收到的数据 */ - rt_kprintf("RECEIVED DATA = %s \n", recv_data); + /* 打印send函数返回值为0的警告信息 */ + LOG_W("Send warning, send function return 0."); } } } - /* 退出服务 */ - closesocket(sock); +__exit: + if (recv_data) + { + rt_free(recv_data); + recv_data = RT_NULL; + } + if (connected >= 0) + { + closesocket(connected); + connected = -1; + } + if (sock >= 0) + { + closesocket(sock); + sock = -1; + } + started = 0; + is_running = 0; + return; +} + +static void usage(void) +{ + LOG_I("Usage: tcpserver -p "); + LOG_I(" tcpserver --stop"); + LOG_I(" tcpserver --help"); + LOG_I(""); + LOG_I("Miscellaneous:"); + LOG_I(" -p Specify the host port number"); + LOG_I(" --stop Stop tcpserver program"); + LOG_I(" --help Print help information"); +} + +static void tcpserver_test(int argc, char** argv) +{ + rt_thread_t tid; + + if (argc == 1 || argc > 3) + { + LOG_I("Please check the command you entered!\n"); + goto __usage; + } + else + { + if (rt_strcmp(argv[1], "--help") == 0) + { + goto __usage; + } + else if (rt_strcmp(argv[1], "--stop") == 0) + { + is_running = 0; + return; + } + else if (rt_strcmp(argv[1], "-p") == 0) + { + if (started) + { + LOG_I("The tcpclient has started!"); + LOG_I("Please stop tcpclient firstly, by: tcpclient --stop"); + return; + } + + port = atoi(argv[2]); + } + else + { + goto __usage; + } + } - /* 释放接收缓冲 */ - rt_free(recv_data); + tid = rt_thread_create("tcp_serv", + tcpserv, RT_NULL, + 2048, RT_THREAD_PRIORITY_MAX/3, 20); + if (tid != RT_NULL) + { + rt_thread_startup(tid); + } + return; - return ; +__usage: + usage(); } #ifdef RT_USING_FINSH -#include -/* 输出tcpserv函数到finsh shell中 */ -FINSH_FUNCTION_EXPORT(tcpserv, startup tcp server); +MSH_CMD_EXPORT_ALIAS(tcpserver_test, tcpserver, + Start a tcp server. Help: tcpserver --help); #endif -- cgit v1.3.1 From b2d4dd0ba757e55e1eecdc887fe5aebc93c5e636 Mon Sep 17 00:00:00 2001 From: MurphyZhao Date: Mon, 5 Nov 2018 16:36:47 +0800 Subject: [examples][network] 更新 UDP client & server MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MurphyZhao --- examples/network/udpclient.c | 135 ++++++++++++++++++++++++++++++--- examples/network/udpserver.c | 173 +++++++++++++++++++++++++++++++++++-------- 2 files changed, 264 insertions(+), 44 deletions(-) (limited to 'examples') diff --git a/examples/network/udpclient.c b/examples/network/udpclient.c index 5060c9a087..80cf521adf 100644 --- a/examples/network/udpclient.c +++ b/examples/network/udpclient.c @@ -1,11 +1,28 @@ #include -//#include /* 为了解析主机名,需要包含netdb.h头文件 */ -//#include /* 使用BSD socket,需要包含sockets.h头文件 */ + #include /* 使用BSD socket,需要包含sockets.h头文件 */ #include "netdb.h" +#define DEBUG_UDP_CLIENT + +#define DBG_ENABLE +#define DBG_SECTION_NAME "UDP" +#ifdef DEBUG_UDP_CLIENT +#define DBG_LEVEL DBG_LOG +#else +#define DBG_LEVEL DBG_INFO /* DBG_ERROR */ +#endif +#define DBG_COLOR +#include + +static int started = 0; +static int is_running = 0; +static char url[256]; +static int port = 8080; +static int count = 10; const char send_data[] = "This is UDP Client from RT-Thread.\n"; /* 发送用到的数据 */ -void udpclient(const char *url, int port, int count) + +static void udpclient(void *arg) { int sock; struct hostent *host; @@ -13,11 +30,16 @@ void udpclient(const char *url, int port, int count) /* 通过函数入口参数url获得host地址(如果是域名,会做域名解析) */ host = (struct hostent *) gethostbyname(url); + if (host == RT_NULL) + { + LOG_E("Get host by name failed!"); + return; + } /* 创建一个socket,类型是SOCK_DGRAM,UDP类型 */ - if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) == -1) + if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) { - rt_kprintf("Socket error\n"); + LOG_E("Create socket error"); return; } @@ -27,26 +49,115 @@ void udpclient(const char *url, int port, int count) server_addr.sin_addr = *((struct in_addr *)host->h_addr); rt_memset(&(server_addr.sin_zero), 0, sizeof(server_addr.sin_zero)); + started = 1; + is_running = 1; + /* 总计发送count次数据 */ - while (count) + while (count && is_running) { /* 发送数据到服务远端 */ - sendto(sock, send_data, strlen(send_data), 0, + sendto(sock, send_data, rt_strlen(send_data), 0, (struct sockaddr *)&server_addr, sizeof(struct sockaddr)); /* 线程休眠一段时间 */ - rt_thread_delay(50); + rt_thread_mdelay(1000); /* 计数值减一 */ count --; } + if (count == 0) + { + LOG_I("UDP client send data finished!"); + } + /* 关闭这个socket */ - closesocket(sock); + if (sock >= 0) + { + closesocket(sock); + sock = -1; + } + started = 0; + is_running = 0; +} + +static void usage(void) +{ + LOG_I("Usage: udpclient -h -p [--cnt] [count]"); + LOG_I(" udpclient --stop"); + LOG_I(" udpclient --help"); + LOG_I(""); + LOG_I("Miscellaneous:"); + LOG_I(" -h Specify host address"); + LOG_I(" -p Specify the host port number"); + LOG_I(" --cnt Specify the send data count"); + LOG_I(" --stop Stop tcpclient program"); + LOG_I(" --help Print help information"); +} + +static void udpclient_test(int argc, char** argv) +{ + rt_thread_t tid; + + if (argc == 1 || argc > 7) + { + LOG_I("Please check the command you entered!\n"); + goto __usage; + } + else + { + if (rt_strcmp(argv[1], "--help") == 0) + { + goto __usage; + } + else if (rt_strcmp(argv[1], "--stop") == 0) + { + is_running = 0; + return; + } + else if (rt_strcmp(argv[1], "-h") == 0 && rt_strcmp(argv[3], "-p") == 0) + { + if (started) + { + LOG_I("The tcpclient has started!"); + LOG_I("Please stop tcpclient firstly, by: tcpclient --stop"); + return; + } + + if (argc == 7 && rt_strcmp(argv[6], "--cnt") == 0) + { + count = atoi(argv[7]); + } + + if (rt_strlen(argv[2]) > sizeof(url)) + { + LOG_E("The input url is too long, max %d bytes!", sizeof(url)); + return; + } + rt_memset(url, 0x0, sizeof(url)); + rt_strncpy(url, argv[2], rt_strlen(argv[2])); + port = atoi(argv[4]); + } + else + { + goto __usage; + } + } + + tid = rt_thread_create("udp_client", + udpclient, RT_NULL, + 2048, RT_THREAD_PRIORITY_MAX/3, 20); + if (tid != RT_NULL) + { + rt_thread_startup(tid); + } + return; + +__usage: + usage(); } #ifdef RT_USING_FINSH -#include -/* 输出udpclient函数到finsh shell中 */ -FINSH_FUNCTION_EXPORT(udpclient, startup udp client); +MSH_CMD_EXPORT_ALIAS(udpclient_test, udpclient, + Start a udp client. Help: udpclient --help); #endif diff --git a/examples/network/udpserver.c b/examples/network/udpserver.c index a684e9cd0c..15cc2096d6 100644 --- a/examples/network/udpserver.c +++ b/examples/network/udpserver.c @@ -1,10 +1,33 @@ #include +#include +#if !defined(SAL_USING_POSIX) +#error "Please enable SAL_USING_POSIX!" +#else +#include +#include +#endif #include /* 使用BSD socket,需要包含socket.h头文件 */ #include "netdb.h" +#define DEBUG_UDP_SERVER + +#define DBG_ENABLE +#define DBG_SECTION_NAME "UDP" +#ifdef DEBUG_UDP_SERVER +#define DBG_LEVEL DBG_LOG +#else +#define DBG_LEVEL DBG_INFO /* DBG_ERROR */ +#endif +#define DBG_COLOR +#include + #define BUFSZ 1024 +static int started = 0; +static int is_running = 0; +static int port = 5000; + static void udpserv(void *paramemter) { int sock; @@ -13,28 +36,27 @@ static void udpserv(void *paramemter) socklen_t addr_len; struct sockaddr_in server_addr, client_addr; + struct timeval timeout; + fd_set readset; + /* 分配接收用的数据缓冲 */ recv_data = rt_malloc(BUFSZ); if (recv_data == RT_NULL) { - /* 分配内存失败,返回 */ - rt_kprintf("No memory\n"); + LOG_E("No memory"); return; } /* 创建一个socket,类型是SOCK_DGRAM,UDP类型 */ if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) == -1) { - rt_kprintf("Socket error\n"); - - /* 释放接收用的数据缓冲 */ - rt_free(recv_data); - return; + LOG_E("Create socket error"); + goto __exit; } /* 初始化服务端地址 */ server_addr.sin_family = AF_INET; - server_addr.sin_port = htons(5000); + server_addr.sin_port = htons(port); server_addr.sin_addr.s_addr = INADDR_ANY; rt_memset(&(server_addr.sin_zero), 0, sizeof(server_addr.sin_zero)); @@ -42,47 +64,134 @@ static void udpserv(void *paramemter) if (bind(sock, (struct sockaddr *)&server_addr, sizeof(struct sockaddr)) == -1) { - /* 绑定地址失败 */ - rt_kprintf("Bind error\n"); - - /* 释放接收用的数据缓冲 */ - rt_free(recv_data); - return; + LOG_E("Unable to bind"); + goto __exit; } addr_len = sizeof(struct sockaddr); - rt_kprintf("UDPServer Waiting for client on port 5000...\n"); + LOG_I("UDPServer Waiting for client on port %d...", port); - while (1) + started = 1; + is_running = 1; + + timeout.tv_sec = 3; + timeout.tv_usec = 0; + + while (is_running) { + FD_ZERO(&readset); + FD_SET(sock, &readset); + + /* Wait for read or write */ + if (select(sock + 1, &readset, RT_NULL, RT_NULL, &timeout) == 0) + continue; + /* 从sock中收取最大BUFSZ - 1字节数据 */ bytes_read = recvfrom(sock, recv_data, BUFSZ - 1, 0, (struct sockaddr *)&client_addr, &addr_len); - /* UDP不同于TCP,它基本不会出现收取的数据失败的情况,除非设置了超时等待 */ + if (bytes_read < 0) + { + LOG_E("Received error, close the connect."); + goto __exit; + } + else if (bytes_read == 0) + { + LOG_W("Received warning, recv function return 0."); + continue; + } + else + { + recv_data[bytes_read] = '\0'; /* 把末端清零 */ - recv_data[bytes_read] = '\0'; /* 把末端清零 */ + /* 输出接收的数据 */ + LOG_D("Received data = %s", recv_data); - /* 输出接收的数据 */ - rt_kprintf("\n(%s , %d) said : ", inet_ntoa(client_addr.sin_addr), - ntohs(client_addr.sin_port)); - rt_kprintf("%s", recv_data); + /* 如果接收数据是exit,退出 */ + if (strcmp(recv_data, "exit") == 0) + { + goto __exit; + } + } + } - /* 如果接收数据是exit,退出 */ - if (strcmp(recv_data, "exit") == 0) - { - closesocket(sock); +__exit: + if (recv_data) + { + rt_free(recv_data); + recv_data = RT_NULL; + } + if (sock >= 0) + { + closesocket(sock); + sock = -1; + } + started = 0; + is_running = 0; +} - /* 释放接收用的数据缓冲 */ - rt_free(recv_data); - break; +static void usage(void) +{ + LOG_I("Usage: udpserver -p "); + LOG_I(" udpserver --stop"); + LOG_I(" udpserver --help"); + LOG_I(""); + LOG_I("Miscellaneous:"); + LOG_I(" -p Specify the host port number"); + LOG_I(" --stop Stop udpserver program"); + LOG_I(" --help Print help information"); +} + +static void udpserver_test(int argc, char** argv) +{ + rt_thread_t tid; + + if (argc == 1 || argc > 3) + { + LOG_I("Please check the command you entered!\n"); + goto __usage; + } + else + { + if (rt_strcmp(argv[1], "--help") == 0) + { + goto __usage; + } + else if (rt_strcmp(argv[1], "--stop") == 0) + { + is_running = 0; + return; + } + else if (rt_strcmp(argv[1], "-p") == 0) + { + if (started) + { + LOG_I("The tcpclient has started!"); + LOG_I("Please stop tcpclient firstly, by: tcpclient --stop"); + return; + } + + port = atoi(argv[2]); + } + else + { + goto __usage; } } + tid = rt_thread_create("udp_serv", + udpserv, RT_NULL, + 2048, RT_THREAD_PRIORITY_MAX/3, 20); + if (tid != RT_NULL) + { + rt_thread_startup(tid); + } return; + +__usage: + usage(); } #ifdef RT_USING_FINSH -#include -/* 输出udpserv函数到finsh shell中 */ -FINSH_FUNCTION_EXPORT(udpserv, startup udp server); +MSH_CMD_EXPORT_ALIAS(udpserver_test, udpserver, + Start a udp server. Help: udpserver --help); #endif -- cgit v1.3.1 From e9c795e8bc09457f2901e159251a1777cd9a6add Mon Sep 17 00:00:00 2001 From: MurphyZhao Date: Tue, 6 Nov 2018 09:45:31 +0800 Subject: [examples][network] 更新 TCP/UDP 例程 uage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MurphyZhao --- examples/network/tcpclient.c | 18 +++++++++--------- examples/network/tcpserver.c | 16 ++++++++-------- examples/network/udpclient.c | 20 ++++++++++---------- examples/network/udpserver.c | 16 ++++++++-------- 4 files changed, 35 insertions(+), 35 deletions(-) (limited to 'examples') diff --git a/examples/network/tcpclient.c b/examples/network/tcpclient.c index 793c71258a..d4c96f893a 100644 --- a/examples/network/tcpclient.c +++ b/examples/network/tcpclient.c @@ -160,15 +160,15 @@ __exit: static void usage(void) { - LOG_I("Usage: tcpclient -h -p "); - LOG_I(" tcpclient --stop"); - LOG_I(" tcpclient --help"); - LOG_I(""); - LOG_I("Miscellaneous:"); - LOG_I(" -h Specify host address"); - LOG_I(" -p Specify the host port number"); - LOG_I(" --stop Stop tcpclient program"); - LOG_I(" --help Print help information"); + rt_kprintf("Usage: tcpclient -h -p \n"); + rt_kprintf(" tcpclient --stop\n"); + rt_kprintf(" tcpclient --help\n"); + rt_kprintf("\n"); + rt_kprintf("Miscellaneous:\n"); + rt_kprintf(" -h Specify host address\n"); + rt_kprintf(" -p Specify the host port number\n"); + rt_kprintf(" --stop Stop tcpclient program\n"); + rt_kprintf(" --help Print help information\n"); } static void tcpclient_test(int argc, char** argv) diff --git a/examples/network/tcpserver.c b/examples/network/tcpserver.c index 1e068451b4..264b6f7c83 100644 --- a/examples/network/tcpserver.c +++ b/examples/network/tcpserver.c @@ -197,14 +197,14 @@ __exit: static void usage(void) { - LOG_I("Usage: tcpserver -p "); - LOG_I(" tcpserver --stop"); - LOG_I(" tcpserver --help"); - LOG_I(""); - LOG_I("Miscellaneous:"); - LOG_I(" -p Specify the host port number"); - LOG_I(" --stop Stop tcpserver program"); - LOG_I(" --help Print help information"); + rt_kprintf("Usage: tcpserver -p \n"); + rt_kprintf(" tcpserver --stop\n"); + rt_kprintf(" tcpserver --help\n"); + rt_kprintf("\n"); + rt_kprintf("Miscellaneous:\n"); + rt_kprintf(" -p Specify the host port number\n"); + rt_kprintf(" --stop Stop tcpserver program\n"); + rt_kprintf(" --help Print help information\n"); } static void tcpserver_test(int argc, char** argv) diff --git a/examples/network/udpclient.c b/examples/network/udpclient.c index 80cf521adf..40542b9fa1 100644 --- a/examples/network/udpclient.c +++ b/examples/network/udpclient.c @@ -83,16 +83,16 @@ static void udpclient(void *arg) static void usage(void) { - LOG_I("Usage: udpclient -h -p [--cnt] [count]"); - LOG_I(" udpclient --stop"); - LOG_I(" udpclient --help"); - LOG_I(""); - LOG_I("Miscellaneous:"); - LOG_I(" -h Specify host address"); - LOG_I(" -p Specify the host port number"); - LOG_I(" --cnt Specify the send data count"); - LOG_I(" --stop Stop tcpclient program"); - LOG_I(" --help Print help information"); + rt_kprintf("Usage: udpclient -h -p [--cnt] [count]\n"); + rt_kprintf(" udpclient --stop\n"); + rt_kprintf(" udpclient --help\n"); + rt_kprintf("\n"); + rt_kprintf("Miscellaneous:\n"); + rt_kprintf(" -h Specify host address\n"); + rt_kprintf(" -p Specify the host port number\n"); + rt_kprintf(" --cnt Specify the send data count\n"); + rt_kprintf(" --stop Stop tcpclient program\n"); + rt_kprintf(" --help Print help information\n"); } static void udpclient_test(int argc, char** argv) diff --git a/examples/network/udpserver.c b/examples/network/udpserver.c index 15cc2096d6..c40a1972b4 100644 --- a/examples/network/udpserver.c +++ b/examples/network/udpserver.c @@ -131,14 +131,14 @@ __exit: static void usage(void) { - LOG_I("Usage: udpserver -p "); - LOG_I(" udpserver --stop"); - LOG_I(" udpserver --help"); - LOG_I(""); - LOG_I("Miscellaneous:"); - LOG_I(" -p Specify the host port number"); - LOG_I(" --stop Stop udpserver program"); - LOG_I(" --help Print help information"); + rt_kprintf("Usage: udpserver -p \n"); + rt_kprintf(" udpserver --stop\n"); + rt_kprintf(" udpserver --help\n"); + rt_kprintf("\n"); + rt_kprintf("Miscellaneous:\n"); + rt_kprintf(" -p Specify the host port number\n"); + rt_kprintf(" --stop Stop udpserver program\n"); + rt_kprintf(" --help Print help information\n"); } static void udpserver_test(int argc, char** argv) -- cgit v1.3.1 From 4fd6f2ef53d832e5528ddd72c653a4e3bd32254a Mon Sep 17 00:00:00 2001 From: zylx Date: Wed, 12 Dec 2018 16:59:02 +0800 Subject: [examples][test]Perfect test function --- examples/test/hwtimer_test.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'examples') diff --git a/examples/test/hwtimer_test.c b/examples/test/hwtimer_test.c index 8f69c4ef87..428373dde0 100644 --- a/examples/test/hwtimer_test.c +++ b/examples/test/hwtimer_test.c @@ -8,7 +8,7 @@ static rt_err_t timer_timeout_cb(rt_device_t dev, rt_size_t size) { - rt_kprintf("HT %d\n", rt_tick_get()); + rt_kprintf("enter hardware timer isr\n"); return 0; } @@ -35,7 +35,7 @@ int hwtimer(void) return -1; } - rt_device_set_rx_indicate(dev, timer_timeout_cb); + /* ʱ¼ä²âÁ¿ */ /* ¼ÆÊýʱÖÓÉèÖÃ(ĬÈÏ1Mhz»ò֧³ֵÄ×îС¼ÆÊýƵÂÊ) */ err = rt_device_control(dev, HWTIMER_CTRL_FREQ_SET, &freq); if (err != RT_EOK) @@ -69,12 +69,34 @@ int hwtimer(void) rt_device_read(dev, 0, &val, sizeof(val)); rt_kprintf("Read: Sec = %d, Usec = %d\n", val.sec, val.usec); + /* ¶¨ʱִÐлص÷º¯Êý -- µ¥´Îģʽ */ + /* ÉèÖó¬ʱ»ص÷º¯Êý */ + rt_device_set_rx_indicate(dev, timer_timeout_cb); + + /* µ¥´Îģʽ */ + mode = HWTIMER_MODE_PERIOD; + err = rt_device_control(dev, HWTIMER_CTRL_MODE_SET, &mode); + + /* ÉèÖö¨ʱÆ÷³¬ʱֵ²¢Æô¶¯¶¨ʱÆ÷ */ + val.sec = t; + val.usec = 0; + rt_kprintf("SetTime: Sec %d, Usec %d\n", val.sec, val.usec); + if (rt_device_write(dev, 0, &val, sizeof(val)) != sizeof(val)) + { + rt_kprintf("SetTime Fail\n"); + goto EXIT; + } + + /* µȴý»ص÷º¯ÊýִÐÐ */ + rt_thread_delay((t + 1)*RT_TICK_PER_SECOND); + EXIT: err = rt_device_close(dev); rt_kprintf("Close %s\n", TIMER); return err; } - -FINSH_FUNCTION_EXPORT(hwtimer, "Test hardware timer"); +#ifdef FINSH_USING_MSH +MSH_CMD_EXPORT(hwtimer, "Test hardware timer"); #endif +#endif /* RT_USING_HWTIMER */ -- cgit v1.3.1 From 57da7246d85f1a56f3ac6832cbaab575846cef1f Mon Sep 17 00:00:00 2001 From: HubretXie Date: Wed, 19 Dec 2018 20:12:15 +0800 Subject: 初始化宏使用错误 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/pm/timer_app.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/pm/timer_app.c b/examples/pm/timer_app.c index 73faf52d0a..5c20d0f690 100644 --- a/examples/pm/timer_app.c +++ b/examples/pm/timer_app.c @@ -48,7 +48,7 @@ static int timer_app_init(void) return -1; } } -INIT_EXPORT_APP(timer_app_init); +INIT_APP_EXPORT(timer_app_init); #endif /* RT_USING_PM */ -- cgit v1.3.1 From 0d7ba79219f939ad0dc55eb70872e11c950b0da8 Mon Sep 17 00:00:00 2001 From: armink Date: Wed, 6 Mar 2019 17:07:15 +0800 Subject: Remove the DBG_COLOR and DBG_ENABLE definition. --- bsp/CME_M7/rtconfig.h | 1 + bsp/allwinner_tina/.config | 1 + bsp/allwinner_tina/drivers/drv_gpio.c | 3 --- bsp/allwinner_tina/drivers/drv_sdio.c | 3 +-- bsp/allwinner_tina/drivers/spi/drv_spi.c | 2 -- bsp/allwinner_tina/drivers/spi/drv_spi_flash.c | 2 -- bsp/allwinner_tina/rtconfig.h | 1 + bsp/amebaz/.config | 1 + bsp/amebaz/drivers/wlan/drv_wifi.c | 2 -- bsp/amebaz/rtconfig.h | 1 + bsp/apollo2/rtconfig.h | 1 + bsp/asm9260t/.config | 1 + bsp/asm9260t/rtconfig.h | 1 + bsp/at91sam9260/.config | 1 + bsp/at91sam9260/rtconfig.h | 1 + bsp/at91sam9g45/.config | 1 + bsp/at91sam9g45/rtconfig.h | 1 + bsp/beaglebone/.config | 1 + bsp/beaglebone/rtconfig.h | 1 + bsp/ck802/.config | 1 + bsp/ck802/rtconfig.h | 1 + bsp/dm365/.config | 1 + bsp/dm365/rtconfig.h | 1 + bsp/efm32/rtconfig.h | 1 + bsp/es32f0334/.config | 1 + bsp/es32f0334/rtconfig.h | 1 + bsp/es32f0654/.config | 1 + bsp/es32f0654/rtconfig.h | 1 + bsp/fh8620/rtconfig.h | 1 + bsp/frdm-k64f/rtconfig.h | 1 + bsp/gd32303e-eval/.config | 1 + bsp/gd32303e-eval/rtconfig.h | 1 + bsp/gd32450z-eval/.config | 1 + bsp/gd32450z-eval/rtconfig.h | 1 + bsp/gkipc/.config | 1 + bsp/gkipc/rtconfig.h | 1 + bsp/hifive1/.config | 1 + bsp/hifive1/rtconfig.h | 1 + bsp/imx6sx/cortex-a9/.config | 1 + bsp/imx6sx/cortex-a9/rtconfig.h | 1 + bsp/imx6ul/rtconfig.h | 1 + bsp/imxrt/Libraries/imxrt1050/drivers/drv_eth.c | 2 -- .../Libraries/imxrt1050/drivers/drv_eth_fire.c | 2 -- .../imxrt1050/drivers/drv_flexspi_hyper.c | 4 +-- .../Libraries/imxrt1050/drivers/drv_flexspi_nor.c | 5 ++-- bsp/imxrt/imxrt1050-ArchMix/.config | 1 + bsp/imxrt/imxrt1050-ArchMix/rtconfig.h | 1 + bsp/imxrt/imxrt1050-evk/.config | 1 + bsp/imxrt/imxrt1050-evk/rtconfig.h | 1 + bsp/k210/.config | 1 + bsp/k210/rtconfig.h | 1 + bsp/lm4f232/rtconfig.h | 1 + bsp/lpc176x/rtconfig.h | 1 + bsp/lpc178x/rtconfig.h | 1 + bsp/lpc2148/rtconfig.h | 1 + bsp/lpc408x/.config | 1 + bsp/lpc408x/rtconfig.h | 1 + bsp/lpc43xx/M0/rtconfig.h | 1 + bsp/lpc43xx/M4/rtconfig.h | 1 + bsp/lpc5410x/rtconfig.h | 1 + bsp/lpc54114-lite/.config | 1 + bsp/lpc54114-lite/rtconfig.h | 1 + bsp/lpc54608-LPCXpresso/.config | 1 + bsp/lpc54608-LPCXpresso/rtconfig.h | 1 + bsp/ls1bdev/rtconfig.h | 1 + bsp/ls1cdev/.config | 1 + bsp/ls1cdev/rtconfig.h | 1 + bsp/m16c62p/rtconfig.h | 1 + bsp/mb9bf568r/rtconfig.h | 1 + bsp/mb9bf618s/rtconfig.h | 1 + bsp/mini4020/rtconfig.h | 1 + bsp/nios_ii/rtconfig.h | 1 + bsp/nrf51822/rtconfig.h | 1 + bsp/nuvoton_m05x/.config | 1 + bsp/nuvoton_m05x/rtconfig.h | 1 + bsp/nuvoton_m451/rtconfig.h | 1 + bsp/nuvoton_m487/.config | 1 + bsp/nuvoton_m487/rtconfig.h | 1 + bsp/nuvoton_nuc472/rtconfig.h | 1 + bsp/pic32ethernet/rtconfig.h | 1 + bsp/qemu-vexpress-a9/.config | 30 +--------------------- bsp/qemu-vexpress-a9/drivers/audio/drv_pl041.c | 2 -- bsp/qemu-vexpress-a9/drivers/drv_keyboard.c | 7 ++--- bsp/qemu-vexpress-a9/drivers/drv_mouse.c | 8 +++--- bsp/qemu-vexpress-a9/drivers/drv_sdio.c | 14 +++++----- bsp/qemu-vexpress-a9/rtconfig.h | 7 +---- bsp/qemu-vexpress-gemini/.config | 1 + bsp/qemu-vexpress-gemini/rtconfig.h | 1 + bsp/raspi2/.config | 1 + bsp/raspi2/rtconfig.h | 1 + bsp/realview-a8/rtconfig.h | 1 + bsp/rv32m1_vega/ri5cy/.config | 1 + bsp/rv32m1_vega/ri5cy/rtconfig.h | 1 + bsp/rx/rtconfig.h | 1 + bsp/samd21/rtconfig.h | 1 + bsp/sep6200/rtconfig.h | 2 +- bsp/simulator/.config | 1 + bsp/simulator/rtconfig.h | 1 + bsp/stm32/libraries/HAL_Drivers/drv_log.h | 3 --- bsp/stm32/libraries/templates/stm32f0xx/.config | 1 + bsp/stm32/libraries/templates/stm32f0xx/rtconfig.h | 1 + bsp/stm32/libraries/templates/stm32f10x/.config | 1 + bsp/stm32/libraries/templates/stm32f10x/rtconfig.h | 1 + bsp/stm32/libraries/templates/stm32f4xx/.config | 1 + bsp/stm32/libraries/templates/stm32f4xx/rtconfig.h | 1 + bsp/stm32/libraries/templates/stm32f7xx/.config | 1 + bsp/stm32/libraries/templates/stm32f7xx/rtconfig.h | 1 + bsp/stm32/libraries/templates/stm32l4xx/.config | 1 + bsp/stm32/libraries/templates/stm32l4xx/rtconfig.h | 1 + bsp/stm32/stm32f091-st-nucleo/.config | 1 + bsp/stm32/stm32f091-st-nucleo/rtconfig.h | 1 + bsp/stm32/stm32f103-atk-nano/.config | 1 + bsp/stm32/stm32f103-atk-nano/rtconfig.h | 1 + bsp/stm32/stm32f103-dofly-lyc8/.config | 1 + bsp/stm32/stm32f103-dofly-lyc8/rtconfig.h | 1 + bsp/stm32/stm32f103-fire-arbitrary/.config | 1 + .../board/ports/sdcard_port.c | 3 --- bsp/stm32/stm32f103-fire-arbitrary/rtconfig.h | 1 + bsp/stm32/stm32f103-hw100k-ibox/.config | 1 + bsp/stm32/stm32f103-hw100k-ibox/rtconfig.h | 1 + bsp/stm32/stm32f107-uc-eval/.config | 1 + bsp/stm32/stm32f107-uc-eval/rtconfig.h | 1 + bsp/stm32/stm32f405-smdz-breadfruit/.config | 1 + bsp/stm32/stm32f405-smdz-breadfruit/rtconfig.h | 1 + bsp/stm32/stm32f407-atk-explorer/.config | 1 + .../board/ports/sdcard_port.c | 3 --- bsp/stm32/stm32f407-atk-explorer/rtconfig.h | 1 + bsp/stm32/stm32f407-st-discovery/.config | 1 + bsp/stm32/stm32f407-st-discovery/rtconfig.h | 1 + bsp/stm32/stm32f411-st-nucleo/.config | 1 + bsp/stm32/stm32f411-st-nucleo/rtconfig.h | 1 + bsp/stm32/stm32f429-armfly-v6/.config | 1 + .../stm32f429-armfly-v6/board/ports/sdcard_port.c | 3 --- bsp/stm32/stm32f429-armfly-v6/rtconfig.h | 1 + bsp/stm32/stm32f429-atk-apollo/.config | 1 + .../stm32f429-atk-apollo/board/ports/sdcard_port.c | 3 --- bsp/stm32/stm32f429-atk-apollo/rtconfig.h | 1 + bsp/stm32/stm32f429-fire-challenger/.config | 1 + .../board/ports/sdcard_port.c | 3 --- bsp/stm32/stm32f429-fire-challenger/rtconfig.h | 1 + bsp/stm32/stm32f446-st-nucleo/.config | 1 + bsp/stm32/stm32f446-st-nucleo/rtconfig.h | 1 + bsp/stm32/stm32f746-st-disco/.config | 1 + .../stm32f746-st-disco/board/ports/sdcard_port.c | 3 --- bsp/stm32/stm32f746-st-disco/rtconfig.h | 1 + bsp/stm32/stm32f767-atk-apollo/.config | 1 + .../stm32f767-atk-apollo/board/ports/sdcard_port.c | 3 --- bsp/stm32/stm32f767-atk-apollo/rtconfig.h | 1 + bsp/stm32/stm32f767-fire-challenger/.config | 1 + .../board/ports/sdcard_port.c | 4 +-- bsp/stm32/stm32f767-fire-challenger/rtconfig.h | 1 + bsp/stm32/stm32f767-st-nucleo/rtconfig.h | 1 + bsp/stm32/stm32g071-st-nucleo/.config | 1 + bsp/stm32/stm32g071-st-nucleo/rtconfig.h | 1 + bsp/stm32/stm32l053-st-nucleo/.config | 1 + bsp/stm32/stm32l053-st-nucleo/rtconfig.h | 1 + bsp/stm32/stm32l432-st-nucleo/.config | 1 + bsp/stm32/stm32l432-st-nucleo/rtconfig.h | 1 + bsp/stm32/stm32l475-atk-pandora/.config | 1 + .../board/ports/sdcard_port.c | 4 +-- bsp/stm32/stm32l475-atk-pandora/rtconfig.h | 1 + bsp/stm32/stm32l476-st-nucleo/.config | 1 + bsp/stm32/stm32l476-st-nucleo/rtconfig.h | 1 + bsp/stm32/stm32l496-ali-developer/.config | 1 + .../board/ports/sdcard_port.c | 4 +-- bsp/stm32/stm32l496-ali-developer/rtconfig.h | 1 + bsp/stm32f0x/rtconfig.h | 1 + bsp/stm32f107/.config | 1 + bsp/stm32f107/rtconfig.h | 1 + bsp/stm32f10x-HAL/.config | 1 + bsp/stm32f10x-HAL/rtconfig.h | 1 + bsp/stm32f10x/.config | 1 + bsp/stm32f10x/rtconfig.h | 1 + bsp/stm32f20x/.config | 1 + bsp/stm32f20x/rtconfig.h | 1 + bsp/stm32f40x/.config | 1 + bsp/stm32f40x/rtconfig.h | 1 + bsp/stm32f429-apollo/.config | 1 + bsp/stm32f429-apollo/drivers/audio/drv_mic.c | 2 -- bsp/stm32f429-apollo/drivers/audio/drv_sound.c | 2 -- bsp/stm32f429-apollo/rtconfig.h | 1 + bsp/stm32f429-disco/.config | 1 + bsp/stm32f429-disco/rtconfig.h | 1 + bsp/stm32f4xx-HAL/.config | 1 + bsp/stm32f4xx-HAL/rtconfig.h | 1 + bsp/stm32f7-disco/.config | 1 + bsp/stm32f7-disco/rtconfig.h | 1 + bsp/stm32h743-nucleo/.config | 1 + bsp/stm32h743-nucleo/rtconfig.h | 1 + bsp/stm32l475-iot-disco/rtconfig.h | 1 + bsp/stm32l476-nucleo/.config | 1 + bsp/stm32l476-nucleo/rtconfig.h | 1 + bsp/swm320-lq100/.config | 1 + bsp/swm320-lq100/rtconfig.h | 1 + bsp/synopsys/emsk_em9d/.config | 1 + bsp/synopsys/emsk_em9d/rtconfig.h | 1 + bsp/tm4c129x/.config | 1 + bsp/tm4c129x/rtconfig.h | 1 + bsp/tms320f28379d/.config | 1 + bsp/tms320f28379d/rtconfig.h | 1 + bsp/upd70f3454/rtconfig.h | 1 + bsp/x1000/.config | 1 + bsp/x1000/drivers/mmc/drv_mmc.c | 8 ++---- bsp/x1000/rtconfig.h | 1 + bsp/x86/rtconfig.h | 1 + bsp/xplorer4330/M0/rtconfig.h | 1 + bsp/xplorer4330/M4/rtconfig.h | 1 + bsp/zynq7000/rtconfig.h | 1 + components/dfs/include/dfs_private.h | 4 +-- components/drivers/misc/adc.c | 2 -- components/drivers/sdio/block_dev.c | 4 +-- components/drivers/sdio/mmc.c | 2 -- components/drivers/sdio/mmcsd_core.c | 2 -- components/drivers/sdio/sd.c | 2 -- components/drivers/sdio/sdio.c | 2 -- components/drivers/sensors/sensor.c | 2 -- components/drivers/sensors/sensor_cmd.c | 2 -- components/drivers/serial/serial.c | 4 +-- components/drivers/wlan/wlan_cfg.c | 2 -- components/drivers/wlan/wlan_dev.c | 2 -- components/drivers/wlan/wlan_lwip.c | 2 -- components/drivers/wlan/wlan_mgnt.c | 3 +-- components/drivers/wlan/wlan_prot.c | 2 -- components/drivers/wlan/wlan_workqueue.c | 2 -- components/libc/libdl/dlelf.c | 2 -- components/libc/libdl/dlmodule.c | 2 -- components/lwp/lwp.c | 2 -- components/lwp/lwp_mem.c | 2 -- components/lwp/lwp_syscall.c | 2 -- components/net/at/include/at_log.h | 3 --- components/net/sal_socket/src/sal_socket.c | 4 +-- components/utilities/Kconfig | 6 ----- components/utilities/ulog/ulog_def.h | 2 +- components/utilities/utest/utest.c | 4 --- components/utilities/utest/utest_log.h | 4 --- examples/network/tcpclient.c | 2 -- examples/network/tcpserver.c | 2 -- examples/network/udpclient.c | 2 -- examples/network/udpserver.c | 2 -- include/rtdbg.h | 16 ++++++++---- src/Kconfig | 4 +++ src/signal.c | 4 +-- 242 files changed, 223 insertions(+), 202 deletions(-) (limited to 'examples') diff --git a/bsp/CME_M7/rtconfig.h b/bsp/CME_M7/rtconfig.h index 886c28cb9e..f65f6f7600 100644 --- a/bsp/CME_M7/rtconfig.h +++ b/bsp/CME_M7/rtconfig.h @@ -17,6 +17,7 @@ /* SECTION: RT_DEBUG */ /* Thread Debug */ #define RT_DEBUG +#define RT_DEBUG_COLOR #define RT_USING_OVERFLOW_CHECK /* Using Hook */ diff --git a/bsp/allwinner_tina/.config b/bsp/allwinner_tina/.config index de547c5a34..2c39e4435e 100644 --- a/bsp/allwinner_tina/.config +++ b/bsp/allwinner_tina/.config @@ -14,6 +14,7 @@ CONFIG_RT_THREAD_PRIORITY_32=y CONFIG_RT_THREAD_PRIORITY_MAX=32 CONFIG_RT_TICK_PER_SECOND=100 CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y CONFIG_RT_USING_OVERFLOW_CHECK=y CONFIG_RT_DEBUG_INIT=0 CONFIG_RT_DEBUG_THREAD=0 diff --git a/bsp/allwinner_tina/drivers/drv_gpio.c b/bsp/allwinner_tina/drivers/drv_gpio.c index 2c3b6e1865..e8d82a3fae 100644 --- a/bsp/allwinner_tina/drivers/drv_gpio.c +++ b/bsp/allwinner_tina/drivers/drv_gpio.c @@ -27,13 +27,10 @@ #include "drv_gpio.h" #include "interrupt.h" -#define DBG_ENABLE #define DBG_SECTION_NAME "GPIO" #define DBG_LEVEL DBG_WARNING -#define DBG_COLOR #include - #define readl(addr) (*(volatile unsigned int *)(addr)) #define writel(value,addr) (*(volatile unsigned int *)(addr) = (value)) diff --git a/bsp/allwinner_tina/drivers/drv_sdio.c b/bsp/allwinner_tina/drivers/drv_sdio.c index 12cb437f42..c1b4bcc41c 100644 --- a/bsp/allwinner_tina/drivers/drv_sdio.c +++ b/bsp/allwinner_tina/drivers/drv_sdio.c @@ -32,13 +32,12 @@ #include "drv_gpio.h" #include "drv_clock.h" -#define DBG_ENABLE + #define DBG_SECTION_NAME "MMC" // #define DBG_LEVEL DBG_LOG // #define DBG_LEVEL DBG_INFO #define DBG_LEVEL DBG_WARNING // #define DBG_LEVEL DBG_ERROR -#define DBG_COLOR #include #ifdef RT_USING_SDIO diff --git a/bsp/allwinner_tina/drivers/spi/drv_spi.c b/bsp/allwinner_tina/drivers/spi/drv_spi.c index 6e76cbec3e..a271c2e7d9 100644 --- a/bsp/allwinner_tina/drivers/spi/drv_spi.c +++ b/bsp/allwinner_tina/drivers/spi/drv_spi.c @@ -35,14 +35,12 @@ //#define DEBUG -#define DBG_ENABLE #define DBG_SECTION_NAME "SPI" #ifdef DEBUG #define DBG_LEVEL DBG_LOG #else #define DBG_LEVEL DBG_WARNING #endif /* DEBUG */ -#define DBG_COLOR #include #ifdef RT_USING_SPI diff --git a/bsp/allwinner_tina/drivers/spi/drv_spi_flash.c b/bsp/allwinner_tina/drivers/spi/drv_spi_flash.c index 6dc1b1b334..0b01200ee8 100644 --- a/bsp/allwinner_tina/drivers/spi/drv_spi_flash.c +++ b/bsp/allwinner_tina/drivers/spi/drv_spi_flash.c @@ -26,10 +26,8 @@ #include #include -#define DBG_ENABLE #define DBG_SECTION_NAME "FLASH" #define DBG_LEVEL DBG_LOG -#define DBG_COLOR #include #define SPI_FLASH_DEVICE_NAME "spi00" diff --git a/bsp/allwinner_tina/rtconfig.h b/bsp/allwinner_tina/rtconfig.h index 25a1302b1a..b9221509b4 100644 --- a/bsp/allwinner_tina/rtconfig.h +++ b/bsp/allwinner_tina/rtconfig.h @@ -14,6 +14,7 @@ #define RT_THREAD_PRIORITY_MAX 32 #define RT_TICK_PER_SECOND 100 #define RT_DEBUG +#define RT_DEBUG_COLOR #define RT_USING_OVERFLOW_CHECK #define RT_DEBUG_INIT 0 #define RT_DEBUG_THREAD 0 diff --git a/bsp/amebaz/.config b/bsp/amebaz/.config index 9412058c8e..ceaafae7a1 100644 --- a/bsp/amebaz/.config +++ b/bsp/amebaz/.config @@ -21,6 +21,7 @@ CONFIG_RT_USING_TIMER_SOFT=y CONFIG_RT_TIMER_THREAD_PRIO=4 CONFIG_RT_TIMER_THREAD_STACK_SIZE=1024 CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/amebaz/drivers/wlan/drv_wifi.c b/bsp/amebaz/drivers/wlan/drv_wifi.c index 7e62ed1acf..753952df43 100644 --- a/bsp/amebaz/drivers/wlan/drv_wifi.c +++ b/bsp/amebaz/drivers/wlan/drv_wifi.c @@ -28,10 +28,8 @@ #include "drv_wlan.h" #include "drv_wifi.h" -#define DBG_ENABLE #define DBG_LEVEL DBG_INFO #define DBG_SECTION_NAME "WIFI" -#define DBG_COLOR #include #define MAX_ADDR_LEN (6) diff --git a/bsp/amebaz/rtconfig.h b/bsp/amebaz/rtconfig.h index 92bac2d294..f018b43d9d 100644 --- a/bsp/amebaz/rtconfig.h +++ b/bsp/amebaz/rtconfig.h @@ -19,6 +19,7 @@ #define RT_TIMER_THREAD_PRIO 4 #define RT_TIMER_THREAD_STACK_SIZE 1024 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/apollo2/rtconfig.h b/bsp/apollo2/rtconfig.h index dfa458bc4e..d8ac639c86 100644 --- a/bsp/apollo2/rtconfig.h +++ b/bsp/apollo2/rtconfig.h @@ -11,6 +11,7 @@ #define RT_THREAD_PRIORITY_MAX 32 #define RT_TICK_PER_SECOND 500 #define RT_DEBUG +#define RT_DEBUG_COLOR #define RT_USING_OVERFLOW_CHECK #define RT_DEBUG_INIT 0 #define RT_DEBUG_THREAD 0 diff --git a/bsp/asm9260t/.config b/bsp/asm9260t/.config index e634c994c8..04964a8375 100644 --- a/bsp/asm9260t/.config +++ b/bsp/asm9260t/.config @@ -11,6 +11,7 @@ CONFIG_RT_ALIGN_SIZE=4 CONFIG_RT_THREAD_PRIORITY_MAX=32 CONFIG_RT_TICK_PER_SECOND=100 CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y CONFIG_RT_USING_OVERFLOW_CHECK=y CONFIG_RT_DEBUG_INIT=0 # CONFIG_RT_DEBUG_THREAD is not set diff --git a/bsp/asm9260t/rtconfig.h b/bsp/asm9260t/rtconfig.h index bf1f76fefb..8ca5daa565 100644 --- a/bsp/asm9260t/rtconfig.h +++ b/bsp/asm9260t/rtconfig.h @@ -11,6 +11,7 @@ #define RT_THREAD_PRIORITY_MAX 32 #define RT_TICK_PER_SECOND 100 #define RT_DEBUG +#define RT_DEBUG_COLOR #define RT_USING_OVERFLOW_CHECK #define RT_DEBUG_INIT 0 /* RT_DEBUG_THREAD is not set */ diff --git a/bsp/at91sam9260/.config b/bsp/at91sam9260/.config index a19ac15d3d..c669ac5fe1 100644 --- a/bsp/at91sam9260/.config +++ b/bsp/at91sam9260/.config @@ -19,6 +19,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=256 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/at91sam9260/rtconfig.h b/bsp/at91sam9260/rtconfig.h index 816054c3e1..0c6e595e5e 100755 --- a/bsp/at91sam9260/rtconfig.h +++ b/bsp/at91sam9260/rtconfig.h @@ -16,6 +16,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 256 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/at91sam9g45/.config b/bsp/at91sam9g45/.config index 5f3ae78673..b0599d74f7 100644 --- a/bsp/at91sam9g45/.config +++ b/bsp/at91sam9g45/.config @@ -19,6 +19,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=256 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/at91sam9g45/rtconfig.h b/bsp/at91sam9g45/rtconfig.h index 5d638ce1c9..755f9bbfc2 100644 --- a/bsp/at91sam9g45/rtconfig.h +++ b/bsp/at91sam9g45/rtconfig.h @@ -16,6 +16,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 256 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/beaglebone/.config b/bsp/beaglebone/.config index 409e89d18e..784324cf75 100644 --- a/bsp/beaglebone/.config +++ b/bsp/beaglebone/.config @@ -19,6 +19,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=256 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/beaglebone/rtconfig.h b/bsp/beaglebone/rtconfig.h index c49528049d..00460b5566 100644 --- a/bsp/beaglebone/rtconfig.h +++ b/bsp/beaglebone/rtconfig.h @@ -16,6 +16,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 256 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/ck802/.config b/bsp/ck802/.config index e91f93fd0e..3bd8636aae 100644 --- a/bsp/ck802/.config +++ b/bsp/ck802/.config @@ -14,6 +14,7 @@ CONFIG_RT_THREAD_PRIORITY_32=y CONFIG_RT_THREAD_PRIORITY_MAX=32 CONFIG_RT_TICK_PER_SECOND=100 CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y CONFIG_RT_USING_OVERFLOW_CHECK=y CONFIG_RT_DEBUG_INIT=0 CONFIG_RT_DEBUG_THREAD=0 diff --git a/bsp/ck802/rtconfig.h b/bsp/ck802/rtconfig.h index 076d48e534..4e3b217f93 100644 --- a/bsp/ck802/rtconfig.h +++ b/bsp/ck802/rtconfig.h @@ -12,6 +12,7 @@ #define RT_THREAD_PRIORITY_MAX 32 #define RT_TICK_PER_SECOND 100 #define RT_DEBUG +#define RT_DEBUG_COLOR #define RT_USING_OVERFLOW_CHECK #define RT_DEBUG_INIT 0 #define RT_DEBUG_THREAD 0 diff --git a/bsp/dm365/.config b/bsp/dm365/.config index 6974ff8ae0..761ecf2cf1 100644 --- a/bsp/dm365/.config +++ b/bsp/dm365/.config @@ -21,6 +21,7 @@ CONFIG_RT_USING_TIMER_SOFT=y CONFIG_RT_TIMER_THREAD_PRIO=8 CONFIG_RT_TIMER_THREAD_STACK_SIZE=512 CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/dm365/rtconfig.h b/bsp/dm365/rtconfig.h index 4f3698f124..5fc198c0cf 100644 --- a/bsp/dm365/rtconfig.h +++ b/bsp/dm365/rtconfig.h @@ -21,6 +21,7 @@ #define RT_TIMER_THREAD_PRIO 8 #define RT_TIMER_THREAD_STACK_SIZE 512 #define RT_DEBUG +#define RT_DEBUG_COLOR /* RT_DEBUG_INIT_CONFIG is not set */ /* RT_DEBUG_THREAD_CONFIG is not set */ /* RT_DEBUG_SCHEDULER_CONFIG is not set */ diff --git a/bsp/efm32/rtconfig.h b/bsp/efm32/rtconfig.h index 882e36f396..4ee9bf1a8e 100644 --- a/bsp/efm32/rtconfig.h +++ b/bsp/efm32/rtconfig.h @@ -35,6 +35,7 @@ /* SECTION: RT_DEBUG */ #define RT_DEBUG +#define RT_DEBUG_COLOR //#define RT_DEBUG_MEM (1) //#define RT_DEBUG_SCHEDULER (1) //#define RT_DEBUG_IPC (1) diff --git a/bsp/es32f0334/.config b/bsp/es32f0334/.config index 885ad72c98..aeccdd7e22 100644 --- a/bsp/es32f0334/.config +++ b/bsp/es32f0334/.config @@ -21,6 +21,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=256 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/es32f0334/rtconfig.h b/bsp/es32f0334/rtconfig.h index 09c7493ada..8435637828 100644 --- a/bsp/es32f0334/rtconfig.h +++ b/bsp/es32f0334/rtconfig.h @@ -17,6 +17,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 256 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/es32f0654/.config b/bsp/es32f0654/.config index 5cb6e5853b..ced622f5ff 100644 --- a/bsp/es32f0654/.config +++ b/bsp/es32f0654/.config @@ -21,6 +21,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=256 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/es32f0654/rtconfig.h b/bsp/es32f0654/rtconfig.h index 9500598676..77e177cc25 100644 --- a/bsp/es32f0654/rtconfig.h +++ b/bsp/es32f0654/rtconfig.h @@ -17,6 +17,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 256 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/fh8620/rtconfig.h b/bsp/fh8620/rtconfig.h index 01a2d2d45c..ea210a4703 100644 --- a/bsp/fh8620/rtconfig.h +++ b/bsp/fh8620/rtconfig.h @@ -24,6 +24,7 @@ #define RT_USING_CPU_FFS //
#define RT_DEBUG +#define RT_DEBUG_COLOR // // #define RT_THREAD_DEBUG // diff --git a/bsp/frdm-k64f/rtconfig.h b/bsp/frdm-k64f/rtconfig.h index 8d0ad639ce..6338b39edb 100644 --- a/bsp/frdm-k64f/rtconfig.h +++ b/bsp/frdm-k64f/rtconfig.h @@ -17,6 +17,7 @@ /* SECTION: RT_DEBUG */ /* Thread Debug */ #define RT_DEBUG +#define RT_DEBUG_COLOR #define RT_USING_OVERFLOW_CHECK diff --git a/bsp/gd32303e-eval/.config b/bsp/gd32303e-eval/.config index b61d310f03..40cac74cf7 100644 --- a/bsp/gd32303e-eval/.config +++ b/bsp/gd32303e-eval/.config @@ -14,6 +14,7 @@ CONFIG_RT_THREAD_PRIORITY_32=y CONFIG_RT_THREAD_PRIORITY_MAX=32 CONFIG_RT_TICK_PER_SECOND=100 CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y CONFIG_RT_USING_OVERFLOW_CHECK=y CONFIG_RT_DEBUG_INIT=0 CONFIG_RT_DEBUG_THREAD=0 diff --git a/bsp/gd32303e-eval/rtconfig.h b/bsp/gd32303e-eval/rtconfig.h index 479ad99af5..77e9056395 100644 --- a/bsp/gd32303e-eval/rtconfig.h +++ b/bsp/gd32303e-eval/rtconfig.h @@ -12,6 +12,7 @@ #define RT_THREAD_PRIORITY_MAX 32 #define RT_TICK_PER_SECOND 100 #define RT_DEBUG +#define RT_DEBUG_COLOR #define RT_USING_OVERFLOW_CHECK #define RT_DEBUG_INIT 0 #define RT_DEBUG_THREAD 0 diff --git a/bsp/gd32450z-eval/.config b/bsp/gd32450z-eval/.config index e2f00a07fc..a8b61c6b69 100644 --- a/bsp/gd32450z-eval/.config +++ b/bsp/gd32450z-eval/.config @@ -19,6 +19,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=256 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/gd32450z-eval/rtconfig.h b/bsp/gd32450z-eval/rtconfig.h index 500aab6290..42601f4ca9 100644 --- a/bsp/gd32450z-eval/rtconfig.h +++ b/bsp/gd32450z-eval/rtconfig.h @@ -16,6 +16,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 256 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/gkipc/.config b/bsp/gkipc/.config index 975b82b5b2..9ef3dadbde 100644 --- a/bsp/gkipc/.config +++ b/bsp/gkipc/.config @@ -14,6 +14,7 @@ CONFIG_RT_THREAD_PRIORITY_256=y CONFIG_RT_THREAD_PRIORITY_MAX=256 CONFIG_RT_TICK_PER_SECOND=100 CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y CONFIG_RT_USING_OVERFLOW_CHECK=y CONFIG_RT_DEBUG_INIT=0 CONFIG_RT_DEBUG_THREAD=0 diff --git a/bsp/gkipc/rtconfig.h b/bsp/gkipc/rtconfig.h index 2c0233cf29..82262adfd5 100644 --- a/bsp/gkipc/rtconfig.h +++ b/bsp/gkipc/rtconfig.h @@ -14,6 +14,7 @@ #define RT_THREAD_PRIORITY_MAX 256 #define RT_TICK_PER_SECOND 100 #define RT_DEBUG +#define RT_DEBUG_COLOR #define RT_USING_OVERFLOW_CHECK #define RT_DEBUG_INIT 0 #define RT_DEBUG_THREAD 0 diff --git a/bsp/hifive1/.config b/bsp/hifive1/.config index 9f66767320..af1e58a0e4 100644 --- a/bsp/hifive1/.config +++ b/bsp/hifive1/.config @@ -21,6 +21,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=1024 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/hifive1/rtconfig.h b/bsp/hifive1/rtconfig.h index 1d96bfc3db..8f4bb37892 100644 --- a/bsp/hifive1/rtconfig.h +++ b/bsp/hifive1/rtconfig.h @@ -17,6 +17,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 1024 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/imx6sx/cortex-a9/.config b/bsp/imx6sx/cortex-a9/.config index ce2e256f2c..a43422d533 100644 --- a/bsp/imx6sx/cortex-a9/.config +++ b/bsp/imx6sx/cortex-a9/.config @@ -19,6 +19,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=256 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/imx6sx/cortex-a9/rtconfig.h b/bsp/imx6sx/cortex-a9/rtconfig.h index 30de937b05..f11ddac2a1 100644 --- a/bsp/imx6sx/cortex-a9/rtconfig.h +++ b/bsp/imx6sx/cortex-a9/rtconfig.h @@ -16,6 +16,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 256 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/imx6ul/rtconfig.h b/bsp/imx6ul/rtconfig.h index ee3857dcb8..2b034ac76b 100644 --- a/bsp/imx6ul/rtconfig.h +++ b/bsp/imx6ul/rtconfig.h @@ -20,6 +20,7 @@ #define IDLE_THREAD_STACK_SIZE 512 //
#define RT_DEBUG +#define RT_DEBUG_COLOR // // #define RT_DEBUG_SCHEDULER 1 // diff --git a/bsp/imxrt/Libraries/imxrt1050/drivers/drv_eth.c b/bsp/imxrt/Libraries/imxrt1050/drivers/drv_eth.c index 54666a7b1c..f68373b535 100644 --- a/bsp/imxrt/Libraries/imxrt1050/drivers/drv_eth.c +++ b/bsp/imxrt/Libraries/imxrt1050/drivers/drv_eth.c @@ -46,9 +46,7 @@ //#define ETH_RX_DUMP //#define ETH_TX_DUMP -#define DBG_ENABLE #define DBG_SECTION_NAME "ETH" -#define DBG_COLOR #define DBG_LEVEL DBG_INFO #include diff --git a/bsp/imxrt/Libraries/imxrt1050/drivers/drv_eth_fire.c b/bsp/imxrt/Libraries/imxrt1050/drivers/drv_eth_fire.c index 30b9e13306..1cae69ba17 100644 --- a/bsp/imxrt/Libraries/imxrt1050/drivers/drv_eth_fire.c +++ b/bsp/imxrt/Libraries/imxrt1050/drivers/drv_eth_fire.c @@ -37,9 +37,7 @@ //#define ETH_RX_DUMP //#define ETH_TX_DUMP -#define DBG_ENABLE #define DBG_SECTION_NAME "ETH" -#define DBG_COLOR #define DBG_LEVEL DBG_LOG #include diff --git a/bsp/imxrt/Libraries/imxrt1050/drivers/drv_flexspi_hyper.c b/bsp/imxrt/Libraries/imxrt1050/drivers/drv_flexspi_hyper.c index aa851f7b39..5ca326070c 100644 --- a/bsp/imxrt/Libraries/imxrt1050/drivers/drv_flexspi_hyper.c +++ b/bsp/imxrt/Libraries/imxrt1050/drivers/drv_flexspi_hyper.c @@ -14,10 +14,8 @@ #include #include "drv_flexspi.h" -#define DBG_ENABLE -#define DBG_SECTION_NAME "[Hyper]" +#define DBG_SECTION_NAME "Hyper" #define DBG_LEVEL DBG_LOG -#define DBG_COLOR #include #define FLEXSPI_CLOCK kCLOCK_FlexSpi diff --git a/bsp/imxrt/Libraries/imxrt1050/drivers/drv_flexspi_nor.c b/bsp/imxrt/Libraries/imxrt1050/drivers/drv_flexspi_nor.c index c48e43c2e0..4e9e738b6c 100644 --- a/bsp/imxrt/Libraries/imxrt1050/drivers/drv_flexspi_nor.c +++ b/bsp/imxrt/Libraries/imxrt1050/drivers/drv_flexspi_nor.c @@ -12,10 +12,9 @@ #include "board.h" #include #include "drv_flexspi.h" -#define DBG_ENABLE -#define DBG_SECTION_NAME "[FLEXSPI]" + +#define DBG_SECTION_NAME "FLEXSPI" #define DBG_LEVEL DBG_LOG -#define DBG_COLOR #include #define FLEXSPI_CLOCK kCLOCK_FlexSpi diff --git a/bsp/imxrt/imxrt1050-ArchMix/.config b/bsp/imxrt/imxrt1050-ArchMix/.config index 43dcdd1b75..35624f7169 100644 --- a/bsp/imxrt/imxrt1050-ArchMix/.config +++ b/bsp/imxrt/imxrt1050-ArchMix/.config @@ -21,6 +21,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=256 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/imxrt/imxrt1050-ArchMix/rtconfig.h b/bsp/imxrt/imxrt1050-ArchMix/rtconfig.h index 67e3f4632b..7f82bba585 100644 --- a/bsp/imxrt/imxrt1050-ArchMix/rtconfig.h +++ b/bsp/imxrt/imxrt1050-ArchMix/rtconfig.h @@ -17,6 +17,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 256 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/imxrt/imxrt1050-evk/.config b/bsp/imxrt/imxrt1050-evk/.config index e49cad6287..f89d1573ec 100644 --- a/bsp/imxrt/imxrt1050-evk/.config +++ b/bsp/imxrt/imxrt1050-evk/.config @@ -21,6 +21,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=256 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/imxrt/imxrt1050-evk/rtconfig.h b/bsp/imxrt/imxrt1050-evk/rtconfig.h index 156ef1f258..d84cda40ad 100644 --- a/bsp/imxrt/imxrt1050-evk/rtconfig.h +++ b/bsp/imxrt/imxrt1050-evk/rtconfig.h @@ -17,6 +17,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 256 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/k210/.config b/bsp/k210/.config index 65164c210d..dca21c52c8 100644 --- a/bsp/k210/.config +++ b/bsp/k210/.config @@ -22,6 +22,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=1024 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y CONFIG_RT_DEBUG_INIT_CONFIG=y CONFIG_RT_DEBUG_INIT=1 # CONFIG_RT_DEBUG_THREAD_CONFIG is not set diff --git a/bsp/k210/rtconfig.h b/bsp/k210/rtconfig.h index 94844cbf88..97e0236108 100644 --- a/bsp/k210/rtconfig.h +++ b/bsp/k210/rtconfig.h @@ -22,6 +22,7 @@ #define IDLE_THREAD_STACK_SIZE 1024 /* RT_USING_TIMER_SOFT is not set */ #define RT_DEBUG +#define RT_DEBUG_COLOR #define RT_DEBUG_INIT_CONFIG #define RT_DEBUG_INIT 1 /* RT_DEBUG_THREAD_CONFIG is not set */ diff --git a/bsp/lm4f232/rtconfig.h b/bsp/lm4f232/rtconfig.h index 75a826ff4f..52844dc578 100644 --- a/bsp/lm4f232/rtconfig.h +++ b/bsp/lm4f232/rtconfig.h @@ -17,6 +17,7 @@ /* SECTION: RT_DEBUG */ /* Thread Debug */ #define RT_DEBUG +#define RT_DEBUG_COLOR #define RT_USING_OVERFLOW_CHECK diff --git a/bsp/lpc176x/rtconfig.h b/bsp/lpc176x/rtconfig.h index 726b887047..629d7da08f 100644 --- a/bsp/lpc176x/rtconfig.h +++ b/bsp/lpc176x/rtconfig.h @@ -17,6 +17,7 @@ #define RT_TICK_PER_SECOND 100 //
#define RT_DEBUG +#define RT_DEBUG_COLOR // // #define RT_THREAD_DEBUG // diff --git a/bsp/lpc178x/rtconfig.h b/bsp/lpc178x/rtconfig.h index 13f7759b0b..25f99888f7 100644 --- a/bsp/lpc178x/rtconfig.h +++ b/bsp/lpc178x/rtconfig.h @@ -18,6 +18,7 @@ #define RT_TICK_PER_SECOND 100 //
#define RT_DEBUG +#define RT_DEBUG_COLOR // // #define RT_THREAD_DEBUG // diff --git a/bsp/lpc2148/rtconfig.h b/bsp/lpc2148/rtconfig.h index 6343ce5ce6..70a6ef0325 100644 --- a/bsp/lpc2148/rtconfig.h +++ b/bsp/lpc2148/rtconfig.h @@ -17,6 +17,7 @@ /* SECTION: RT_DEBUG */ /* Thread Debug */ #define RT_DEBUG +#define RT_DEBUG_COLOR /* #define RT_THREAD_DEBUG */ #define RT_USING_OVERFLOW_CHECK diff --git a/bsp/lpc408x/.config b/bsp/lpc408x/.config index eed04f9c32..fca755e768 100644 --- a/bsp/lpc408x/.config +++ b/bsp/lpc408x/.config @@ -14,6 +14,7 @@ CONFIG_RT_THREAD_PRIORITY_32=y CONFIG_RT_THREAD_PRIORITY_MAX=32 CONFIG_RT_TICK_PER_SECOND=100 CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y CONFIG_RT_USING_OVERFLOW_CHECK=y CONFIG_RT_DEBUG_INIT=0 CONFIG_RT_DEBUG_THREAD=0 diff --git a/bsp/lpc408x/rtconfig.h b/bsp/lpc408x/rtconfig.h index 0d5469786f..2b046180b4 100644 --- a/bsp/lpc408x/rtconfig.h +++ b/bsp/lpc408x/rtconfig.h @@ -14,6 +14,7 @@ #define RT_THREAD_PRIORITY_MAX 32 #define RT_TICK_PER_SECOND 100 #define RT_DEBUG +#define RT_DEBUG_COLOR #define RT_USING_OVERFLOW_CHECK #define RT_DEBUG_INIT 0 #define RT_DEBUG_THREAD 0 diff --git a/bsp/lpc43xx/M0/rtconfig.h b/bsp/lpc43xx/M0/rtconfig.h index 90531287dd..a4aef7f151 100644 --- a/bsp/lpc43xx/M0/rtconfig.h +++ b/bsp/lpc43xx/M0/rtconfig.h @@ -22,6 +22,7 @@ //#define RT_USING_MODULE //
#define RT_DEBUG +#define RT_DEBUG_COLOR // #define RT_DEBUG_INIT 0 //#define RT_DEBUG_SCHEDULER 1 diff --git a/bsp/lpc43xx/M4/rtconfig.h b/bsp/lpc43xx/M4/rtconfig.h index 0b30998cc0..5e41344165 100644 --- a/bsp/lpc43xx/M4/rtconfig.h +++ b/bsp/lpc43xx/M4/rtconfig.h @@ -22,6 +22,7 @@ //#define RT_USING_MODULE //
#define RT_DEBUG +#define RT_DEBUG_COLOR // #define RT_DEBUG_INIT 0 // diff --git a/bsp/lpc5410x/rtconfig.h b/bsp/lpc5410x/rtconfig.h index c054bfabba..387f1e75e6 100644 --- a/bsp/lpc5410x/rtconfig.h +++ b/bsp/lpc5410x/rtconfig.h @@ -18,6 +18,7 @@ #define RT_TICK_PER_SECOND 100 //
#define RT_DEBUG +#define RT_DEBUG_COLOR // // #define RT_THREAD_DEBUG // diff --git a/bsp/lpc54114-lite/.config b/bsp/lpc54114-lite/.config index 4fae2a9de6..acdb890f05 100644 --- a/bsp/lpc54114-lite/.config +++ b/bsp/lpc54114-lite/.config @@ -21,6 +21,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=256 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/lpc54114-lite/rtconfig.h b/bsp/lpc54114-lite/rtconfig.h index 4fc1054b7b..2d833b3e4d 100644 --- a/bsp/lpc54114-lite/rtconfig.h +++ b/bsp/lpc54114-lite/rtconfig.h @@ -17,6 +17,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 256 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/lpc54608-LPCXpresso/.config b/bsp/lpc54608-LPCXpresso/.config index 85046e050d..f793185bda 100644 --- a/bsp/lpc54608-LPCXpresso/.config +++ b/bsp/lpc54608-LPCXpresso/.config @@ -21,6 +21,7 @@ CONFIG_RT_USING_TIMER_SOFT=y CONFIG_RT_TIMER_THREAD_PRIO=4 CONFIG_RT_TIMER_THREAD_STACK_SIZE=512 CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/lpc54608-LPCXpresso/rtconfig.h b/bsp/lpc54608-LPCXpresso/rtconfig.h index 46855f7713..987439e331 100644 --- a/bsp/lpc54608-LPCXpresso/rtconfig.h +++ b/bsp/lpc54608-LPCXpresso/rtconfig.h @@ -19,6 +19,7 @@ #define RT_TIMER_THREAD_PRIO 4 #define RT_TIMER_THREAD_STACK_SIZE 512 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/ls1bdev/rtconfig.h b/bsp/ls1bdev/rtconfig.h index 67bba7fc68..4135268111 100644 --- a/bsp/ls1bdev/rtconfig.h +++ b/bsp/ls1bdev/rtconfig.h @@ -17,6 +17,7 @@ #define RT_TICK_PER_SECOND 100 //
#define RT_DEBUG +#define RT_DEBUG_COLOR // // #define RT_THREAD_DEBUG // diff --git a/bsp/ls1cdev/.config b/bsp/ls1cdev/.config index 30d3540c58..dd1327ddc8 100644 --- a/bsp/ls1cdev/.config +++ b/bsp/ls1cdev/.config @@ -19,6 +19,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=1024 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/ls1cdev/rtconfig.h b/bsp/ls1cdev/rtconfig.h index 7e140a731c..98ac15d730 100644 --- a/bsp/ls1cdev/rtconfig.h +++ b/bsp/ls1cdev/rtconfig.h @@ -19,6 +19,7 @@ #define IDLE_THREAD_STACK_SIZE 1024 /* RT_USING_TIMER_SOFT is not set */ #define RT_DEBUG +#define RT_DEBUG_COLOR /* RT_DEBUG_INIT_CONFIG is not set */ /* RT_DEBUG_THREAD_CONFIG is not set */ /* RT_DEBUG_SCHEDULER_CONFIG is not set */ diff --git a/bsp/m16c62p/rtconfig.h b/bsp/m16c62p/rtconfig.h index 978fe7af50..adcf67e748 100644 --- a/bsp/m16c62p/rtconfig.h +++ b/bsp/m16c62p/rtconfig.h @@ -17,6 +17,7 @@ /* SECTION: RT_DEBUG */ /* Thread Debug */ #define RT_DEBUG +#define RT_DEBUG_COLOR ///#define SCHEDULER_DEBUG #define RT_USING_OVERFLOW_CHECK diff --git a/bsp/mb9bf568r/rtconfig.h b/bsp/mb9bf568r/rtconfig.h index dc4c61b148..1982028ce7 100644 --- a/bsp/mb9bf568r/rtconfig.h +++ b/bsp/mb9bf568r/rtconfig.h @@ -17,6 +17,7 @@ /* SECTION: RT_DEBUG */ /* Thread Debug */ #define RT_DEBUG +#define RT_DEBUG_COLOR #define RT_USING_OVERFLOW_CHECK /* Using Hook */ diff --git a/bsp/mb9bf618s/rtconfig.h b/bsp/mb9bf618s/rtconfig.h index 85c8719d36..1b647a7a30 100644 --- a/bsp/mb9bf618s/rtconfig.h +++ b/bsp/mb9bf618s/rtconfig.h @@ -17,6 +17,7 @@ /* SECTION: RT_DEBUG */ /* Thread Debug */ #define RT_DEBUG +#define RT_DEBUG_COLOR #define RT_USING_OVERFLOW_CHECK /* Using Hook */ diff --git a/bsp/mini4020/rtconfig.h b/bsp/mini4020/rtconfig.h index bef31bc1a7..c35134731b 100644 --- a/bsp/mini4020/rtconfig.h +++ b/bsp/mini4020/rtconfig.h @@ -17,6 +17,7 @@ /* SECTION: RT_DEBUG */ /* Thread Debug */ #define RT_DEBUG +#define RT_DEBUG_COLOR /* #define RT_THREAD_DEBUG */ #define RT_USING_OVERFLOW_CHECK diff --git a/bsp/nios_ii/rtconfig.h b/bsp/nios_ii/rtconfig.h index 700907e986..fcd3799846 100644 --- a/bsp/nios_ii/rtconfig.h +++ b/bsp/nios_ii/rtconfig.h @@ -21,6 +21,7 @@ /* SECTION: RT_DEBUG */ /* Thread Debug */ #define RT_DEBUG +#define RT_DEBUG_COLOR //#define THREAD_DEBUG //#define SCHEDULER_DEBUG //#define IRQ_DEBUG diff --git a/bsp/nrf51822/rtconfig.h b/bsp/nrf51822/rtconfig.h index b41bbdadfa..ee7cb6b2f4 100644 --- a/bsp/nrf51822/rtconfig.h +++ b/bsp/nrf51822/rtconfig.h @@ -17,6 +17,7 @@ /* SECTION: RT_DEBUG */ /* Thread Debug */ #define RT_DEBUG +#define RT_DEBUG_COLOR //#define RT_DEBUG_INIT 1 #define RT_USING_OVERFLOW_CHECK diff --git a/bsp/nuvoton_m05x/.config b/bsp/nuvoton_m05x/.config index 07830e5c36..e86503da27 100644 --- a/bsp/nuvoton_m05x/.config +++ b/bsp/nuvoton_m05x/.config @@ -19,6 +19,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=256 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/nuvoton_m05x/rtconfig.h b/bsp/nuvoton_m05x/rtconfig.h index db3cc679c8..618084a0af 100644 --- a/bsp/nuvoton_m05x/rtconfig.h +++ b/bsp/nuvoton_m05x/rtconfig.h @@ -19,6 +19,7 @@ #define IDLE_THREAD_STACK_SIZE 256 /* RT_USING_TIMER_SOFT is not set */ #define RT_DEBUG +#define RT_DEBUG_COLOR /* RT_DEBUG_INIT_CONFIG is not set */ /* RT_DEBUG_THREAD_CONFIG is not set */ /* RT_DEBUG_SCHEDULER_CONFIG is not set */ diff --git a/bsp/nuvoton_m451/rtconfig.h b/bsp/nuvoton_m451/rtconfig.h index cb4868725c..b47eb84c59 100644 --- a/bsp/nuvoton_m451/rtconfig.h +++ b/bsp/nuvoton_m451/rtconfig.h @@ -17,6 +17,7 @@ /* SECTION: RT_DEBUG */ /* Thread Debug */ #define RT_DEBUG +#define RT_DEBUG_COLOR #define RT_DEBUG_INIT 1 #define RT_USING_OVERFLOW_CHECK diff --git a/bsp/nuvoton_m487/.config b/bsp/nuvoton_m487/.config index 2e12793338..6fc68de8e5 100644 --- a/bsp/nuvoton_m487/.config +++ b/bsp/nuvoton_m487/.config @@ -20,6 +20,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=256 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/nuvoton_m487/rtconfig.h b/bsp/nuvoton_m487/rtconfig.h index 7f151fe1de..0fa34764be 100644 --- a/bsp/nuvoton_m487/rtconfig.h +++ b/bsp/nuvoton_m487/rtconfig.h @@ -17,6 +17,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 256 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/nuvoton_nuc472/rtconfig.h b/bsp/nuvoton_nuc472/rtconfig.h index 9d1268a7ff..af9eacbef5 100644 --- a/bsp/nuvoton_nuc472/rtconfig.h +++ b/bsp/nuvoton_nuc472/rtconfig.h @@ -17,6 +17,7 @@ /* SECTION: RT_DEBUG */ /* Thread Debug */ #define RT_DEBUG +#define RT_DEBUG_COLOR #define RT_THREAD_DEBUG #define RT_USING_OVERFLOW_CHECK diff --git a/bsp/pic32ethernet/rtconfig.h b/bsp/pic32ethernet/rtconfig.h index 6bd11bfe2e..5d329788bc 100644 --- a/bsp/pic32ethernet/rtconfig.h +++ b/bsp/pic32ethernet/rtconfig.h @@ -17,6 +17,7 @@ /* SECTION: RT_DEBUG */ /* Thread Debug */ #define RT_DEBUG +#define RT_DEBUG_COLOR //#define THREAD_DEBUG #define SCHEDULER_DEBUG //#define IRQ_DEBUG diff --git a/bsp/qemu-vexpress-a9/.config b/bsp/qemu-vexpress-a9/.config index f1ea781e66..c8814d366a 100644 --- a/bsp/qemu-vexpress-a9/.config +++ b/bsp/qemu-vexpress-a9/.config @@ -24,6 +24,7 @@ CONFIG_RT_USING_TIMER_SOFT=y CONFIG_RT_TIMER_THREAD_PRIO=4 CONFIG_RT_TIMER_THREAD_STACK_SIZE=1024 CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set @@ -457,35 +458,6 @@ CONFIG_RT_USING_LWP=y # CONFIG_PKG_USING_PERIPHERAL_SAMPLES is not set # CONFIG_PKG_USING_HELLO is not set # CONFIG_PKG_USING_VI is not set - -# -# Privated Packages of RealThread -# -# CONFIG_PKG_USING_CODEC is not set -# CONFIG_PKG_USING_PLAYER is not set -# CONFIG_PKG_USING_PERSIMMON_SRC is not set -# CONFIG_PKG_USING_JS_PERSIMMON is not set -# CONFIG_PKG_USING_JERRYSCRIPT_WIN32 is not set - -# -# Network Utilities -# -# CONFIG_PKG_USING_MDNS is not set -# CONFIG_PKG_USING_UPNP is not set -# CONFIG_PKG_USING_WICED is not set -# CONFIG_PKG_USING_CLOUDSDK is not set -# CONFIG_PKG_USING_COREMARK is not set -# CONFIG_PKG_USING_POWER_MANAGER is not set -# CONFIG_PKG_USING_RT_OTA is not set -# CONFIG_PKG_USING_RDBD_SRC is not set -# CONFIG_PKG_USING_RTINSIGHT is not set -# CONFIG_PKG_USING_SMARTCONFIG is not set -# CONFIG_PKG_USING_RTX is not set -# CONFIG_RT_USING_TESTCASE is not set -# CONFIG_PKG_USING_NGHTTP2 is not set -# CONFIG_PKG_USING_AVS is not set -# CONFIG_PKG_USING_STS is not set -# CONFIG_PKG_USING_DLMS is not set CONFIG_SOC_VEXPRESS_A9=y CONFIG_RT_USING_UART0=y CONFIG_RT_USING_UART1=y diff --git a/bsp/qemu-vexpress-a9/drivers/audio/drv_pl041.c b/bsp/qemu-vexpress-a9/drivers/audio/drv_pl041.c index 55ac034ab9..68f8f09c10 100644 --- a/bsp/qemu-vexpress-a9/drivers/audio/drv_pl041.c +++ b/bsp/qemu-vexpress-a9/drivers/audio/drv_pl041.c @@ -28,13 +28,11 @@ #include "drv_ac97.h" #include "realview.h" -#define DBG_ENABLE #define DBG_SECTION_NAME "PL041" // #define DBG_LEVEL DBG_LOG // #define DBG_LEVEL DBG_INFO #define DBG_LEVEL DBG_WARNING // #define DBG_LEVEL DBG_ERROR -#define DBG_COLOR #include #define FRAME_PERIOD_US (50) diff --git a/bsp/qemu-vexpress-a9/drivers/drv_keyboard.c b/bsp/qemu-vexpress-a9/drivers/drv_keyboard.c index 7b1a49db55..4948f46117 100644 --- a/bsp/qemu-vexpress-a9/drivers/drv_keyboard.c +++ b/bsp/qemu-vexpress-a9/drivers/drv_keyboard.c @@ -6,10 +6,7 @@ #include "interrupt.h" #include "drv_keyboard.h" -#define DBG_LEVEL DBG_LOG -// #define DBG_ENABLE -#define DBG_COLOR - +#define DBG_LEVEL DBG_INFO #include "rtdbg.h" #define KEYBOARD_ADDRESS (0x10006000) @@ -442,7 +439,7 @@ int rt_hw_keyboard_init(void) pdat = rt_malloc(sizeof(struct keyboard_pl050_pdata_t)); if(!pdat) { - LOG_E("malloc memory", id); + LOG_E("malloc memory failed"); return RT_ERROR; } rt_memset(pdat, 0, sizeof(struct keyboard_pl050_pdata_t)); diff --git a/bsp/qemu-vexpress-a9/drivers/drv_mouse.c b/bsp/qemu-vexpress-a9/drivers/drv_mouse.c index 5fc1434166..852cc56129 100644 --- a/bsp/qemu-vexpress-a9/drivers/drv_mouse.c +++ b/bsp/qemu-vexpress-a9/drivers/drv_mouse.c @@ -7,10 +7,8 @@ #include "drv_mouse.h" #include "drv_clcd.h" -#define DBG_LEVEL DBG_LOG -// #define DBG_ENABLE -#define DBG_COLOR - +#define DBG_SECTION_NAME "drv.mouse" +#define DBG_LEVEL DBG_INFO #include "rtdbg.h" #define MOUSE_ADDRESS (0x10007000) @@ -246,7 +244,7 @@ int rt_hw_mouse_init(void) pdat = rt_malloc(sizeof(struct mouse_pl050_pdata_t)); if(!pdat) { - LOG_E("malloc memory", id); + LOG_E("malloc memory failed"); return RT_ERROR; } rt_memset(pdat, 0, sizeof(struct mouse_pl050_pdata_t)); diff --git a/bsp/qemu-vexpress-a9/drivers/drv_sdio.c b/bsp/qemu-vexpress-a9/drivers/drv_sdio.c index 5f2470f83d..c031011e51 100644 --- a/bsp/qemu-vexpress-a9/drivers/drv_sdio.c +++ b/bsp/qemu-vexpress-a9/drivers/drv_sdio.c @@ -77,10 +77,8 @@ #define PL180_CLR_DAT_END (1 << 8) #define PL180_CLR_DAT_BLK_END (1 << 10) -#define DBG_LEVEL DBG_LOG -// #define DBG_ENABLE -#define DBG_COLOR - +#define DBG_SECTION_NAME "drv.sdio" +#define DBG_LEVEL DBG_INFO #include "rtdbg.h" struct sdhci_pl180_pdata_t @@ -344,10 +342,10 @@ static void mmc_request_send(struct rt_mmcsd_host *host, struct rt_mmcsd_req *re req->cmd->err = sdhci_pl180_transfer(sdhci, &cmd, RT_NULL); } - LOG_I("cmdarg:%d", cmd.cmdarg); - LOG_I("cmdidx:%d", cmd.cmdidx); + LOG_D("cmdarg:%d", cmd.cmdarg); + LOG_D("cmdidx:%d", cmd.cmdidx); - LOG_I("[0]:0x%08x [1]:0x%08x [2]:0x%08x [3]:0x%08x", cmd.response[0], cmd.response[1], cmd.response[2], cmd.response[3]); + LOG_D("[0]:0x%08x [1]:0x%08x [2]:0x%08x [3]:0x%08x", cmd.response[0], cmd.response[1], cmd.response[2], cmd.response[3]); req->cmd->resp[3] = cmd.response[3]; req->cmd->resp[2] = cmd.response[2]; req->cmd->resp[1] = cmd.response[1]; @@ -381,7 +379,7 @@ static void mmc_set_iocfg(struct rt_mmcsd_host *host, struct rt_mmcsd_io_cfg *io sdhci_pl180_setclock(sdhci, io_cfg->clock); sdhci_pl180_setwidth(sdhci, io_cfg->bus_width); - LOG_I("clock:%d bus_width:%d", io_cfg->clock, io_cfg->bus_width); + LOG_D("clock:%d bus_width:%d", io_cfg->clock, io_cfg->bus_width); } static const struct rt_mmcsd_host_ops ops = diff --git a/bsp/qemu-vexpress-a9/rtconfig.h b/bsp/qemu-vexpress-a9/rtconfig.h index 2007a21f44..b6c3399da3 100644 --- a/bsp/qemu-vexpress-a9/rtconfig.h +++ b/bsp/qemu-vexpress-a9/rtconfig.h @@ -22,6 +22,7 @@ #define RT_TIMER_THREAD_PRIO 4 #define RT_TIMER_THREAD_STACK_SIZE 1024 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ @@ -254,12 +255,6 @@ /* samples: kernel and components samples */ - -/* Privated Packages of RealThread */ - - -/* Network Utilities */ - #define SOC_VEXPRESS_A9 #define RT_USING_UART0 #define RT_USING_UART1 diff --git a/bsp/qemu-vexpress-gemini/.config b/bsp/qemu-vexpress-gemini/.config index 425f9a1eae..b7610b6c5e 100644 --- a/bsp/qemu-vexpress-gemini/.config +++ b/bsp/qemu-vexpress-gemini/.config @@ -19,6 +19,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=512 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/qemu-vexpress-gemini/rtconfig.h b/bsp/qemu-vexpress-gemini/rtconfig.h index 7218fedca1..acb00aadda 100644 --- a/bsp/qemu-vexpress-gemini/rtconfig.h +++ b/bsp/qemu-vexpress-gemini/rtconfig.h @@ -19,6 +19,7 @@ #define IDLE_THREAD_STACK_SIZE 512 /* RT_USING_TIMER_SOFT is not set */ #define RT_DEBUG +#define RT_DEBUG_COLOR /* RT_DEBUG_INIT_CONFIG is not set */ /* RT_DEBUG_THREAD_CONFIG is not set */ /* RT_DEBUG_SCHEDULER_CONFIG is not set */ diff --git a/bsp/raspi2/.config b/bsp/raspi2/.config index 7db26a7cb1..5821005c0c 100644 --- a/bsp/raspi2/.config +++ b/bsp/raspi2/.config @@ -19,6 +19,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=256 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/raspi2/rtconfig.h b/bsp/raspi2/rtconfig.h index d0b692f9ab..b2e6349ad0 100644 --- a/bsp/raspi2/rtconfig.h +++ b/bsp/raspi2/rtconfig.h @@ -19,6 +19,7 @@ #define IDLE_THREAD_STACK_SIZE 256 /* RT_USING_TIMER_SOFT is not set */ #define RT_DEBUG +#define RT_DEBUG_COLOR /* RT_DEBUG_INIT_CONFIG is not set */ /* RT_DEBUG_THREAD_CONFIG is not set */ /* RT_DEBUG_SCHEDULER_CONFIG is not set */ diff --git a/bsp/realview-a8/rtconfig.h b/bsp/realview-a8/rtconfig.h index d06e81a0e1..68d28bcd93 100644 --- a/bsp/realview-a8/rtconfig.h +++ b/bsp/realview-a8/rtconfig.h @@ -20,6 +20,7 @@ #define IDLE_THREAD_STACK_SIZE 512 //
#define RT_DEBUG +#define RT_DEBUG_COLOR // // #define RT_THREAD_DEBUG // diff --git a/bsp/rv32m1_vega/ri5cy/.config b/bsp/rv32m1_vega/ri5cy/.config index d62e37947a..5bb6a992e5 100644 --- a/bsp/rv32m1_vega/ri5cy/.config +++ b/bsp/rv32m1_vega/ri5cy/.config @@ -21,6 +21,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=1024 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/rv32m1_vega/ri5cy/rtconfig.h b/bsp/rv32m1_vega/ri5cy/rtconfig.h index ff78ea65a1..82fecbb22f 100644 --- a/bsp/rv32m1_vega/ri5cy/rtconfig.h +++ b/bsp/rv32m1_vega/ri5cy/rtconfig.h @@ -17,6 +17,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 1024 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/rx/rtconfig.h b/bsp/rx/rtconfig.h index 364204696f..6f055dce1a 100644 --- a/bsp/rx/rtconfig.h +++ b/bsp/rx/rtconfig.h @@ -17,6 +17,7 @@ /* SECTION: RT_DEBUG */ /* Thread Debug */ #define RT_DEBUG +#define RT_DEBUG_COLOR #define RT_THREAD_DEBUG #define RT_USING_OVERFLOW_CHECK diff --git a/bsp/samd21/rtconfig.h b/bsp/samd21/rtconfig.h index c22a5496e7..99fe288e3a 100644 --- a/bsp/samd21/rtconfig.h +++ b/bsp/samd21/rtconfig.h @@ -17,6 +17,7 @@ /* SECTION: RT_DEBUG */ /* Thread Debug */ #define RT_DEBUG +#define RT_DEBUG_COLOR //#define RT_DEBUG_INIT 1 #define RT_USING_OVERFLOW_CHECK diff --git a/bsp/sep6200/rtconfig.h b/bsp/sep6200/rtconfig.h index e2ca52cc5c..c078a6b5a2 100644 --- a/bsp/sep6200/rtconfig.h +++ b/bsp/sep6200/rtconfig.h @@ -2,7 +2,6 @@ #ifndef __RTTHREAD_CFG_H__ #define __RTTHREAD_CFG_H__ -#define RT_DEBUG /* #define RT_DEBUG_IRQ 1 */ /* #define RT_DEBUG_TIMER 1 */ @@ -29,6 +28,7 @@ /* SECTION: RT_DEBUG */ /* Thread Debug */ #define RT_DEBUG +#define RT_DEBUG_COLOR /* #define RT_THREAD_DEBUG */ #define RT_USING_OVERFLOW_CHECK diff --git a/bsp/simulator/.config b/bsp/simulator/.config index dbb69fd390..479f5658d1 100644 --- a/bsp/simulator/.config +++ b/bsp/simulator/.config @@ -14,6 +14,7 @@ CONFIG_RT_THREAD_PRIORITY_32=y CONFIG_RT_THREAD_PRIORITY_MAX=32 CONFIG_RT_TICK_PER_SECOND=100 CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y CONFIG_RT_USING_OVERFLOW_CHECK=y CONFIG_RT_DEBUG_INIT=0 CONFIG_RT_DEBUG_THREAD=0 diff --git a/bsp/simulator/rtconfig.h b/bsp/simulator/rtconfig.h index 4955172df7..22f9d2a5b4 100755 --- a/bsp/simulator/rtconfig.h +++ b/bsp/simulator/rtconfig.h @@ -14,6 +14,7 @@ #define RT_THREAD_PRIORITY_MAX 32 #define RT_TICK_PER_SECOND 100 #define RT_DEBUG +#define RT_DEBUG_COLOR #define RT_USING_OVERFLOW_CHECK #define RT_DEBUG_INIT 0 #define RT_DEBUG_THREAD 0 diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_log.h b/bsp/stm32/libraries/HAL_Drivers/drv_log.h index f7461223d7..69328b368a 100644 --- a/bsp/stm32/libraries/HAL_Drivers/drv_log.h +++ b/bsp/stm32/libraries/HAL_Drivers/drv_log.h @@ -12,9 +12,6 @@ * NOTE: DO NOT include this file on the header file. */ -#define DBG_ENABLE -#define DBG_COLOR - #ifndef LOG_TAG #define DBG_SECTION_NAME "drv" #else diff --git a/bsp/stm32/libraries/templates/stm32f0xx/.config b/bsp/stm32/libraries/templates/stm32f0xx/.config index 95ba89c2b8..71e677bd8d 100644 --- a/bsp/stm32/libraries/templates/stm32f0xx/.config +++ b/bsp/stm32/libraries/templates/stm32f0xx/.config @@ -21,6 +21,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=256 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/stm32/libraries/templates/stm32f0xx/rtconfig.h b/bsp/stm32/libraries/templates/stm32f0xx/rtconfig.h index 0026ccb4a8..0ed9946b4d 100644 --- a/bsp/stm32/libraries/templates/stm32f0xx/rtconfig.h +++ b/bsp/stm32/libraries/templates/stm32f0xx/rtconfig.h @@ -17,6 +17,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 256 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/stm32/libraries/templates/stm32f10x/.config b/bsp/stm32/libraries/templates/stm32f10x/.config index 4d9fc24b34..a7356cd424 100644 --- a/bsp/stm32/libraries/templates/stm32f10x/.config +++ b/bsp/stm32/libraries/templates/stm32f10x/.config @@ -21,6 +21,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=256 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/stm32/libraries/templates/stm32f10x/rtconfig.h b/bsp/stm32/libraries/templates/stm32f10x/rtconfig.h index 63450a8a21..b49535ef9c 100644 --- a/bsp/stm32/libraries/templates/stm32f10x/rtconfig.h +++ b/bsp/stm32/libraries/templates/stm32f10x/rtconfig.h @@ -17,6 +17,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 256 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/stm32/libraries/templates/stm32f4xx/.config b/bsp/stm32/libraries/templates/stm32f4xx/.config index 973b093b5b..e685a4fdcf 100644 --- a/bsp/stm32/libraries/templates/stm32f4xx/.config +++ b/bsp/stm32/libraries/templates/stm32f4xx/.config @@ -21,6 +21,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=256 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/stm32/libraries/templates/stm32f4xx/rtconfig.h b/bsp/stm32/libraries/templates/stm32f4xx/rtconfig.h index 8e6b709a8a..eef0a9fe47 100644 --- a/bsp/stm32/libraries/templates/stm32f4xx/rtconfig.h +++ b/bsp/stm32/libraries/templates/stm32f4xx/rtconfig.h @@ -17,6 +17,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 256 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/stm32/libraries/templates/stm32f7xx/.config b/bsp/stm32/libraries/templates/stm32f7xx/.config index a594f088db..da5d2099bf 100644 --- a/bsp/stm32/libraries/templates/stm32f7xx/.config +++ b/bsp/stm32/libraries/templates/stm32f7xx/.config @@ -21,6 +21,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=256 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/stm32/libraries/templates/stm32f7xx/rtconfig.h b/bsp/stm32/libraries/templates/stm32f7xx/rtconfig.h index 50eb442ed8..019e9ccb3a 100644 --- a/bsp/stm32/libraries/templates/stm32f7xx/rtconfig.h +++ b/bsp/stm32/libraries/templates/stm32f7xx/rtconfig.h @@ -17,6 +17,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 256 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/stm32/libraries/templates/stm32l4xx/.config b/bsp/stm32/libraries/templates/stm32l4xx/.config index e29aecd0c8..7349adcc55 100644 --- a/bsp/stm32/libraries/templates/stm32l4xx/.config +++ b/bsp/stm32/libraries/templates/stm32l4xx/.config @@ -21,6 +21,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=256 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/stm32/libraries/templates/stm32l4xx/rtconfig.h b/bsp/stm32/libraries/templates/stm32l4xx/rtconfig.h index 6ae4a7ba8a..b6055004ae 100644 --- a/bsp/stm32/libraries/templates/stm32l4xx/rtconfig.h +++ b/bsp/stm32/libraries/templates/stm32l4xx/rtconfig.h @@ -17,6 +17,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 256 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/stm32/stm32f091-st-nucleo/.config b/bsp/stm32/stm32f091-st-nucleo/.config index 0fced6c38b..4fad5a0bb3 100644 --- a/bsp/stm32/stm32f091-st-nucleo/.config +++ b/bsp/stm32/stm32f091-st-nucleo/.config @@ -21,6 +21,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=256 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/stm32/stm32f091-st-nucleo/rtconfig.h b/bsp/stm32/stm32f091-st-nucleo/rtconfig.h index dc6298a719..791373ea2e 100644 --- a/bsp/stm32/stm32f091-st-nucleo/rtconfig.h +++ b/bsp/stm32/stm32f091-st-nucleo/rtconfig.h @@ -17,6 +17,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 256 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/stm32/stm32f103-atk-nano/.config b/bsp/stm32/stm32f103-atk-nano/.config index 7a4eec1ff9..52ed83da63 100644 --- a/bsp/stm32/stm32f103-atk-nano/.config +++ b/bsp/stm32/stm32f103-atk-nano/.config @@ -21,6 +21,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=256 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/stm32/stm32f103-atk-nano/rtconfig.h b/bsp/stm32/stm32f103-atk-nano/rtconfig.h index 816034b45d..619439d3f5 100644 --- a/bsp/stm32/stm32f103-atk-nano/rtconfig.h +++ b/bsp/stm32/stm32f103-atk-nano/rtconfig.h @@ -17,6 +17,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 256 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/stm32/stm32f103-dofly-lyc8/.config b/bsp/stm32/stm32f103-dofly-lyc8/.config index 7f97f2603f..959d611b80 100644 --- a/bsp/stm32/stm32f103-dofly-lyc8/.config +++ b/bsp/stm32/stm32f103-dofly-lyc8/.config @@ -21,6 +21,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=256 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/stm32/stm32f103-dofly-lyc8/rtconfig.h b/bsp/stm32/stm32f103-dofly-lyc8/rtconfig.h index 92eee96813..92e59c0759 100644 --- a/bsp/stm32/stm32f103-dofly-lyc8/rtconfig.h +++ b/bsp/stm32/stm32f103-dofly-lyc8/rtconfig.h @@ -17,6 +17,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 256 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/stm32/stm32f103-fire-arbitrary/.config b/bsp/stm32/stm32f103-fire-arbitrary/.config index 0938feaf7e..9674152dba 100644 --- a/bsp/stm32/stm32f103-fire-arbitrary/.config +++ b/bsp/stm32/stm32f103-fire-arbitrary/.config @@ -21,6 +21,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=256 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/stm32/stm32f103-fire-arbitrary/board/ports/sdcard_port.c b/bsp/stm32/stm32f103-fire-arbitrary/board/ports/sdcard_port.c index 16c7a9e454..45c8a6d74d 100644 --- a/bsp/stm32/stm32f103-fire-arbitrary/board/ports/sdcard_port.c +++ b/bsp/stm32/stm32f103-fire-arbitrary/board/ports/sdcard_port.c @@ -16,10 +16,7 @@ #include #include -#define DBG_ENABLE #define DBG_SECTION_NAME "app.card" -#define DBG_COLOR - #define DBG_LEVEL DBG_INFO #include diff --git a/bsp/stm32/stm32f103-fire-arbitrary/rtconfig.h b/bsp/stm32/stm32f103-fire-arbitrary/rtconfig.h index 5a2ac1c53c..4f5b34280a 100644 --- a/bsp/stm32/stm32f103-fire-arbitrary/rtconfig.h +++ b/bsp/stm32/stm32f103-fire-arbitrary/rtconfig.h @@ -17,6 +17,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 256 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/stm32/stm32f103-hw100k-ibox/.config b/bsp/stm32/stm32f103-hw100k-ibox/.config index d13b95269e..e7e202aecb 100644 --- a/bsp/stm32/stm32f103-hw100k-ibox/.config +++ b/bsp/stm32/stm32f103-hw100k-ibox/.config @@ -21,6 +21,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=256 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/stm32/stm32f103-hw100k-ibox/rtconfig.h b/bsp/stm32/stm32f103-hw100k-ibox/rtconfig.h index 322d2776eb..6ea22eea76 100644 --- a/bsp/stm32/stm32f103-hw100k-ibox/rtconfig.h +++ b/bsp/stm32/stm32f103-hw100k-ibox/rtconfig.h @@ -17,6 +17,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 256 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/stm32/stm32f107-uc-eval/.config b/bsp/stm32/stm32f107-uc-eval/.config index 9e3c8a7fcc..e116d9221b 100644 --- a/bsp/stm32/stm32f107-uc-eval/.config +++ b/bsp/stm32/stm32f107-uc-eval/.config @@ -21,6 +21,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=256 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/stm32/stm32f107-uc-eval/rtconfig.h b/bsp/stm32/stm32f107-uc-eval/rtconfig.h index afc9a75ace..016619dcab 100644 --- a/bsp/stm32/stm32f107-uc-eval/rtconfig.h +++ b/bsp/stm32/stm32f107-uc-eval/rtconfig.h @@ -17,6 +17,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 256 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/stm32/stm32f405-smdz-breadfruit/.config b/bsp/stm32/stm32f405-smdz-breadfruit/.config index fe5e73f6c0..a93ce77cd2 100644 --- a/bsp/stm32/stm32f405-smdz-breadfruit/.config +++ b/bsp/stm32/stm32f405-smdz-breadfruit/.config @@ -21,6 +21,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=256 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/stm32/stm32f405-smdz-breadfruit/rtconfig.h b/bsp/stm32/stm32f405-smdz-breadfruit/rtconfig.h index 1129acefb6..0e41735873 100644 --- a/bsp/stm32/stm32f405-smdz-breadfruit/rtconfig.h +++ b/bsp/stm32/stm32f405-smdz-breadfruit/rtconfig.h @@ -21,6 +21,7 @@ #define IDLE_THREAD_STACK_SIZE 256 /* RT_USING_TIMER_SOFT is not set */ #define RT_DEBUG +#define RT_DEBUG_COLOR /* RT_DEBUG_INIT_CONFIG is not set */ /* RT_DEBUG_THREAD_CONFIG is not set */ /* RT_DEBUG_SCHEDULER_CONFIG is not set */ diff --git a/bsp/stm32/stm32f407-atk-explorer/.config b/bsp/stm32/stm32f407-atk-explorer/.config index 177d468704..52b162451a 100644 --- a/bsp/stm32/stm32f407-atk-explorer/.config +++ b/bsp/stm32/stm32f407-atk-explorer/.config @@ -21,6 +21,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=1024 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/stm32/stm32f407-atk-explorer/board/ports/sdcard_port.c b/bsp/stm32/stm32f407-atk-explorer/board/ports/sdcard_port.c index 3026357b5c..625cec463d 100644 --- a/bsp/stm32/stm32f407-atk-explorer/board/ports/sdcard_port.c +++ b/bsp/stm32/stm32f407-atk-explorer/board/ports/sdcard_port.c @@ -16,10 +16,7 @@ #include #include -#define DBG_ENABLE #define DBG_SECTION_NAME "app.card" -#define DBG_COLOR - #define DBG_LEVEL DBG_INFO #include diff --git a/bsp/stm32/stm32f407-atk-explorer/rtconfig.h b/bsp/stm32/stm32f407-atk-explorer/rtconfig.h index d35ad8f997..ce6e3b4c2c 100644 --- a/bsp/stm32/stm32f407-atk-explorer/rtconfig.h +++ b/bsp/stm32/stm32f407-atk-explorer/rtconfig.h @@ -17,6 +17,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 1024 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/stm32/stm32f407-st-discovery/.config b/bsp/stm32/stm32f407-st-discovery/.config index 855a959166..456c95097d 100644 --- a/bsp/stm32/stm32f407-st-discovery/.config +++ b/bsp/stm32/stm32f407-st-discovery/.config @@ -21,6 +21,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=256 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/stm32/stm32f407-st-discovery/rtconfig.h b/bsp/stm32/stm32f407-st-discovery/rtconfig.h index 41e6ddedbd..c25a065336 100644 --- a/bsp/stm32/stm32f407-st-discovery/rtconfig.h +++ b/bsp/stm32/stm32f407-st-discovery/rtconfig.h @@ -17,6 +17,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 256 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/stm32/stm32f411-st-nucleo/.config b/bsp/stm32/stm32f411-st-nucleo/.config index ca166c9644..ba35dd2786 100644 --- a/bsp/stm32/stm32f411-st-nucleo/.config +++ b/bsp/stm32/stm32f411-st-nucleo/.config @@ -21,6 +21,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=256 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/stm32/stm32f411-st-nucleo/rtconfig.h b/bsp/stm32/stm32f411-st-nucleo/rtconfig.h index 94d5708a91..4c8e05dd2e 100644 --- a/bsp/stm32/stm32f411-st-nucleo/rtconfig.h +++ b/bsp/stm32/stm32f411-st-nucleo/rtconfig.h @@ -17,6 +17,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 256 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/stm32/stm32f429-armfly-v6/.config b/bsp/stm32/stm32f429-armfly-v6/.config index 3169a6cb0f..5864f2d8c2 100644 --- a/bsp/stm32/stm32f429-armfly-v6/.config +++ b/bsp/stm32/stm32f429-armfly-v6/.config @@ -21,6 +21,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=256 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/stm32/stm32f429-armfly-v6/board/ports/sdcard_port.c b/bsp/stm32/stm32f429-armfly-v6/board/ports/sdcard_port.c index 617379fd4e..0eb7035ddf 100644 --- a/bsp/stm32/stm32f429-armfly-v6/board/ports/sdcard_port.c +++ b/bsp/stm32/stm32f429-armfly-v6/board/ports/sdcard_port.c @@ -16,10 +16,7 @@ #include #include -#define DBG_ENABLE #define DBG_SECTION_NAME "app.card" -#define DBG_COLOR - #define DBG_LEVEL DBG_INFO #include diff --git a/bsp/stm32/stm32f429-armfly-v6/rtconfig.h b/bsp/stm32/stm32f429-armfly-v6/rtconfig.h index 7d6c12513e..f396b058ea 100644 --- a/bsp/stm32/stm32f429-armfly-v6/rtconfig.h +++ b/bsp/stm32/stm32f429-armfly-v6/rtconfig.h @@ -17,6 +17,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 256 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/stm32/stm32f429-atk-apollo/.config b/bsp/stm32/stm32f429-atk-apollo/.config index 90c7572d90..71b42e506b 100644 --- a/bsp/stm32/stm32f429-atk-apollo/.config +++ b/bsp/stm32/stm32f429-atk-apollo/.config @@ -21,6 +21,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=1024 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/stm32/stm32f429-atk-apollo/board/ports/sdcard_port.c b/bsp/stm32/stm32f429-atk-apollo/board/ports/sdcard_port.c index 3026357b5c..625cec463d 100644 --- a/bsp/stm32/stm32f429-atk-apollo/board/ports/sdcard_port.c +++ b/bsp/stm32/stm32f429-atk-apollo/board/ports/sdcard_port.c @@ -16,10 +16,7 @@ #include #include -#define DBG_ENABLE #define DBG_SECTION_NAME "app.card" -#define DBG_COLOR - #define DBG_LEVEL DBG_INFO #include diff --git a/bsp/stm32/stm32f429-atk-apollo/rtconfig.h b/bsp/stm32/stm32f429-atk-apollo/rtconfig.h index bcf153da33..21f47999d0 100644 --- a/bsp/stm32/stm32f429-atk-apollo/rtconfig.h +++ b/bsp/stm32/stm32f429-atk-apollo/rtconfig.h @@ -17,6 +17,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 1024 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/stm32/stm32f429-fire-challenger/.config b/bsp/stm32/stm32f429-fire-challenger/.config index ddd5f2950f..55d2ccfb56 100644 --- a/bsp/stm32/stm32f429-fire-challenger/.config +++ b/bsp/stm32/stm32f429-fire-challenger/.config @@ -21,6 +21,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=1024 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/stm32/stm32f429-fire-challenger/board/ports/sdcard_port.c b/bsp/stm32/stm32f429-fire-challenger/board/ports/sdcard_port.c index 0a84162150..c7200001e3 100644 --- a/bsp/stm32/stm32f429-fire-challenger/board/ports/sdcard_port.c +++ b/bsp/stm32/stm32f429-fire-challenger/board/ports/sdcard_port.c @@ -17,10 +17,7 @@ #include #include "drv_gpio.h" -#define DBG_ENABLE #define DBG_SECTION_NAME "app.card" -#define DBG_COLOR - #define DBG_LEVEL DBG_INFO #include diff --git a/bsp/stm32/stm32f429-fire-challenger/rtconfig.h b/bsp/stm32/stm32f429-fire-challenger/rtconfig.h index 7e366cf856..f411466331 100644 --- a/bsp/stm32/stm32f429-fire-challenger/rtconfig.h +++ b/bsp/stm32/stm32f429-fire-challenger/rtconfig.h @@ -17,6 +17,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 1024 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/stm32/stm32f446-st-nucleo/.config b/bsp/stm32/stm32f446-st-nucleo/.config index 1e648651f4..916cefa8d2 100644 --- a/bsp/stm32/stm32f446-st-nucleo/.config +++ b/bsp/stm32/stm32f446-st-nucleo/.config @@ -21,6 +21,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=256 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/stm32/stm32f446-st-nucleo/rtconfig.h b/bsp/stm32/stm32f446-st-nucleo/rtconfig.h index 6f058fe597..b32a8e953d 100644 --- a/bsp/stm32/stm32f446-st-nucleo/rtconfig.h +++ b/bsp/stm32/stm32f446-st-nucleo/rtconfig.h @@ -17,6 +17,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 256 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/stm32/stm32f746-st-disco/.config b/bsp/stm32/stm32f746-st-disco/.config index 1f7a54ed9f..b0cc2489cf 100644 --- a/bsp/stm32/stm32f746-st-disco/.config +++ b/bsp/stm32/stm32f746-st-disco/.config @@ -21,6 +21,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=256 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/stm32/stm32f746-st-disco/board/ports/sdcard_port.c b/bsp/stm32/stm32f746-st-disco/board/ports/sdcard_port.c index 90cfd4d1a4..143576eb12 100644 --- a/bsp/stm32/stm32f746-st-disco/board/ports/sdcard_port.c +++ b/bsp/stm32/stm32f746-st-disco/board/ports/sdcard_port.c @@ -16,10 +16,7 @@ #include #include -#define DBG_ENABLE #define DBG_SECTION_NAME "app.card" -#define DBG_COLOR - #define DBG_LEVEL DBG_INFO #include diff --git a/bsp/stm32/stm32f746-st-disco/rtconfig.h b/bsp/stm32/stm32f746-st-disco/rtconfig.h index cdea6fd74f..d7084fdc3a 100644 --- a/bsp/stm32/stm32f746-st-disco/rtconfig.h +++ b/bsp/stm32/stm32f746-st-disco/rtconfig.h @@ -17,6 +17,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 256 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/stm32/stm32f767-atk-apollo/.config b/bsp/stm32/stm32f767-atk-apollo/.config index 46bbff3a82..18940f0bd4 100644 --- a/bsp/stm32/stm32f767-atk-apollo/.config +++ b/bsp/stm32/stm32f767-atk-apollo/.config @@ -21,6 +21,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=1024 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/stm32/stm32f767-atk-apollo/board/ports/sdcard_port.c b/bsp/stm32/stm32f767-atk-apollo/board/ports/sdcard_port.c index 3026357b5c..625cec463d 100644 --- a/bsp/stm32/stm32f767-atk-apollo/board/ports/sdcard_port.c +++ b/bsp/stm32/stm32f767-atk-apollo/board/ports/sdcard_port.c @@ -16,10 +16,7 @@ #include #include -#define DBG_ENABLE #define DBG_SECTION_NAME "app.card" -#define DBG_COLOR - #define DBG_LEVEL DBG_INFO #include diff --git a/bsp/stm32/stm32f767-atk-apollo/rtconfig.h b/bsp/stm32/stm32f767-atk-apollo/rtconfig.h index 23599ade59..40b4703fd7 100644 --- a/bsp/stm32/stm32f767-atk-apollo/rtconfig.h +++ b/bsp/stm32/stm32f767-atk-apollo/rtconfig.h @@ -17,6 +17,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 1024 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/stm32/stm32f767-fire-challenger/.config b/bsp/stm32/stm32f767-fire-challenger/.config index ef2f4a0c70..4f6f6f6468 100644 --- a/bsp/stm32/stm32f767-fire-challenger/.config +++ b/bsp/stm32/stm32f767-fire-challenger/.config @@ -21,6 +21,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=1024 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/stm32/stm32f767-fire-challenger/board/ports/sdcard_port.c b/bsp/stm32/stm32f767-fire-challenger/board/ports/sdcard_port.c index 035d3357d1..b8db33d0d2 100644 --- a/bsp/stm32/stm32f767-fire-challenger/board/ports/sdcard_port.c +++ b/bsp/stm32/stm32f767-fire-challenger/board/ports/sdcard_port.c @@ -17,10 +17,8 @@ #include #include "drv_gpio.h" -// #define DBG_ENABLE -#define DBG_SECTION_NAME "app.card" -#define DBG_COLOR +#define DBG_SECTION_NAME "app.card" #define DBG_LEVEL DBG_INFO #include diff --git a/bsp/stm32/stm32f767-fire-challenger/rtconfig.h b/bsp/stm32/stm32f767-fire-challenger/rtconfig.h index 16f05af945..405e99cef1 100644 --- a/bsp/stm32/stm32f767-fire-challenger/rtconfig.h +++ b/bsp/stm32/stm32f767-fire-challenger/rtconfig.h @@ -17,6 +17,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 1024 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/stm32/stm32f767-st-nucleo/rtconfig.h b/bsp/stm32/stm32f767-st-nucleo/rtconfig.h index 44fac63085..949da7906c 100644 --- a/bsp/stm32/stm32f767-st-nucleo/rtconfig.h +++ b/bsp/stm32/stm32f767-st-nucleo/rtconfig.h @@ -17,6 +17,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 256 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/stm32/stm32g071-st-nucleo/.config b/bsp/stm32/stm32g071-st-nucleo/.config index 1e6c3689a0..4bea393c68 100644 --- a/bsp/stm32/stm32g071-st-nucleo/.config +++ b/bsp/stm32/stm32g071-st-nucleo/.config @@ -21,6 +21,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=256 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/stm32/stm32g071-st-nucleo/rtconfig.h b/bsp/stm32/stm32g071-st-nucleo/rtconfig.h index 1a407f8e83..aa14175609 100644 --- a/bsp/stm32/stm32g071-st-nucleo/rtconfig.h +++ b/bsp/stm32/stm32g071-st-nucleo/rtconfig.h @@ -17,6 +17,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 256 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/stm32/stm32l053-st-nucleo/.config b/bsp/stm32/stm32l053-st-nucleo/.config index 40e3129afa..be3b800004 100644 --- a/bsp/stm32/stm32l053-st-nucleo/.config +++ b/bsp/stm32/stm32l053-st-nucleo/.config @@ -21,6 +21,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=256 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/stm32/stm32l053-st-nucleo/rtconfig.h b/bsp/stm32/stm32l053-st-nucleo/rtconfig.h index 89f211e824..7f3a0e5416 100644 --- a/bsp/stm32/stm32l053-st-nucleo/rtconfig.h +++ b/bsp/stm32/stm32l053-st-nucleo/rtconfig.h @@ -17,6 +17,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 256 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/stm32/stm32l432-st-nucleo/.config b/bsp/stm32/stm32l432-st-nucleo/.config index 7b2e09bad1..43dd91cc60 100644 --- a/bsp/stm32/stm32l432-st-nucleo/.config +++ b/bsp/stm32/stm32l432-st-nucleo/.config @@ -21,6 +21,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=256 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/stm32/stm32l432-st-nucleo/rtconfig.h b/bsp/stm32/stm32l432-st-nucleo/rtconfig.h index 2aa2734e2b..58c4cba2fe 100644 --- a/bsp/stm32/stm32l432-st-nucleo/rtconfig.h +++ b/bsp/stm32/stm32l432-st-nucleo/rtconfig.h @@ -17,6 +17,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 256 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/stm32/stm32l475-atk-pandora/.config b/bsp/stm32/stm32l475-atk-pandora/.config index 630083f09c..06d83718ce 100644 --- a/bsp/stm32/stm32l475-atk-pandora/.config +++ b/bsp/stm32/stm32l475-atk-pandora/.config @@ -21,6 +21,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=256 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/stm32/stm32l475-atk-pandora/board/ports/sdcard_port.c b/bsp/stm32/stm32l475-atk-pandora/board/ports/sdcard_port.c index 9d40589756..11c66f34b7 100644 --- a/bsp/stm32/stm32l475-atk-pandora/board/ports/sdcard_port.c +++ b/bsp/stm32/stm32l475-atk-pandora/board/ports/sdcard_port.c @@ -18,10 +18,8 @@ #include "drv_spi.h" #include "spi_msd.h" -#define DBG_ENABLE -#define DBG_SECTION_NAME "app.card" -#define DBG_COLOR +#define DBG_SECTION_NAME "app.card" #define DBG_LEVEL DBG_INFO #include diff --git a/bsp/stm32/stm32l475-atk-pandora/rtconfig.h b/bsp/stm32/stm32l475-atk-pandora/rtconfig.h index f138878738..d0c5e24f0e 100644 --- a/bsp/stm32/stm32l475-atk-pandora/rtconfig.h +++ b/bsp/stm32/stm32l475-atk-pandora/rtconfig.h @@ -17,6 +17,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 256 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/stm32/stm32l476-st-nucleo/.config b/bsp/stm32/stm32l476-st-nucleo/.config index 427cb9a3a7..0731ce4782 100644 --- a/bsp/stm32/stm32l476-st-nucleo/.config +++ b/bsp/stm32/stm32l476-st-nucleo/.config @@ -21,6 +21,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=256 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/stm32/stm32l476-st-nucleo/rtconfig.h b/bsp/stm32/stm32l476-st-nucleo/rtconfig.h index ac2fd6a542..afeaf369c0 100644 --- a/bsp/stm32/stm32l476-st-nucleo/rtconfig.h +++ b/bsp/stm32/stm32l476-st-nucleo/rtconfig.h @@ -17,6 +17,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 256 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/stm32/stm32l496-ali-developer/.config b/bsp/stm32/stm32l496-ali-developer/.config index 53adaf801c..0324c80f42 100644 --- a/bsp/stm32/stm32l496-ali-developer/.config +++ b/bsp/stm32/stm32l496-ali-developer/.config @@ -21,6 +21,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=256 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/stm32/stm32l496-ali-developer/board/ports/sdcard_port.c b/bsp/stm32/stm32l496-ali-developer/board/ports/sdcard_port.c index 2ffcef8fda..54b5af7ed6 100644 --- a/bsp/stm32/stm32l496-ali-developer/board/ports/sdcard_port.c +++ b/bsp/stm32/stm32l496-ali-developer/board/ports/sdcard_port.c @@ -16,10 +16,8 @@ #include #include -#define DBG_ENABLE -#define DBG_SECTION_NAME "app.card" -#define DBG_COLOR +#define DBG_SECTION_NAME "app.card" #define DBG_LEVEL DBG_INFO #include diff --git a/bsp/stm32/stm32l496-ali-developer/rtconfig.h b/bsp/stm32/stm32l496-ali-developer/rtconfig.h index 05e86e250b..d6ce5027bc 100644 --- a/bsp/stm32/stm32l496-ali-developer/rtconfig.h +++ b/bsp/stm32/stm32l496-ali-developer/rtconfig.h @@ -17,6 +17,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 256 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/stm32f0x/rtconfig.h b/bsp/stm32f0x/rtconfig.h index 0a71690b53..6a7aeb1fdf 100644 --- a/bsp/stm32f0x/rtconfig.h +++ b/bsp/stm32f0x/rtconfig.h @@ -17,6 +17,7 @@ /* SECTION: RT_DEBUG */ /* Thread Debug */ #define RT_DEBUG +#define RT_DEBUG_COLOR #define RT_DEBUG_INIT 1 #define RT_USING_OVERFLOW_CHECK diff --git a/bsp/stm32f107/.config b/bsp/stm32f107/.config index b8e5092cf1..616acba058 100644 --- a/bsp/stm32f107/.config +++ b/bsp/stm32f107/.config @@ -21,6 +21,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=256 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/stm32f107/rtconfig.h b/bsp/stm32f107/rtconfig.h index b05fca7ed4..e7e9c9e5ea 100644 --- a/bsp/stm32f107/rtconfig.h +++ b/bsp/stm32f107/rtconfig.h @@ -17,6 +17,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 256 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/stm32f10x-HAL/.config b/bsp/stm32f10x-HAL/.config index 39706cd496..8c6e8d4a8f 100644 --- a/bsp/stm32f10x-HAL/.config +++ b/bsp/stm32f10x-HAL/.config @@ -14,6 +14,7 @@ CONFIG_RT_THREAD_PRIORITY_32=y CONFIG_RT_THREAD_PRIORITY_MAX=32 CONFIG_RT_TICK_PER_SECOND=100 CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y CONFIG_RT_USING_OVERFLOW_CHECK=y CONFIG_RT_DEBUG_INIT=0 CONFIG_RT_DEBUG_THREAD=0 diff --git a/bsp/stm32f10x-HAL/rtconfig.h b/bsp/stm32f10x-HAL/rtconfig.h index 84514b603c..1eb6845129 100644 --- a/bsp/stm32f10x-HAL/rtconfig.h +++ b/bsp/stm32f10x-HAL/rtconfig.h @@ -14,6 +14,7 @@ #define RT_THREAD_PRIORITY_MAX 32 #define RT_TICK_PER_SECOND 100 #define RT_DEBUG +#define RT_DEBUG_COLOR #define RT_USING_OVERFLOW_CHECK #define RT_DEBUG_INIT 0 #define RT_DEBUG_THREAD 0 diff --git a/bsp/stm32f10x/.config b/bsp/stm32f10x/.config index 7b1a9477ab..35ebac08b4 100644 --- a/bsp/stm32f10x/.config +++ b/bsp/stm32f10x/.config @@ -14,6 +14,7 @@ CONFIG_RT_THREAD_PRIORITY_32=y CONFIG_RT_THREAD_PRIORITY_MAX=32 CONFIG_RT_TICK_PER_SECOND=100 CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y CONFIG_RT_USING_OVERFLOW_CHECK=y CONFIG_RT_DEBUG_INIT=0 CONFIG_RT_DEBUG_THREAD=0 diff --git a/bsp/stm32f10x/rtconfig.h b/bsp/stm32f10x/rtconfig.h index e1d38b4667..ea1542aea2 100644 --- a/bsp/stm32f10x/rtconfig.h +++ b/bsp/stm32f10x/rtconfig.h @@ -14,6 +14,7 @@ #define RT_THREAD_PRIORITY_MAX 32 #define RT_TICK_PER_SECOND 100 #define RT_DEBUG +#define RT_DEBUG_COLOR #define RT_USING_OVERFLOW_CHECK #define RT_DEBUG_INIT 0 #define RT_DEBUG_THREAD 0 diff --git a/bsp/stm32f20x/.config b/bsp/stm32f20x/.config index d7b8a922cc..3e08e1f717 100644 --- a/bsp/stm32f20x/.config +++ b/bsp/stm32f20x/.config @@ -14,6 +14,7 @@ CONFIG_RT_THREAD_PRIORITY_32=y CONFIG_RT_THREAD_PRIORITY_MAX=32 CONFIG_RT_TICK_PER_SECOND=100 CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y CONFIG_RT_USING_OVERFLOW_CHECK=y CONFIG_RT_DEBUG_INIT=0 CONFIG_RT_DEBUG_THREAD=0 diff --git a/bsp/stm32f20x/rtconfig.h b/bsp/stm32f20x/rtconfig.h index 04df5cb236..e976eac230 100644 --- a/bsp/stm32f20x/rtconfig.h +++ b/bsp/stm32f20x/rtconfig.h @@ -12,6 +12,7 @@ #define RT_THREAD_PRIORITY_MAX 32 #define RT_TICK_PER_SECOND 100 #define RT_DEBUG +#define RT_DEBUG_COLOR #define RT_USING_OVERFLOW_CHECK #define RT_DEBUG_INIT 0 #define RT_DEBUG_THREAD 0 diff --git a/bsp/stm32f40x/.config b/bsp/stm32f40x/.config index a6a47ac6f3..e6a7bd72cb 100644 --- a/bsp/stm32f40x/.config +++ b/bsp/stm32f40x/.config @@ -19,6 +19,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=1024 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/stm32f40x/rtconfig.h b/bsp/stm32f40x/rtconfig.h index c855f42fad..1c7a4076f6 100644 --- a/bsp/stm32f40x/rtconfig.h +++ b/bsp/stm32f40x/rtconfig.h @@ -16,6 +16,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 1024 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/stm32f429-apollo/.config b/bsp/stm32f429-apollo/.config index 604b56e5b2..459d9c92a3 100644 --- a/bsp/stm32f429-apollo/.config +++ b/bsp/stm32f429-apollo/.config @@ -20,6 +20,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=1024 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/stm32f429-apollo/drivers/audio/drv_mic.c b/bsp/stm32f429-apollo/drivers/audio/drv_mic.c index 873f37e9b7..3dab97c60a 100644 --- a/bsp/stm32f429-apollo/drivers/audio/drv_mic.c +++ b/bsp/stm32f429-apollo/drivers/audio/drv_mic.c @@ -18,9 +18,7 @@ #include "drv_wm8978.h" #include -#define DBG_ENABLE #define DBG_LEVEL DBG_INFO -#define DBG_COLOR #define DBG_SECTION_NAME "MIC" #include diff --git a/bsp/stm32f429-apollo/drivers/audio/drv_sound.c b/bsp/stm32f429-apollo/drivers/audio/drv_sound.c index 43bbadf412..5bebc01470 100644 --- a/bsp/stm32f429-apollo/drivers/audio/drv_sound.c +++ b/bsp/stm32f429-apollo/drivers/audio/drv_sound.c @@ -19,9 +19,7 @@ #include "drv_wm8978.h" #include -#define DBG_ENABLE #define DBG_LEVEL DBG_LOG -#define DBG_COLOR #define DBG_SECTION_NAME "Sound" #include diff --git a/bsp/stm32f429-apollo/rtconfig.h b/bsp/stm32f429-apollo/rtconfig.h index 9c28c2c959..439bf623aa 100644 --- a/bsp/stm32f429-apollo/rtconfig.h +++ b/bsp/stm32f429-apollo/rtconfig.h @@ -18,6 +18,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 1024 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/stm32f429-disco/.config b/bsp/stm32f429-disco/.config index 1a51abcea1..07c1d6a272 100644 --- a/bsp/stm32f429-disco/.config +++ b/bsp/stm32f429-disco/.config @@ -19,6 +19,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=1024 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/stm32f429-disco/rtconfig.h b/bsp/stm32f429-disco/rtconfig.h index 91dd49c872..9175876eeb 100644 --- a/bsp/stm32f429-disco/rtconfig.h +++ b/bsp/stm32f429-disco/rtconfig.h @@ -16,6 +16,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 1024 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/stm32f4xx-HAL/.config b/bsp/stm32f4xx-HAL/.config index 210efe60dc..50d617be17 100644 --- a/bsp/stm32f4xx-HAL/.config +++ b/bsp/stm32f4xx-HAL/.config @@ -14,6 +14,7 @@ CONFIG_RT_THREAD_PRIORITY_32=y CONFIG_RT_THREAD_PRIORITY_MAX=32 CONFIG_RT_TICK_PER_SECOND=100 CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y CONFIG_RT_USING_OVERFLOW_CHECK=y CONFIG_RT_DEBUG_INIT=0 CONFIG_RT_DEBUG_THREAD=0 diff --git a/bsp/stm32f4xx-HAL/rtconfig.h b/bsp/stm32f4xx-HAL/rtconfig.h index e490ee1f31..0c5877724d 100644 --- a/bsp/stm32f4xx-HAL/rtconfig.h +++ b/bsp/stm32f4xx-HAL/rtconfig.h @@ -14,6 +14,7 @@ #define RT_THREAD_PRIORITY_MAX 32 #define RT_TICK_PER_SECOND 100 #define RT_DEBUG +#define RT_DEBUG_COLOR #define RT_USING_OVERFLOW_CHECK #define RT_DEBUG_INIT 0 #define RT_DEBUG_THREAD 0 diff --git a/bsp/stm32f7-disco/.config b/bsp/stm32f7-disco/.config index 9cdfcfa368..2d9db8e75d 100644 --- a/bsp/stm32f7-disco/.config +++ b/bsp/stm32f7-disco/.config @@ -14,6 +14,7 @@ CONFIG_RT_THREAD_PRIORITY_32=y CONFIG_RT_THREAD_PRIORITY_MAX=32 CONFIG_RT_TICK_PER_SECOND=100 CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y CONFIG_RT_USING_OVERFLOW_CHECK=y CONFIG_RT_DEBUG_INIT=0 CONFIG_RT_DEBUG_THREAD=0 diff --git a/bsp/stm32f7-disco/rtconfig.h b/bsp/stm32f7-disco/rtconfig.h index 5d0a04aad7..98eb060314 100644 --- a/bsp/stm32f7-disco/rtconfig.h +++ b/bsp/stm32f7-disco/rtconfig.h @@ -12,6 +12,7 @@ #define RT_THREAD_PRIORITY_MAX 32 #define RT_TICK_PER_SECOND 100 #define RT_DEBUG +#define RT_DEBUG_COLOR #define RT_USING_OVERFLOW_CHECK #define RT_DEBUG_INIT 0 #define RT_DEBUG_THREAD 0 diff --git a/bsp/stm32h743-nucleo/.config b/bsp/stm32h743-nucleo/.config index 1576a11eff..30867d5aab 100644 --- a/bsp/stm32h743-nucleo/.config +++ b/bsp/stm32h743-nucleo/.config @@ -19,6 +19,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=256 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/stm32h743-nucleo/rtconfig.h b/bsp/stm32h743-nucleo/rtconfig.h index 7f092e5fa7..4e9e91ff6d 100644 --- a/bsp/stm32h743-nucleo/rtconfig.h +++ b/bsp/stm32h743-nucleo/rtconfig.h @@ -19,6 +19,7 @@ #define IDLE_THREAD_STACK_SIZE 256 /* RT_USING_TIMER_SOFT is not set */ #define RT_DEBUG +#define RT_DEBUG_COLOR /* RT_DEBUG_INIT_CONFIG is not set */ /* RT_DEBUG_THREAD_CONFIG is not set */ /* RT_DEBUG_SCHEDULER_CONFIG is not set */ diff --git a/bsp/stm32l475-iot-disco/rtconfig.h b/bsp/stm32l475-iot-disco/rtconfig.h index f7b00767d2..4cc0d9da9a 100644 --- a/bsp/stm32l475-iot-disco/rtconfig.h +++ b/bsp/stm32l475-iot-disco/rtconfig.h @@ -17,6 +17,7 @@ /* SECTION: RT_DEBUG */ /* Thread Debug */ #define RT_DEBUG +#define RT_DEBUG_COLOR #define RT_USING_OVERFLOW_CHECK /* Using Hook */ diff --git a/bsp/stm32l476-nucleo/.config b/bsp/stm32l476-nucleo/.config index 529d8c5fb0..943036d2f2 100644 --- a/bsp/stm32l476-nucleo/.config +++ b/bsp/stm32l476-nucleo/.config @@ -19,6 +19,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=256 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/stm32l476-nucleo/rtconfig.h b/bsp/stm32l476-nucleo/rtconfig.h index d1e5fd2e41..a18d036962 100644 --- a/bsp/stm32l476-nucleo/rtconfig.h +++ b/bsp/stm32l476-nucleo/rtconfig.h @@ -16,6 +16,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 256 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/swm320-lq100/.config b/bsp/swm320-lq100/.config index 4eb8c0a38e..6e380259b4 100644 --- a/bsp/swm320-lq100/.config +++ b/bsp/swm320-lq100/.config @@ -21,6 +21,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=256 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/swm320-lq100/rtconfig.h b/bsp/swm320-lq100/rtconfig.h index 13645d862c..f62b9f87e9 100644 --- a/bsp/swm320-lq100/rtconfig.h +++ b/bsp/swm320-lq100/rtconfig.h @@ -17,6 +17,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 256 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/synopsys/emsk_em9d/.config b/bsp/synopsys/emsk_em9d/.config index 55759f136a..4e5baa1877 100644 --- a/bsp/synopsys/emsk_em9d/.config +++ b/bsp/synopsys/emsk_em9d/.config @@ -21,6 +21,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=256 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/synopsys/emsk_em9d/rtconfig.h b/bsp/synopsys/emsk_em9d/rtconfig.h index 865e753ae5..d2fab1109a 100644 --- a/bsp/synopsys/emsk_em9d/rtconfig.h +++ b/bsp/synopsys/emsk_em9d/rtconfig.h @@ -20,6 +20,7 @@ #define IDLE_THREAD_STACK_SIZE 512 //
#define RT_DEBUG +#define RT_DEBUG_COLOR // // #define RT_THREAD_DEBUG // diff --git a/bsp/tm4c129x/.config b/bsp/tm4c129x/.config index d12272fbf8..1c373715d4 100644 --- a/bsp/tm4c129x/.config +++ b/bsp/tm4c129x/.config @@ -23,6 +23,7 @@ CONFIG_RT_USING_TIMER_SOFT=y CONFIG_RT_TIMER_THREAD_PRIO=4 CONFIG_RT_TIMER_THREAD_STACK_SIZE=512 CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/tm4c129x/rtconfig.h b/bsp/tm4c129x/rtconfig.h index f6eef5ad5f..6a7a5c804f 100644 --- a/bsp/tm4c129x/rtconfig.h +++ b/bsp/tm4c129x/rtconfig.h @@ -20,6 +20,7 @@ #define RT_TIMER_THREAD_PRIO 4 #define RT_TIMER_THREAD_STACK_SIZE 512 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/tms320f28379d/.config b/bsp/tms320f28379d/.config index d62b1e40c8..4d68f71848 100644 --- a/bsp/tms320f28379d/.config +++ b/bsp/tms320f28379d/.config @@ -21,6 +21,7 @@ CONFIG_RT_IDEL_HOOK_LIST_SIZE=4 CONFIG_IDLE_THREAD_STACK_SIZE=256 # CONFIG_RT_USING_TIMER_SOFT is not set CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y # CONFIG_RT_DEBUG_INIT_CONFIG is not set # CONFIG_RT_DEBUG_THREAD_CONFIG is not set # CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set diff --git a/bsp/tms320f28379d/rtconfig.h b/bsp/tms320f28379d/rtconfig.h index b037295813..139789a5b2 100644 --- a/bsp/tms320f28379d/rtconfig.h +++ b/bsp/tms320f28379d/rtconfig.h @@ -19,6 +19,7 @@ #define RT_IDEL_HOOK_LIST_SIZE 4 #define IDLE_THREAD_STACK_SIZE 256 #define RT_DEBUG +#define RT_DEBUG_COLOR /* Inter-Thread communication */ diff --git a/bsp/upd70f3454/rtconfig.h b/bsp/upd70f3454/rtconfig.h index 37188b43c8..894bc5beff 100644 --- a/bsp/upd70f3454/rtconfig.h +++ b/bsp/upd70f3454/rtconfig.h @@ -17,6 +17,7 @@ /* SECTION: RT_DEBUG */ /* Thread Debug */ #define RT_DEBUG +#define RT_DEBUG_COLOR ///#define SCHEDULER_DEBUG #define RT_USING_OVERFLOW_CHECK diff --git a/bsp/x1000/.config b/bsp/x1000/.config index 9ac579ccd9..9a5600a15e 100644 --- a/bsp/x1000/.config +++ b/bsp/x1000/.config @@ -14,6 +14,7 @@ CONFIG_RT_THREAD_PRIORITY_32=y CONFIG_RT_THREAD_PRIORITY_MAX=32 CONFIG_RT_TICK_PER_SECOND=1000 CONFIG_RT_DEBUG=y +CONFIG_RT_DEBUG_COLOR=y CONFIG_RT_USING_OVERFLOW_CHECK=y CONFIG_RT_DEBUG_INIT=0 CONFIG_RT_DEBUG_THREAD=0 diff --git a/bsp/x1000/drivers/mmc/drv_mmc.c b/bsp/x1000/drivers/mmc/drv_mmc.c index c2fa538fbc..d2b0016f4b 100644 --- a/bsp/x1000/drivers/mmc/drv_mmc.c +++ b/bsp/x1000/drivers/mmc/drv_mmc.c @@ -33,12 +33,8 @@ #define DMA_ALIGN (32U) #define PIO_THRESHOLD 64 /* use pio mode if data length < PIO_THRESHOLD */ -#define DEBUG_ENABLE -#define DEBUG_SECTION_NAME "SDIO" -#define DEBUG_LEVEL DBG_INFO -// #define DEBUG_LEVEL DBG_LOG -#define DEBUG_COLOR - +#define DBG_SECTION_NAME "SDIO" +#define DBG_LEVEL DBG_INFO #include /* diff --git a/bsp/x1000/rtconfig.h b/bsp/x1000/rtconfig.h index 6babbd0b15..e7c3e5feda 100644 --- a/bsp/x1000/rtconfig.h +++ b/bsp/x1000/rtconfig.h @@ -14,6 +14,7 @@ #define RT_THREAD_PRIORITY_MAX 32 #define RT_TICK_PER_SECOND 1000 #define RT_DEBUG +#define RT_DEBUG_COLOR #define RT_USING_OVERFLOW_CHECK #define RT_DEBUG_INIT 0 #define RT_DEBUG_THREAD 0 diff --git a/bsp/x86/rtconfig.h b/bsp/x86/rtconfig.h index 2878f811d0..c4cdac1fdc 100644 --- a/bsp/x86/rtconfig.h +++ b/bsp/x86/rtconfig.h @@ -17,6 +17,7 @@ /* SECTION: RT_DEBUG */ /* Thread Debug */ #define RT_DEBUG +#define RT_DEBUG_COLOR #define RT_DEBUG_MODULE 0 #define RT_USING_OVERFLOW_CHECK diff --git a/bsp/xplorer4330/M0/rtconfig.h b/bsp/xplorer4330/M0/rtconfig.h index ee849028f2..19c70eb642 100644 --- a/bsp/xplorer4330/M0/rtconfig.h +++ b/bsp/xplorer4330/M0/rtconfig.h @@ -22,6 +22,7 @@ //#define RT_USING_MODULE //
#define RT_DEBUG +#define RT_DEBUG_COLOR // #define RT_DEBUG_INIT 0 // diff --git a/bsp/xplorer4330/M4/rtconfig.h b/bsp/xplorer4330/M4/rtconfig.h index ee849028f2..19c70eb642 100644 --- a/bsp/xplorer4330/M4/rtconfig.h +++ b/bsp/xplorer4330/M4/rtconfig.h @@ -22,6 +22,7 @@ //#define RT_USING_MODULE //
#define RT_DEBUG +#define RT_DEBUG_COLOR // #define RT_DEBUG_INIT 0 // diff --git a/bsp/zynq7000/rtconfig.h b/bsp/zynq7000/rtconfig.h index ca304c6ac9..b09fc1ab26 100644 --- a/bsp/zynq7000/rtconfig.h +++ b/bsp/zynq7000/rtconfig.h @@ -20,6 +20,7 @@ #define IDLE_THREAD_STACK_SIZE 512 //
#define RT_DEBUG +#define RT_DEBUG_COLOR // // #define RT_THREAD_DEBUG // diff --git a/components/dfs/include/dfs_private.h b/components/dfs/include/dfs_private.h index e20680d9df..bfc71b3b35 100644 --- a/components/dfs/include/dfs_private.h +++ b/components/dfs/include/dfs_private.h @@ -12,10 +12,8 @@ #include -// #define DBG_ENABLE #define DBG_SECTION_NAME "DFS" -#define DBG_COLOR -#define DBG_LEVEL DBG_LOG +#define DBG_LEVEL DBG_INFO #include #define NO_WORKING_DIR "system does not support working directory\n" diff --git a/components/drivers/misc/adc.c b/components/drivers/misc/adc.c index 83e789a6e4..b2fd9ba430 100644 --- a/components/drivers/misc/adc.c +++ b/components/drivers/misc/adc.c @@ -15,10 +15,8 @@ #include #include -#define DBG_ENABLE #define DBG_SECTION_NAME "adc" #define DBG_LEVEL DBG_INFO -#define DBG_COLOR #include static rt_size_t _adc_read(rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size) diff --git a/components/drivers/sdio/block_dev.c b/components/drivers/sdio/block_dev.c index 23be319fc6..dcfbc0ca7b 100644 --- a/components/drivers/sdio/block_dev.c +++ b/components/drivers/sdio/block_dev.c @@ -13,14 +13,12 @@ #include -#define DBG_ENABLE #define DBG_SECTION_NAME "SDIO" #ifdef RT_SDIO_DEBUG #define DBG_LEVEL DBG_LOG #else #define DBG_LEVEL DBG_INFO #endif /* RT_SDIO_DEBUG */ -#define DBG_COLOR #include static rt_list_t blk_devices = RT_LIST_OBJECT_INIT(blk_devices); @@ -369,7 +367,7 @@ rt_int32_t rt_mmcsd_blk_probe(struct rt_mmcsd_card *card) return err; } - LOG_I("probe mmcsd block device!"); + LOG_D("probe mmcsd block device!"); /* get the first sector to read partition table */ sector = (rt_uint8_t *)rt_malloc(SECTOR_SIZE); diff --git a/components/drivers/sdio/mmc.c b/components/drivers/sdio/mmc.c index bbf0ff838c..5f9259ef52 100644 --- a/components/drivers/sdio/mmc.c +++ b/components/drivers/sdio/mmc.c @@ -11,14 +11,12 @@ #include #include -#define DBG_ENABLE #define DBG_SECTION_NAME "SDIO" #ifdef RT_SDIO_DEBUG #define DBG_LEVEL DBG_LOG #else #define DBG_LEVEL DBG_INFO #endif /* RT_SDIO_DEBUG */ -#define DBG_COLOR #include static const rt_uint32_t tran_unit[] = diff --git a/components/drivers/sdio/mmcsd_core.c b/components/drivers/sdio/mmcsd_core.c index 2206960a69..160defa645 100644 --- a/components/drivers/sdio/mmcsd_core.c +++ b/components/drivers/sdio/mmcsd_core.c @@ -14,14 +14,12 @@ #include #include -#define DBG_ENABLE #define DBG_SECTION_NAME "SDIO" #ifdef RT_SDIO_DEBUG #define DBG_LEVEL DBG_LOG #else #define DBG_LEVEL DBG_INFO #endif /* RT_SDIO_DEBUG */ -#define DBG_COLOR #include #ifndef RT_MMCSD_STACK_SIZE diff --git a/components/drivers/sdio/sd.c b/components/drivers/sdio/sd.c index 69a4561fb0..f4e925507c 100644 --- a/components/drivers/sdio/sd.c +++ b/components/drivers/sdio/sd.c @@ -11,14 +11,12 @@ #include #include -#define DBG_ENABLE #define DBG_SECTION_NAME "SDIO" #ifdef RT_SDIO_DEBUG #define DBG_LEVEL DBG_LOG #else #define DBG_LEVEL DBG_INFO #endif /* RT_SDIO_DEBUG */ -#define DBG_COLOR #include static const rt_uint32_t tran_unit[] = diff --git a/components/drivers/sdio/sdio.c b/components/drivers/sdio/sdio.c index 6045c4ade8..b0516704fd 100644 --- a/components/drivers/sdio/sdio.c +++ b/components/drivers/sdio/sdio.c @@ -12,14 +12,12 @@ #include #include -#define DBG_ENABLE #define DBG_SECTION_NAME "SDIO" #ifdef RT_SDIO_DEBUG #define DBG_LEVEL DBG_LOG #else #define DBG_LEVEL DBG_INFO #endif /* RT_SDIO_DEBUG */ -#define DBG_COLOR #include #ifndef RT_SDIO_STACK_SIZE diff --git a/components/drivers/sensors/sensor.c b/components/drivers/sensors/sensor.c index 0c21f04b6f..99f366ddac 100644 --- a/components/drivers/sensors/sensor.c +++ b/components/drivers/sensors/sensor.c @@ -10,10 +10,8 @@ #include "sensor.h" -#define DBG_ENABLE #define DBG_LEVEL DBG_INFO #define DBG_SECTION_NAME "sensor" -#define DBG_COLOR #include #include diff --git a/components/drivers/sensors/sensor_cmd.c b/components/drivers/sensors/sensor_cmd.c index b6dd471988..07487c8866 100644 --- a/components/drivers/sensors/sensor_cmd.c +++ b/components/drivers/sensors/sensor_cmd.c @@ -10,10 +10,8 @@ #include "sensor.h" -#define DBG_ENABLE #define DBG_LEVEL DBG_INFO #define DBG_SECTION_NAME "sensor.cmd" -#define DBG_COLOR #include #include diff --git a/components/drivers/serial/serial.c b/components/drivers/serial/serial.c index 094c403656..13bf54e721 100644 --- a/components/drivers/serial/serial.c +++ b/components/drivers/serial/serial.c @@ -28,10 +28,8 @@ #include #include -// #define DEBUG_ENABLE -#define DEBUG_LEVEL DBG_LOG +#define DBG_LEVEL DBG_INFO #define DBG_SECTION_NAME "UART" -#define DEBUG_COLOR #include #ifdef RT_USING_POSIX diff --git a/components/drivers/wlan/wlan_cfg.c b/components/drivers/wlan/wlan_cfg.c index 27da9bc24e..00e9dbc83e 100644 --- a/components/drivers/wlan/wlan_cfg.c +++ b/components/drivers/wlan/wlan_cfg.c @@ -11,14 +11,12 @@ #include #include -#define DBG_ENABLE #ifdef RT_WLAN_CFG_DEBUG #define DBG_LEVEL DBG_LOG #else #define DBG_LEVEL DBG_INFO #endif #define DBG_SECTION_NAME "WLAN.cfg" -#define DBG_COLOR #include #define WLAN_CFG_LOCK() (rt_mutex_take(&cfg_mutex, RT_WAITING_FOREVER)) diff --git a/components/drivers/wlan/wlan_dev.c b/components/drivers/wlan/wlan_dev.c index eac1d0f975..3f4adf35ad 100644 --- a/components/drivers/wlan/wlan_dev.c +++ b/components/drivers/wlan/wlan_dev.c @@ -13,14 +13,12 @@ #include #include -#define DBG_ENABLE #ifdef RT_WLAN_DEV_DEBUG #define DBG_LEVEL DBG_LOG #else #define DBG_LEVEL DBG_INFO #endif #define DBG_SECTION_NAME "WLAN.dev" -#define DBG_COLOR #include #ifndef RT_DEVICE diff --git a/components/drivers/wlan/wlan_lwip.c b/components/drivers/wlan/wlan_lwip.c index 2f8bcefd0d..052c2afd2e 100644 --- a/components/drivers/wlan/wlan_lwip.c +++ b/components/drivers/wlan/wlan_lwip.c @@ -21,14 +21,12 @@ #include #endif -#define DBG_ENABLE #ifdef RT_WLAN_LWIP_DEBUG #define DBG_LEVEL DBG_LOG #else #define DBG_LEVEL DBG_INFO #endif #define DBG_SECTION_NAME "WLAN.lwip" -#define DBG_COLOR #include #ifndef IPADDR_STRLEN_MAX diff --git a/components/drivers/wlan/wlan_mgnt.c b/components/drivers/wlan/wlan_mgnt.c index ac0731d06c..ced5bfa1c2 100644 --- a/components/drivers/wlan/wlan_mgnt.c +++ b/components/drivers/wlan/wlan_mgnt.c @@ -16,14 +16,13 @@ #include #include -#define DBG_ENABLE + #ifdef RT_WLAN_MGNT_DEBUG #define DBG_LEVEL DBG_LOG #else #define DBG_LEVEL DBG_INFO #endif #define DBG_SECTION_NAME "WLAN.mgnt" -#define DBG_COLOR #include #ifndef RT_WLAN_DEVICE diff --git a/components/drivers/wlan/wlan_prot.c b/components/drivers/wlan/wlan_prot.c index ec5e419bc4..48adbc48f3 100644 --- a/components/drivers/wlan/wlan_prot.c +++ b/components/drivers/wlan/wlan_prot.c @@ -13,14 +13,12 @@ #include #include -#define DBG_ENABLE #ifdef RT_WLAN_PROT_DEBUG #define DBG_LEVEL DBG_LOG #else #define DBG_LEVEL DBG_INFO #endif #define DBG_SECTION_NAME "WLAN.prot" -#define DBG_COLOR #include #if RT_WLAN_PROT_NAME_LEN < 4 diff --git a/components/drivers/wlan/wlan_workqueue.c b/components/drivers/wlan/wlan_workqueue.c index f65ac95d08..23823afae0 100644 --- a/components/drivers/wlan/wlan_workqueue.c +++ b/components/drivers/wlan/wlan_workqueue.c @@ -13,10 +13,8 @@ #include #include -#define DBG_ENABLE #define DBG_LEVEL DBG_INFO #define DBG_SECTION_NAME "WLAN.work" -#define DBG_COLOR #include struct rt_wlan_work diff --git a/components/libc/libdl/dlelf.c b/components/libc/libdl/dlelf.c index 6d83424b80..4557ee3458 100644 --- a/components/libc/libdl/dlelf.c +++ b/components/libc/libdl/dlelf.c @@ -12,9 +12,7 @@ #include "dlelf.h" #define DBG_SECTION_NAME "DLMD" -#define DBG_ENABLE // enable debug macro #define DBG_LEVEL DBG_INFO -#define DBG_COLOR #include // must after of DEBUG_ENABLE or some other options rt_err_t dlmodule_load_shared_object(struct rt_dlmodule* module, void *module_ptr) diff --git a/components/libc/libdl/dlmodule.c b/components/libc/libdl/dlmodule.c index 61ffbfc772..0029c01728 100644 --- a/components/libc/libdl/dlmodule.c +++ b/components/libc/libdl/dlmodule.c @@ -17,9 +17,7 @@ #include #define DBG_SECTION_NAME "DLMD" -#define DBG_ENABLE // enable debug macro #define DBG_LEVEL DBG_INFO -#define DBG_COLOR #include // must after of DEBUG_ENABLE or some other options static struct rt_module_symtab *_rt_module_symtab_begin = RT_NULL; diff --git a/components/lwp/lwp.c b/components/lwp/lwp.c index 84d6515ac6..e1ba26f21c 100644 --- a/components/lwp/lwp.c +++ b/components/lwp/lwp.c @@ -19,9 +19,7 @@ #include "lwp.h" -#define DBG_ENABLE #define DBG_SECTION_NAME "LWP" -#define DBG_COLOR #define DBG_LEVEL DBG_WARNING #include diff --git a/components/lwp/lwp_mem.c b/components/lwp/lwp_mem.c index ebc878494a..e733166934 100644 --- a/components/lwp/lwp_mem.c +++ b/components/lwp/lwp_mem.c @@ -11,9 +11,7 @@ #include #include -#define DBG_ENABLE #define DBG_SECTION_NAME "LWPMEM" -#define DBG_COLOR #define DBG_LEVEL DBG_WARNING #include diff --git a/components/lwp/lwp_syscall.c b/components/lwp/lwp_syscall.c index 5d4bbf6d91..723786f1cd 100644 --- a/components/lwp/lwp_syscall.c +++ b/components/lwp/lwp_syscall.c @@ -24,9 +24,7 @@ #define SYSCALL_NET(f) ((void*)sys_notimpl) #endif -#define DBG_ENABLE #define DBG_SECTION_NAME "LWP_CALL" -#define DBG_COLOR #define DBG_LEVEL DBG_WARNING #include diff --git a/components/net/at/include/at_log.h b/components/net/at/include/at_log.h index 278763d30e..fe8766ba95 100644 --- a/components/net/at/include/at_log.h +++ b/components/net/at/include/at_log.h @@ -12,9 +12,6 @@ * NOTE: DO NOT include this file on the header file. */ -#define DBG_ENABLE -#define DBG_COLOR - #ifndef LOG_TAG #define DBG_SECTION_NAME "at" #else diff --git a/components/net/sal_socket/src/sal_socket.c b/components/net/sal_socket/src/sal_socket.c index dba8e66254..771a56f061 100644 --- a/components/net/sal_socket/src/sal_socket.c +++ b/components/net/sal_socket/src/sal_socket.c @@ -19,10 +19,8 @@ #endif #include -#define DBG_ENABLE -#define DBG_SECTION_NAME "SAL_SOC" +#define DBG_SECTION_NAME "SAL_SKT" #define DBG_LEVEL DBG_INFO -#define DBG_COLOR #include #define SOCKET_TABLE_STEP_LEN 4 diff --git a/components/utilities/Kconfig b/components/utilities/Kconfig index 1175006a58..504a56691d 100644 --- a/components/utilities/Kconfig +++ b/components/utilities/Kconfig @@ -222,12 +222,6 @@ config RT_USING_ULOG select ULOG_OUTPUT_TIME select ULOG_USING_FILTER default n - - config ULOG_SW_VERSION_NUM - hex - default 0x00101 - help - sfotware module version number endif config RT_USING_UTEST diff --git a/components/utilities/ulog/ulog_def.h b/components/utilities/ulog/ulog_def.h index e7c033f71c..40b39de972 100644 --- a/components/utilities/ulog/ulog_def.h +++ b/components/utilities/ulog/ulog_def.h @@ -47,7 +47,7 @@ extern "C" { #define DBG_INFO LOG_LVL_INFO #define DBG_LOG LOG_LVL_DBG #define dbg_log(level, ...) \ - if ((level) <= DBG_LEVEL) \ + if ((level) <= LOG_LVL) \ { \ ulog_output(level, LOG_TAG, RT_FALSE, __VA_ARGS__);\ } diff --git a/components/utilities/utest/utest.c b/components/utilities/utest/utest.c index f7348b3be4..7bc2c93656 100644 --- a/components/utilities/utest/utest.c +++ b/components/utilities/utest/utest.c @@ -17,17 +17,13 @@ #undef DBG_SECTION_NAME #undef DBG_LEVEL -#undef DBG_COLOR -#undef DBG_ENABLE -#define DBG_ENABLE #define DBG_SECTION_NAME "utest" #ifdef UTEST_DEBUG #define DBG_LEVEL DBG_LOG #else #define DBG_LEVEL DBG_INFO #endif -#define DBG_COLOR #include #if RT_CONSOLEBUF_SIZE < 256 diff --git a/components/utilities/utest/utest_log.h b/components/utilities/utest/utest_log.h index 9f38d3f9c8..c4bd25a80b 100644 --- a/components/utilities/utest/utest_log.h +++ b/components/utilities/utest/utest_log.h @@ -17,17 +17,13 @@ #undef DBG_SECTION_NAME #undef DBG_LEVEL -#undef DBG_COLOR -#undef DBG_ENABLE -#define DBG_ENABLE #define DBG_SECTION_NAME "testcase" #ifdef UTEST_DEBUG #define DBG_LEVEL DBG_LOG #else #define DBG_LEVEL DBG_INFO #endif -#define DBG_COLOR #include #define UTEST_LOG_ALL (1u) diff --git a/examples/network/tcpclient.c b/examples/network/tcpclient.c index d4c96f893a..be50711e94 100644 --- a/examples/network/tcpclient.c +++ b/examples/network/tcpclient.c @@ -12,14 +12,12 @@ #define DEBUG_TCP_CLIENT -#define DBG_ENABLE #define DBG_SECTION_NAME "TCP" #ifdef DEBUG_TCP_CLIENT #define DBG_LEVEL DBG_LOG #else #define DBG_LEVEL DBG_INFO /* DBG_ERROR */ #endif -#define DBG_COLOR #include #define BUFSZ 1024 diff --git a/examples/network/tcpserver.c b/examples/network/tcpserver.c index 264b6f7c83..0837495366 100644 --- a/examples/network/tcpserver.c +++ b/examples/network/tcpserver.c @@ -12,14 +12,12 @@ #define DEBUG_TCP_SERVER -#define DBG_ENABLE #define DBG_SECTION_NAME "TCP" #ifdef DEBUG_TCP_SERVER #define DBG_LEVEL DBG_LOG #else #define DBG_LEVEL DBG_INFO /* DBG_ERROR */ #endif -#define DBG_COLOR #include #define BUFSZ (1024) diff --git a/examples/network/udpclient.c b/examples/network/udpclient.c index 40542b9fa1..d43b46a446 100644 --- a/examples/network/udpclient.c +++ b/examples/network/udpclient.c @@ -5,14 +5,12 @@ #define DEBUG_UDP_CLIENT -#define DBG_ENABLE #define DBG_SECTION_NAME "UDP" #ifdef DEBUG_UDP_CLIENT #define DBG_LEVEL DBG_LOG #else #define DBG_LEVEL DBG_INFO /* DBG_ERROR */ #endif -#define DBG_COLOR #include static int started = 0; diff --git a/examples/network/udpserver.c b/examples/network/udpserver.c index c40a1972b4..40dd754673 100644 --- a/examples/network/udpserver.c +++ b/examples/network/udpserver.c @@ -12,14 +12,12 @@ #define DEBUG_UDP_SERVER -#define DBG_ENABLE #define DBG_SECTION_NAME "UDP" #ifdef DEBUG_UDP_SERVER #define DBG_LEVEL DBG_LOG #else #define DBG_LEVEL DBG_INFO /* DBG_ERROR */ #endif -#define DBG_COLOR #include #define BUFSZ 1024 diff --git a/include/rtdbg.h b/include/rtdbg.h index 9036a0cd66..97845321e7 100644 --- a/include/rtdbg.h +++ b/include/rtdbg.h @@ -19,16 +19,12 @@ * header file. * * #define DBG_SECTION_NAME "MOD" - * #define DBG_ENABLE // enable debug macro * #define DBG_LEVEL DBG_INFO - * #include // must after of DEBUG_ENABLE or some other options + * #include // must after of DBG_LEVEL, DBG_SECTION_NAME or other options * * Then in your C/C++ file, you can use LOG_X macro to print out logs: * LOG_D("this is a debug log!"); * LOG_E("this is a error log!"); - * - * If you want to use different color for different kinds log, you can - * #define DBG_COLOR */ #ifndef RT_DBG_H__ @@ -36,6 +32,16 @@ #include +/* the debug log will force enable when RT_DEBUG macro is defined */ +#if defined(RT_DEBUG) && !defined(DBG_ENABLE) +#define DBG_ENABLE +#endif + +/* it will force output color log when RT_DEBUG_COLOR macro is defined */ +#if defined(RT_DEBUG_COLOR) && !defined(DBG_COLOR) +#define DBG_COLOR +#endif + #if defined(RT_USING_ULOG) && defined(DBG_ENABLE) /* using ulog compatible with rtdbg */ #include diff --git a/src/Kconfig b/src/Kconfig index 2fdcfd4982..fbfae65882 100644 --- a/src/Kconfig +++ b/src/Kconfig @@ -113,6 +113,10 @@ menuconfig RT_DEBUG if RT_DEBUG +config RT_DEBUG_COLOR + bool "Enable color debugging log" + default y + config RT_DEBUG_INIT_CONFIG bool "Enable debugging of components initialization" default n diff --git a/src/signal.c b/src/signal.c index 05632b2c4a..c9d6c20805 100644 --- a/src/signal.c +++ b/src/signal.c @@ -22,10 +22,8 @@ #define RT_SIG_INFO_MAX 32 #endif -// #define DBG_ENABLE #define DBG_SECTION_NAME "SIGN" -#define DBG_COLOR -#define DBG_LEVEL DBG_LOG +#define DBG_LEVEL DBG_INFO #include #define sig_mask(sig_no) (1u << sig_no) -- cgit v1.3.1 From fa4d4ab7cf774ccb701d01a6fd1371ce8d9474e9 Mon Sep 17 00:00:00 2001 From: armink Date: Fri, 12 Apr 2019 10:18:57 +0800 Subject: Update all of debug log definition to DBG_TAG and DBG_LVL. --- bsp/allwinner_tina/drivers/drv_gpio.c | 4 ++-- bsp/allwinner_tina/drivers/drv_sdio.c | 10 +++++----- bsp/allwinner_tina/drivers/spi/drv_spi.c | 6 +++--- bsp/allwinner_tina/drivers/spi/drv_spi_flash.c | 4 ++-- bsp/amebaz/drivers/wlan/drv_wifi.c | 4 ++-- bsp/imxrt/Libraries/imxrt1021/drivers/drv_eth.c | 7 +++---- bsp/imxrt/Libraries/imxrt1021/drivers/drv_flexspi_nor.c | 4 ++-- bsp/imxrt/Libraries/imxrt1050/drivers/drv_eth.c | 4 ++-- bsp/imxrt/Libraries/imxrt1050/drivers/drv_eth_fire.c | 4 ++-- bsp/imxrt/Libraries/imxrt1050/drivers/drv_flexspi_hyper.c | 4 ++-- bsp/imxrt/Libraries/imxrt1050/drivers/drv_flexspi_nor.c | 4 ++-- bsp/k210/driver/drv_gpio.c | 4 ++-- bsp/k210/driver/drv_lcd.c | 6 ++---- bsp/qemu-vexpress-a9/drivers/audio/drv_pl041.c | 10 +++++----- bsp/qemu-vexpress-a9/drivers/drv_keyboard.c | 2 +- bsp/qemu-vexpress-a9/drivers/drv_mouse.c | 4 ++-- bsp/qemu-vexpress-a9/drivers/drv_sdio.c | 4 ++-- bsp/stm32/libraries/HAL_Drivers/drv_log.h | 8 ++++---- bsp/stm32/stm32f103-fire-arbitrary/board/ports/sdcard_port.c | 4 ++-- bsp/stm32/stm32f407-atk-explorer/board/ports/sdcard_port.c | 4 ++-- bsp/stm32/stm32f429-armfly-v6/board/ports/sdcard_port.c | 4 ++-- bsp/stm32/stm32f429-atk-apollo/board/ports/sdcard_port.c | 4 ++-- bsp/stm32/stm32f429-fire-challenger/board/ports/sdcard_port.c | 4 ++-- bsp/stm32/stm32f746-st-disco/board/ports/sdcard_port.c | 4 ++-- bsp/stm32/stm32f767-atk-apollo/board/ports/sdcard_port.c | 4 ++-- bsp/stm32/stm32f767-fire-challenger/board/ports/sdcard_port.c | 5 ++--- bsp/stm32/stm32l475-atk-pandora/board/ports/sdcard_port.c | 5 ++--- bsp/stm32/stm32l496-ali-developer/board/ports/sdcard_port.c | 5 ++--- bsp/stm32f429-apollo/drivers/audio/drv_mic.c | 4 ++-- bsp/stm32f429-apollo/drivers/audio/drv_sound.c | 4 ++-- bsp/w60x/drivers/drv_wifi.c | 6 ++---- bsp/x1000/drivers/mmc/drv_mmc.c | 4 ++-- components/dfs/include/dfs_private.h | 4 ++-- components/drivers/misc/adc.c | 4 ++-- components/drivers/sdio/block_dev.c | 6 +++--- components/drivers/sdio/mmc.c | 6 +++--- components/drivers/sdio/mmcsd_core.c | 6 +++--- components/drivers/sdio/sd.c | 6 +++--- components/drivers/sdio/sdio.c | 6 +++--- components/drivers/sensors/sensor.c | 4 ++-- components/drivers/sensors/sensor_cmd.c | 4 ++-- components/drivers/serial/serial.c | 4 ++-- components/drivers/wlan/wlan_cfg.c | 8 ++++---- components/drivers/wlan/wlan_dev.c | 8 ++++---- components/drivers/wlan/wlan_lwip.c | 8 ++++---- components/drivers/wlan/wlan_mgnt.c | 9 ++++----- components/drivers/wlan/wlan_prot.c | 8 ++++---- components/drivers/wlan/wlan_workqueue.c | 4 ++-- components/libc/libdl/dlelf.c | 4 ++-- components/libc/libdl/dlmodule.c | 4 ++-- components/lwp/lwp.c | 4 ++-- components/lwp/lwp_mem.c | 4 ++-- components/lwp/lwp_syscall.c | 4 ++-- components/net/at/include/at_log.h | 8 ++++---- components/net/sal_socket/src/sal_socket.c | 4 ++-- components/utilities/ulog/ulog_def.h | 8 ++++++-- components/utilities/utest/utest.c | 10 +++++----- components/utilities/utest/utest_log.h | 10 +++++----- examples/network/tcpclient.c | 6 +++--- examples/network/tcpserver.c | 6 +++--- examples/network/udpclient.c | 6 +++--- examples/network/udpserver.c | 6 +++--- src/signal.c | 4 ++-- 63 files changed, 166 insertions(+), 171 deletions(-) (limited to 'examples') diff --git a/bsp/allwinner_tina/drivers/drv_gpio.c b/bsp/allwinner_tina/drivers/drv_gpio.c index e8d82a3fae..b121842b30 100644 --- a/bsp/allwinner_tina/drivers/drv_gpio.c +++ b/bsp/allwinner_tina/drivers/drv_gpio.c @@ -27,8 +27,8 @@ #include "drv_gpio.h" #include "interrupt.h" -#define DBG_SECTION_NAME "GPIO" -#define DBG_LEVEL DBG_WARNING +#define DBG_TAG "GPIO" +#define DBG_LVL DBG_WARNING #include #define readl(addr) (*(volatile unsigned int *)(addr)) diff --git a/bsp/allwinner_tina/drivers/drv_sdio.c b/bsp/allwinner_tina/drivers/drv_sdio.c index c1b4bcc41c..11b5a63d02 100644 --- a/bsp/allwinner_tina/drivers/drv_sdio.c +++ b/bsp/allwinner_tina/drivers/drv_sdio.c @@ -33,11 +33,11 @@ #include "drv_clock.h" -#define DBG_SECTION_NAME "MMC" -// #define DBG_LEVEL DBG_LOG -// #define DBG_LEVEL DBG_INFO -#define DBG_LEVEL DBG_WARNING -// #define DBG_LEVEL DBG_ERROR +#define DBG_TAG "MMC" +// #define DBG_LVL DBG_LOG +// #define DBG_LVL DBG_INFO +#define DBG_LVL DBG_WARNING +// #define DBG_LVL DBG_ERROR #include #ifdef RT_USING_SDIO diff --git a/bsp/allwinner_tina/drivers/spi/drv_spi.c b/bsp/allwinner_tina/drivers/spi/drv_spi.c index a271c2e7d9..506b0cae99 100644 --- a/bsp/allwinner_tina/drivers/spi/drv_spi.c +++ b/bsp/allwinner_tina/drivers/spi/drv_spi.c @@ -35,11 +35,11 @@ //#define DEBUG -#define DBG_SECTION_NAME "SPI" +#define DBG_TAG "SPI" #ifdef DEBUG -#define DBG_LEVEL DBG_LOG +#define DBG_LVL DBG_LOG #else -#define DBG_LEVEL DBG_WARNING +#define DBG_LVL DBG_WARNING #endif /* DEBUG */ #include diff --git a/bsp/allwinner_tina/drivers/spi/drv_spi_flash.c b/bsp/allwinner_tina/drivers/spi/drv_spi_flash.c index 0b01200ee8..e507859928 100644 --- a/bsp/allwinner_tina/drivers/spi/drv_spi_flash.c +++ b/bsp/allwinner_tina/drivers/spi/drv_spi_flash.c @@ -26,8 +26,8 @@ #include #include -#define DBG_SECTION_NAME "FLASH" -#define DBG_LEVEL DBG_LOG +#define DBG_TAG "FLASH" +#define DBG_LVL DBG_LOG #include #define SPI_FLASH_DEVICE_NAME "spi00" diff --git a/bsp/amebaz/drivers/wlan/drv_wifi.c b/bsp/amebaz/drivers/wlan/drv_wifi.c index 753952df43..12865bfc3b 100644 --- a/bsp/amebaz/drivers/wlan/drv_wifi.c +++ b/bsp/amebaz/drivers/wlan/drv_wifi.c @@ -28,8 +28,8 @@ #include "drv_wlan.h" #include "drv_wifi.h" -#define DBG_LEVEL DBG_INFO -#define DBG_SECTION_NAME "WIFI" +#define DBG_LVL DBG_INFO +#define DBG_TAG "WIFI" #include #define MAX_ADDR_LEN (6) diff --git a/bsp/imxrt/Libraries/imxrt1021/drivers/drv_eth.c b/bsp/imxrt/Libraries/imxrt1021/drivers/drv_eth.c index 24b8e51736..15aa05e838 100644 --- a/bsp/imxrt/Libraries/imxrt1021/drivers/drv_eth.c +++ b/bsp/imxrt/Libraries/imxrt1021/drivers/drv_eth.c @@ -40,10 +40,9 @@ //#define ETH_RX_DUMP //#define ETH_TX_DUMP -#define DBG_ENABLE -#define DBG_SECTION_NAME "ETH" -#define DBG_COLOR -#define DBG_LEVEL DBG_INFO + +#define DBG_TAG "ETH" +#define DBG_LVL DBG_INFO #include #define MAX_ADDR_LEN 6 diff --git a/bsp/imxrt/Libraries/imxrt1021/drivers/drv_flexspi_nor.c b/bsp/imxrt/Libraries/imxrt1021/drivers/drv_flexspi_nor.c index 0e49ae01fb..fc69e65375 100644 --- a/bsp/imxrt/Libraries/imxrt1021/drivers/drv_flexspi_nor.c +++ b/bsp/imxrt/Libraries/imxrt1021/drivers/drv_flexspi_nor.c @@ -14,8 +14,8 @@ #include #include "drv_flexspi.h" -#define DBG_SECTION_NAME "FLEXSPI" -#define DBG_LEVEL DBG_LOG +#define DBG_TAG "FLEXSPI" +#define DBG_LVL DBG_LOG #include #define FLEXSPI_CLOCK kCLOCK_FlexSpi diff --git a/bsp/imxrt/Libraries/imxrt1050/drivers/drv_eth.c b/bsp/imxrt/Libraries/imxrt1050/drivers/drv_eth.c index efc5cb9ca9..cc591b944a 100644 --- a/bsp/imxrt/Libraries/imxrt1050/drivers/drv_eth.c +++ b/bsp/imxrt/Libraries/imxrt1050/drivers/drv_eth.c @@ -46,8 +46,8 @@ //#define ETH_RX_DUMP //#define ETH_TX_DUMP -#define DBG_SECTION_NAME "ETH" -#define DBG_LEVEL DBG_INFO +#define DBG_TAG "ETH" +#define DBG_LVL DBG_INFO #include #define MAX_ADDR_LEN 6 diff --git a/bsp/imxrt/Libraries/imxrt1050/drivers/drv_eth_fire.c b/bsp/imxrt/Libraries/imxrt1050/drivers/drv_eth_fire.c index 1cae69ba17..ef6008ca78 100644 --- a/bsp/imxrt/Libraries/imxrt1050/drivers/drv_eth_fire.c +++ b/bsp/imxrt/Libraries/imxrt1050/drivers/drv_eth_fire.c @@ -37,8 +37,8 @@ //#define ETH_RX_DUMP //#define ETH_TX_DUMP -#define DBG_SECTION_NAME "ETH" -#define DBG_LEVEL DBG_LOG +#define DBG_TAG "ETH" +#define DBG_LVL DBG_LOG #include #define MAX_ADDR_LEN 6 diff --git a/bsp/imxrt/Libraries/imxrt1050/drivers/drv_flexspi_hyper.c b/bsp/imxrt/Libraries/imxrt1050/drivers/drv_flexspi_hyper.c index 5ca326070c..5e0192f8ba 100644 --- a/bsp/imxrt/Libraries/imxrt1050/drivers/drv_flexspi_hyper.c +++ b/bsp/imxrt/Libraries/imxrt1050/drivers/drv_flexspi_hyper.c @@ -14,8 +14,8 @@ #include #include "drv_flexspi.h" -#define DBG_SECTION_NAME "Hyper" -#define DBG_LEVEL DBG_LOG +#define DBG_TAG "Hyper" +#define DBG_LVL DBG_LOG #include #define FLEXSPI_CLOCK kCLOCK_FlexSpi diff --git a/bsp/imxrt/Libraries/imxrt1050/drivers/drv_flexspi_nor.c b/bsp/imxrt/Libraries/imxrt1050/drivers/drv_flexspi_nor.c index 4e9e738b6c..05b4e32331 100644 --- a/bsp/imxrt/Libraries/imxrt1050/drivers/drv_flexspi_nor.c +++ b/bsp/imxrt/Libraries/imxrt1050/drivers/drv_flexspi_nor.c @@ -13,8 +13,8 @@ #include #include "drv_flexspi.h" -#define DBG_SECTION_NAME "FLEXSPI" -#define DBG_LEVEL DBG_LOG +#define DBG_TAG "FLEXSPI" +#define DBG_LVL DBG_LOG #include #define FLEXSPI_CLOCK kCLOCK_FlexSpi diff --git a/bsp/k210/driver/drv_gpio.c b/bsp/k210/driver/drv_gpio.c index 25ee6f68b0..4efce0e827 100644 --- a/bsp/k210/driver/drv_gpio.c +++ b/bsp/k210/driver/drv_gpio.c @@ -20,8 +20,8 @@ #include #define DBG_ENABLE -#define DBG_SECTION_NAME "PIN" -#define DBG_LEVEL DBG_WARNING +#define DBG_TAG "PIN" +#define DBG_LVL DBG_WARNING #define DBG_COLOR #include diff --git a/bsp/k210/driver/drv_lcd.c b/bsp/k210/driver/drv_lcd.c index cd7d11bbb5..2719391154 100644 --- a/bsp/k210/driver/drv_lcd.c +++ b/bsp/k210/driver/drv_lcd.c @@ -21,10 +21,8 @@ #include #include -#define DBG_ENABLE -#define DBG_SECTION_NAME "LCD" -#define DBG_LEVEL DBG_WARNING -#define DBG_COLOR +#define DBG_TAG "LCD" +#define DBG_LVL DBG_WARNING #include #define NO_OPERATION 0x00 diff --git a/bsp/qemu-vexpress-a9/drivers/audio/drv_pl041.c b/bsp/qemu-vexpress-a9/drivers/audio/drv_pl041.c index 68f8f09c10..51cf3710ef 100644 --- a/bsp/qemu-vexpress-a9/drivers/audio/drv_pl041.c +++ b/bsp/qemu-vexpress-a9/drivers/audio/drv_pl041.c @@ -28,11 +28,11 @@ #include "drv_ac97.h" #include "realview.h" -#define DBG_SECTION_NAME "PL041" -// #define DBG_LEVEL DBG_LOG -// #define DBG_LEVEL DBG_INFO -#define DBG_LEVEL DBG_WARNING -// #define DBG_LEVEL DBG_ERROR +#define DBG_TAG "PL041" +// #define DBG_LVL DBG_LOG +// #define DBG_LVL DBG_INFO +#define DBG_LVL DBG_WARNING +// #define DBG_LVL DBG_ERROR #include #define FRAME_PERIOD_US (50) diff --git a/bsp/qemu-vexpress-a9/drivers/drv_keyboard.c b/bsp/qemu-vexpress-a9/drivers/drv_keyboard.c index 4948f46117..246e053a60 100644 --- a/bsp/qemu-vexpress-a9/drivers/drv_keyboard.c +++ b/bsp/qemu-vexpress-a9/drivers/drv_keyboard.c @@ -6,7 +6,7 @@ #include "interrupt.h" #include "drv_keyboard.h" -#define DBG_LEVEL DBG_INFO +#define DBG_LVL DBG_INFO #include "rtdbg.h" #define KEYBOARD_ADDRESS (0x10006000) diff --git a/bsp/qemu-vexpress-a9/drivers/drv_mouse.c b/bsp/qemu-vexpress-a9/drivers/drv_mouse.c index 852cc56129..07e3ed16f6 100644 --- a/bsp/qemu-vexpress-a9/drivers/drv_mouse.c +++ b/bsp/qemu-vexpress-a9/drivers/drv_mouse.c @@ -7,8 +7,8 @@ #include "drv_mouse.h" #include "drv_clcd.h" -#define DBG_SECTION_NAME "drv.mouse" -#define DBG_LEVEL DBG_INFO +#define DBG_TAG "drv.mouse" +#define DBG_LVL DBG_INFO #include "rtdbg.h" #define MOUSE_ADDRESS (0x10007000) diff --git a/bsp/qemu-vexpress-a9/drivers/drv_sdio.c b/bsp/qemu-vexpress-a9/drivers/drv_sdio.c index c031011e51..17c6b11f57 100644 --- a/bsp/qemu-vexpress-a9/drivers/drv_sdio.c +++ b/bsp/qemu-vexpress-a9/drivers/drv_sdio.c @@ -77,8 +77,8 @@ #define PL180_CLR_DAT_END (1 << 8) #define PL180_CLR_DAT_BLK_END (1 << 10) -#define DBG_SECTION_NAME "drv.sdio" -#define DBG_LEVEL DBG_INFO +#define DBG_TAG "drv.sdio" +#define DBG_LVL DBG_INFO #include "rtdbg.h" struct sdhci_pl180_pdata_t diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_log.h b/bsp/stm32/libraries/HAL_Drivers/drv_log.h index 69328b368a..7e0bfee5b4 100644 --- a/bsp/stm32/libraries/HAL_Drivers/drv_log.h +++ b/bsp/stm32/libraries/HAL_Drivers/drv_log.h @@ -13,15 +13,15 @@ */ #ifndef LOG_TAG -#define DBG_SECTION_NAME "drv" +#define DBG_TAG "drv" #else -#define DBG_SECTION_NAME LOG_TAG +#define DBG_TAG LOG_TAG #endif /* LOG_TAG */ #ifdef DRV_DEBUG -#define DBG_LEVEL DBG_LOG +#define DBG_LVL DBG_LOG #else -#define DBG_LEVEL DBG_INFO +#define DBG_LVL DBG_INFO #endif /* DRV_DEBUG */ #include diff --git a/bsp/stm32/stm32f103-fire-arbitrary/board/ports/sdcard_port.c b/bsp/stm32/stm32f103-fire-arbitrary/board/ports/sdcard_port.c index 45c8a6d74d..bf5f3e10a7 100644 --- a/bsp/stm32/stm32f103-fire-arbitrary/board/ports/sdcard_port.c +++ b/bsp/stm32/stm32f103-fire-arbitrary/board/ports/sdcard_port.c @@ -16,8 +16,8 @@ #include #include -#define DBG_SECTION_NAME "app.card" -#define DBG_LEVEL DBG_INFO +#define DBG_TAG "app.card" +#define DBG_LVL DBG_INFO #include void sd_mount(void *parameter) diff --git a/bsp/stm32/stm32f407-atk-explorer/board/ports/sdcard_port.c b/bsp/stm32/stm32f407-atk-explorer/board/ports/sdcard_port.c index 625cec463d..0a9c36fd42 100644 --- a/bsp/stm32/stm32f407-atk-explorer/board/ports/sdcard_port.c +++ b/bsp/stm32/stm32f407-atk-explorer/board/ports/sdcard_port.c @@ -16,8 +16,8 @@ #include #include -#define DBG_SECTION_NAME "app.card" -#define DBG_LEVEL DBG_INFO +#define DBG_TAG "app.card" +#define DBG_LVL DBG_INFO #include void sd_mount(void *parameter) diff --git a/bsp/stm32/stm32f429-armfly-v6/board/ports/sdcard_port.c b/bsp/stm32/stm32f429-armfly-v6/board/ports/sdcard_port.c index 0eb7035ddf..b46537d311 100644 --- a/bsp/stm32/stm32f429-armfly-v6/board/ports/sdcard_port.c +++ b/bsp/stm32/stm32f429-armfly-v6/board/ports/sdcard_port.c @@ -16,8 +16,8 @@ #include #include -#define DBG_SECTION_NAME "app.card" -#define DBG_LEVEL DBG_INFO +#define DBG_TAG "app.card" +#define DBG_LVL DBG_INFO #include void sd_mount(void *parameter) diff --git a/bsp/stm32/stm32f429-atk-apollo/board/ports/sdcard_port.c b/bsp/stm32/stm32f429-atk-apollo/board/ports/sdcard_port.c index 625cec463d..0a9c36fd42 100644 --- a/bsp/stm32/stm32f429-atk-apollo/board/ports/sdcard_port.c +++ b/bsp/stm32/stm32f429-atk-apollo/board/ports/sdcard_port.c @@ -16,8 +16,8 @@ #include #include -#define DBG_SECTION_NAME "app.card" -#define DBG_LEVEL DBG_INFO +#define DBG_TAG "app.card" +#define DBG_LVL DBG_INFO #include void sd_mount(void *parameter) diff --git a/bsp/stm32/stm32f429-fire-challenger/board/ports/sdcard_port.c b/bsp/stm32/stm32f429-fire-challenger/board/ports/sdcard_port.c index c7200001e3..d7b740ae47 100644 --- a/bsp/stm32/stm32f429-fire-challenger/board/ports/sdcard_port.c +++ b/bsp/stm32/stm32f429-fire-challenger/board/ports/sdcard_port.c @@ -17,8 +17,8 @@ #include #include "drv_gpio.h" -#define DBG_SECTION_NAME "app.card" -#define DBG_LEVEL DBG_INFO +#define DBG_TAG "app.card" +#define DBG_LVL DBG_INFO #include #define WIFI_RESET_PIN GET_PIN(G, 9) diff --git a/bsp/stm32/stm32f746-st-disco/board/ports/sdcard_port.c b/bsp/stm32/stm32f746-st-disco/board/ports/sdcard_port.c index 143576eb12..0797f9326c 100644 --- a/bsp/stm32/stm32f746-st-disco/board/ports/sdcard_port.c +++ b/bsp/stm32/stm32f746-st-disco/board/ports/sdcard_port.c @@ -16,8 +16,8 @@ #include #include -#define DBG_SECTION_NAME "app.card" -#define DBG_LEVEL DBG_INFO +#define DBG_TAG "app.card" +#define DBG_LVL DBG_INFO #include void sd_mount(void *parameter) diff --git a/bsp/stm32/stm32f767-atk-apollo/board/ports/sdcard_port.c b/bsp/stm32/stm32f767-atk-apollo/board/ports/sdcard_port.c index 625cec463d..0a9c36fd42 100644 --- a/bsp/stm32/stm32f767-atk-apollo/board/ports/sdcard_port.c +++ b/bsp/stm32/stm32f767-atk-apollo/board/ports/sdcard_port.c @@ -16,8 +16,8 @@ #include #include -#define DBG_SECTION_NAME "app.card" -#define DBG_LEVEL DBG_INFO +#define DBG_TAG "app.card" +#define DBG_LVL DBG_INFO #include void sd_mount(void *parameter) diff --git a/bsp/stm32/stm32f767-fire-challenger/board/ports/sdcard_port.c b/bsp/stm32/stm32f767-fire-challenger/board/ports/sdcard_port.c index b8db33d0d2..615ad6e06e 100644 --- a/bsp/stm32/stm32f767-fire-challenger/board/ports/sdcard_port.c +++ b/bsp/stm32/stm32f767-fire-challenger/board/ports/sdcard_port.c @@ -17,9 +17,8 @@ #include #include "drv_gpio.h" - -#define DBG_SECTION_NAME "app.card" -#define DBG_LEVEL DBG_INFO +#define DBG_TAG "app.card" +#define DBG_LVL DBG_INFO #include #define WIFI_RESET_PIN GET_PIN(G, 9) diff --git a/bsp/stm32/stm32l475-atk-pandora/board/ports/sdcard_port.c b/bsp/stm32/stm32l475-atk-pandora/board/ports/sdcard_port.c index 11c66f34b7..e1af109455 100644 --- a/bsp/stm32/stm32l475-atk-pandora/board/ports/sdcard_port.c +++ b/bsp/stm32/stm32l475-atk-pandora/board/ports/sdcard_port.c @@ -18,9 +18,8 @@ #include "drv_spi.h" #include "spi_msd.h" - -#define DBG_SECTION_NAME "app.card" -#define DBG_LEVEL DBG_INFO +#define DBG_TAG "app.card" +#define DBG_LVL DBG_INFO #include void sd_mount(void *parameter) diff --git a/bsp/stm32/stm32l496-ali-developer/board/ports/sdcard_port.c b/bsp/stm32/stm32l496-ali-developer/board/ports/sdcard_port.c index 54b5af7ed6..8a2c1cade7 100644 --- a/bsp/stm32/stm32l496-ali-developer/board/ports/sdcard_port.c +++ b/bsp/stm32/stm32l496-ali-developer/board/ports/sdcard_port.c @@ -16,9 +16,8 @@ #include #include - -#define DBG_SECTION_NAME "app.card" -#define DBG_LEVEL DBG_INFO +#define DBG_TAG "app.card" +#define DBG_LVL DBG_INFO #include void sd_mount(void *parameter) diff --git a/bsp/stm32f429-apollo/drivers/audio/drv_mic.c b/bsp/stm32f429-apollo/drivers/audio/drv_mic.c index 3dab97c60a..745fb53869 100644 --- a/bsp/stm32f429-apollo/drivers/audio/drv_mic.c +++ b/bsp/stm32f429-apollo/drivers/audio/drv_mic.c @@ -18,8 +18,8 @@ #include "drv_wm8978.h" #include -#define DBG_LEVEL DBG_INFO -#define DBG_SECTION_NAME "MIC" +#define DBG_TAG "MIC" +#define DBG_LVL DBG_INFO #include struct micphone_device diff --git a/bsp/stm32f429-apollo/drivers/audio/drv_sound.c b/bsp/stm32f429-apollo/drivers/audio/drv_sound.c index 5bebc01470..b35be5af61 100644 --- a/bsp/stm32f429-apollo/drivers/audio/drv_sound.c +++ b/bsp/stm32f429-apollo/drivers/audio/drv_sound.c @@ -19,8 +19,8 @@ #include "drv_wm8978.h" #include -#define DBG_LEVEL DBG_LOG -#define DBG_SECTION_NAME "Sound" +#define DBG_TAG "Sound" +#define DBG_LVL DBG_LOG #include /** diff --git a/bsp/w60x/drivers/drv_wifi.c b/bsp/w60x/drivers/drv_wifi.c index b7bc9eb459..2ae441b420 100644 --- a/bsp/w60x/drivers/drv_wifi.c +++ b/bsp/w60x/drivers/drv_wifi.c @@ -14,10 +14,8 @@ #include "wm_wifi.h" #include "drv_wifi.h" -#define DBG_ENABLE -#define DBG_LEVEL DBG_INFO -#define DBG_SECTION_NAME "WIFI" -#define DBG_COLOR +#define DBG_TAG "WIFI" +#define DBG_LVL DBG_INFO #include #include "wm_ram_config.h" diff --git a/bsp/x1000/drivers/mmc/drv_mmc.c b/bsp/x1000/drivers/mmc/drv_mmc.c index d2b0016f4b..8e6e86c942 100644 --- a/bsp/x1000/drivers/mmc/drv_mmc.c +++ b/bsp/x1000/drivers/mmc/drv_mmc.c @@ -33,8 +33,8 @@ #define DMA_ALIGN (32U) #define PIO_THRESHOLD 64 /* use pio mode if data length < PIO_THRESHOLD */ -#define DBG_SECTION_NAME "SDIO" -#define DBG_LEVEL DBG_INFO +#define DBG_TAG "SDIO" +#define DBG_LVL DBG_INFO #include /* diff --git a/components/dfs/include/dfs_private.h b/components/dfs/include/dfs_private.h index 77dbe8562d..fccd260ac0 100644 --- a/components/dfs/include/dfs_private.h +++ b/components/dfs/include/dfs_private.h @@ -12,8 +12,8 @@ #include -#define DBG_SECTION_NAME "DFS" -#define DBG_LEVEL DBG_INFO +#define DBG_TAG "DFS" +#define DBG_LVL DBG_INFO #include #define NO_WORKING_DIR "system does not support working directory\n" diff --git a/components/drivers/misc/adc.c b/components/drivers/misc/adc.c index fec4f736e0..2d26beb243 100644 --- a/components/drivers/misc/adc.c +++ b/components/drivers/misc/adc.c @@ -15,8 +15,8 @@ #include #include -#define DBG_SECTION_NAME "adc" -#define DBG_LEVEL DBG_INFO +#define DBG_TAG "adc" +#define DBG_LVL DBG_INFO #include static rt_size_t _adc_read(rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size) diff --git a/components/drivers/sdio/block_dev.c b/components/drivers/sdio/block_dev.c index dcfbc0ca7b..cac4fc5036 100644 --- a/components/drivers/sdio/block_dev.c +++ b/components/drivers/sdio/block_dev.c @@ -13,11 +13,11 @@ #include -#define DBG_SECTION_NAME "SDIO" +#define DBG_TAG "SDIO" #ifdef RT_SDIO_DEBUG -#define DBG_LEVEL DBG_LOG +#define DBG_LVL DBG_LOG #else -#define DBG_LEVEL DBG_INFO +#define DBG_LVL DBG_INFO #endif /* RT_SDIO_DEBUG */ #include diff --git a/components/drivers/sdio/mmc.c b/components/drivers/sdio/mmc.c index 5f9259ef52..5c7ddcb258 100644 --- a/components/drivers/sdio/mmc.c +++ b/components/drivers/sdio/mmc.c @@ -11,11 +11,11 @@ #include #include -#define DBG_SECTION_NAME "SDIO" +#define DBG_TAG "SDIO" #ifdef RT_SDIO_DEBUG -#define DBG_LEVEL DBG_LOG +#define DBG_LVL DBG_LOG #else -#define DBG_LEVEL DBG_INFO +#define DBG_LVL DBG_INFO #endif /* RT_SDIO_DEBUG */ #include diff --git a/components/drivers/sdio/mmcsd_core.c b/components/drivers/sdio/mmcsd_core.c index 160defa645..8131a33133 100644 --- a/components/drivers/sdio/mmcsd_core.c +++ b/components/drivers/sdio/mmcsd_core.c @@ -14,11 +14,11 @@ #include #include -#define DBG_SECTION_NAME "SDIO" +#define DBG_TAG "SDIO" #ifdef RT_SDIO_DEBUG -#define DBG_LEVEL DBG_LOG +#define DBG_LVL DBG_LOG #else -#define DBG_LEVEL DBG_INFO +#define DBG_LVL DBG_INFO #endif /* RT_SDIO_DEBUG */ #include diff --git a/components/drivers/sdio/sd.c b/components/drivers/sdio/sd.c index f4e925507c..3e7ad1cd16 100644 --- a/components/drivers/sdio/sd.c +++ b/components/drivers/sdio/sd.c @@ -11,11 +11,11 @@ #include #include -#define DBG_SECTION_NAME "SDIO" +#define DBG_TAG "SDIO" #ifdef RT_SDIO_DEBUG -#define DBG_LEVEL DBG_LOG +#define DBG_LVL DBG_LOG #else -#define DBG_LEVEL DBG_INFO +#define DBG_LVL DBG_INFO #endif /* RT_SDIO_DEBUG */ #include diff --git a/components/drivers/sdio/sdio.c b/components/drivers/sdio/sdio.c index b0516704fd..f31f5b81a8 100644 --- a/components/drivers/sdio/sdio.c +++ b/components/drivers/sdio/sdio.c @@ -12,11 +12,11 @@ #include #include -#define DBG_SECTION_NAME "SDIO" +#define DBG_TAG "SDIO" #ifdef RT_SDIO_DEBUG -#define DBG_LEVEL DBG_LOG +#define DBG_LVL DBG_LOG #else -#define DBG_LEVEL DBG_INFO +#define DBG_LVL DBG_INFO #endif /* RT_SDIO_DEBUG */ #include diff --git a/components/drivers/sensors/sensor.c b/components/drivers/sensors/sensor.c index ec1ad98fb6..c86f96c14d 100644 --- a/components/drivers/sensors/sensor.c +++ b/components/drivers/sensors/sensor.c @@ -10,8 +10,8 @@ #include "sensor.h" -#define DBG_LEVEL DBG_INFO -#define DBG_SECTION_NAME "sensor" +#define DBG_TAG "sensor" +#define DBG_LVL DBG_INFO #include #include diff --git a/components/drivers/sensors/sensor_cmd.c b/components/drivers/sensors/sensor_cmd.c index 4658a42722..3369ee376a 100644 --- a/components/drivers/sensors/sensor_cmd.c +++ b/components/drivers/sensors/sensor_cmd.c @@ -10,8 +10,8 @@ #include "sensor.h" -#define DBG_LEVEL DBG_INFO -#define DBG_SECTION_NAME "sensor.cmd" +#define DBG_TAG "sensor.cmd" +#define DBG_LVL DBG_INFO #include #include diff --git a/components/drivers/serial/serial.c b/components/drivers/serial/serial.c index 13bf54e721..d4cf35414c 100644 --- a/components/drivers/serial/serial.c +++ b/components/drivers/serial/serial.c @@ -28,8 +28,8 @@ #include #include -#define DBG_LEVEL DBG_INFO -#define DBG_SECTION_NAME "UART" +#define DBG_TAG "UART" +#define DBG_LVL DBG_INFO #include #ifdef RT_USING_POSIX diff --git a/components/drivers/wlan/wlan_cfg.c b/components/drivers/wlan/wlan_cfg.c index 00e9dbc83e..43fed8e6e8 100644 --- a/components/drivers/wlan/wlan_cfg.c +++ b/components/drivers/wlan/wlan_cfg.c @@ -11,12 +11,12 @@ #include #include +#define DBG_TAG "WLAN.cfg" #ifdef RT_WLAN_CFG_DEBUG -#define DBG_LEVEL DBG_LOG +#define DBG_LVL DBG_LOG #else -#define DBG_LEVEL DBG_INFO -#endif -#define DBG_SECTION_NAME "WLAN.cfg" +#define DBG_LVL DBG_INFO +#endif /* RT_WLAN_CFG_DEBUG */ #include #define WLAN_CFG_LOCK() (rt_mutex_take(&cfg_mutex, RT_WAITING_FOREVER)) diff --git a/components/drivers/wlan/wlan_dev.c b/components/drivers/wlan/wlan_dev.c index 3f4adf35ad..82fa4e73e7 100644 --- a/components/drivers/wlan/wlan_dev.c +++ b/components/drivers/wlan/wlan_dev.c @@ -13,12 +13,12 @@ #include #include +#define DBG_TAG "WLAN.dev" #ifdef RT_WLAN_DEV_DEBUG -#define DBG_LEVEL DBG_LOG +#define DBG_LVL DBG_LOG #else -#define DBG_LEVEL DBG_INFO -#endif -#define DBG_SECTION_NAME "WLAN.dev" +#define DBG_LVL DBG_INFO +#endif /* RT_WLAN_DEV_DEBUG */ #include #ifndef RT_DEVICE diff --git a/components/drivers/wlan/wlan_lwip.c b/components/drivers/wlan/wlan_lwip.c index 052c2afd2e..84b448c68f 100644 --- a/components/drivers/wlan/wlan_lwip.c +++ b/components/drivers/wlan/wlan_lwip.c @@ -21,12 +21,12 @@ #include #endif +#define DBG_TAG "WLAN.lwip" #ifdef RT_WLAN_LWIP_DEBUG -#define DBG_LEVEL DBG_LOG +#define DBG_LVL DBG_LOG #else -#define DBG_LEVEL DBG_INFO -#endif -#define DBG_SECTION_NAME "WLAN.lwip" +#define DBG_LVL DBG_INFO +#endif /* RT_WLAN_LWIP_DEBUG */ #include #ifndef IPADDR_STRLEN_MAX diff --git a/components/drivers/wlan/wlan_mgnt.c b/components/drivers/wlan/wlan_mgnt.c index ced5bfa1c2..91a77e43d0 100644 --- a/components/drivers/wlan/wlan_mgnt.c +++ b/components/drivers/wlan/wlan_mgnt.c @@ -16,13 +16,12 @@ #include #include - +#define DBG_TAG "WLAN.mgnt" #ifdef RT_WLAN_MGNT_DEBUG -#define DBG_LEVEL DBG_LOG +#define DBG_LVL DBG_LOG #else -#define DBG_LEVEL DBG_INFO -#endif -#define DBG_SECTION_NAME "WLAN.mgnt" +#define DBG_LVL DBG_INFO +#endif /* RT_WLAN_MGNT_DEBUG */ #include #ifndef RT_WLAN_DEVICE diff --git a/components/drivers/wlan/wlan_prot.c b/components/drivers/wlan/wlan_prot.c index 48adbc48f3..0402962e01 100644 --- a/components/drivers/wlan/wlan_prot.c +++ b/components/drivers/wlan/wlan_prot.c @@ -13,12 +13,12 @@ #include #include +#define DBG_TAG "WLAN.prot" #ifdef RT_WLAN_PROT_DEBUG -#define DBG_LEVEL DBG_LOG +#define DBG_LVL DBG_LOG #else -#define DBG_LEVEL DBG_INFO -#endif -#define DBG_SECTION_NAME "WLAN.prot" +#define DBG_LVL DBG_INFO +#endif /* RT_WLAN_PROT_DEBUG */ #include #if RT_WLAN_PROT_NAME_LEN < 4 diff --git a/components/drivers/wlan/wlan_workqueue.c b/components/drivers/wlan/wlan_workqueue.c index 23823afae0..ec21243d60 100644 --- a/components/drivers/wlan/wlan_workqueue.c +++ b/components/drivers/wlan/wlan_workqueue.c @@ -13,8 +13,8 @@ #include #include -#define DBG_LEVEL DBG_INFO -#define DBG_SECTION_NAME "WLAN.work" +#define DBG_TAG "WLAN.work" +#define DBG_LVL DBG_INFO #include struct rt_wlan_work diff --git a/components/libc/libdl/dlelf.c b/components/libc/libdl/dlelf.c index 4557ee3458..1265ffcb07 100644 --- a/components/libc/libdl/dlelf.c +++ b/components/libc/libdl/dlelf.c @@ -11,8 +11,8 @@ #include "dlmodule.h" #include "dlelf.h" -#define DBG_SECTION_NAME "DLMD" -#define DBG_LEVEL DBG_INFO +#define DBG_TAG "DLMD" +#define DBG_LVL DBG_INFO #include // must after of DEBUG_ENABLE or some other options rt_err_t dlmodule_load_shared_object(struct rt_dlmodule* module, void *module_ptr) diff --git a/components/libc/libdl/dlmodule.c b/components/libc/libdl/dlmodule.c index 14cbfe4cfb..dbebfc8961 100644 --- a/components/libc/libdl/dlmodule.c +++ b/components/libc/libdl/dlmodule.c @@ -16,8 +16,8 @@ #include -#define DBG_SECTION_NAME "DLMD" -#define DBG_LEVEL DBG_INFO +#define DBG_TAG "DLMD" +#define DBG_LVL DBG_INFO #include // must after of DEBUG_ENABLE or some other options static struct rt_module_symtab *_rt_module_symtab_begin = RT_NULL; diff --git a/components/lwp/lwp.c b/components/lwp/lwp.c index e1ba26f21c..7881fcc68f 100644 --- a/components/lwp/lwp.c +++ b/components/lwp/lwp.c @@ -19,8 +19,8 @@ #include "lwp.h" -#define DBG_SECTION_NAME "LWP" -#define DBG_LEVEL DBG_WARNING +#define DBG_TAG "LWP" +#define DBG_LVL DBG_WARNING #include extern void lwp_user_entry(void *args, const void *text, void *data); diff --git a/components/lwp/lwp_mem.c b/components/lwp/lwp_mem.c index e733166934..63fd5c89e1 100644 --- a/components/lwp/lwp_mem.c +++ b/components/lwp/lwp_mem.c @@ -11,8 +11,8 @@ #include #include -#define DBG_SECTION_NAME "LWPMEM" -#define DBG_LEVEL DBG_WARNING +#define DBG_TAG "LWPMEM" +#define DBG_LVL DBG_WARNING #include // todo: remove repleat code diff --git a/components/lwp/lwp_syscall.c b/components/lwp/lwp_syscall.c index 723786f1cd..be95c5fb89 100644 --- a/components/lwp/lwp_syscall.c +++ b/components/lwp/lwp_syscall.c @@ -24,8 +24,8 @@ #define SYSCALL_NET(f) ((void*)sys_notimpl) #endif -#define DBG_SECTION_NAME "LWP_CALL" -#define DBG_LEVEL DBG_WARNING +#define DBG_TAG "LWP_CALL" +#define DBG_LVL DBG_WARNING #include static void __exit_files(rt_thread_t tid) diff --git a/components/net/at/include/at_log.h b/components/net/at/include/at_log.h index fe8766ba95..9e133561f7 100644 --- a/components/net/at/include/at_log.h +++ b/components/net/at/include/at_log.h @@ -13,15 +13,15 @@ */ #ifndef LOG_TAG -#define DBG_SECTION_NAME "at" +#define DBG_TAG "at" #else -#define DBG_SECTION_NAME LOG_TAG +#define DBG_TAG LOG_TAG #endif /* LOG_TAG */ #ifdef AT_DEBUG -#define DBG_LEVEL DBG_LOG +#define DBG_LVL DBG_LOG #else -#define DBG_LEVEL DBG_INFO +#define DBG_LVL DBG_INFO #endif /* AT_DEBUG */ #include diff --git a/components/net/sal_socket/src/sal_socket.c b/components/net/sal_socket/src/sal_socket.c index 771a56f061..8d699b63e7 100644 --- a/components/net/sal_socket/src/sal_socket.c +++ b/components/net/sal_socket/src/sal_socket.c @@ -19,8 +19,8 @@ #endif #include -#define DBG_SECTION_NAME "SAL_SKT" -#define DBG_LEVEL DBG_INFO +#define DBG_TAG "SAL_SKT" +#define DBG_LVL DBG_INFO #include #define SOCKET_TABLE_STEP_LEN 4 diff --git a/components/utilities/ulog/ulog_def.h b/components/utilities/ulog/ulog_def.h index 40b39de972..de5e82fcc5 100644 --- a/components/utilities/ulog/ulog_def.h +++ b/components/utilities/ulog/ulog_def.h @@ -54,7 +54,9 @@ extern "C" { #if !defined(LOG_TAG) /* compatible for rtdbg */ - #if defined(DBG_SECTION_NAME) + #if defined(DBG_TAG) + #define LOG_TAG DBG_TAG + #elif defined(DBG_SECTION_NAME) #define LOG_TAG DBG_SECTION_NAME #else #define LOG_TAG "NO_TAG" @@ -63,7 +65,9 @@ extern "C" { #if !defined(LOG_LVL) /* compatible for rtdbg */ - #if defined(DBG_LEVEL) + #if defined(DBG_LVL) + #define LOG_LVL DBG_LVL + #elif defined(DBG_LEVEL) #define LOG_LVL DBG_LEVEL #else #define LOG_LVL LOG_LVL_DBG diff --git a/components/utilities/utest/utest.c b/components/utilities/utest/utest.c index 99775ab09f..f59f97bb64 100644 --- a/components/utilities/utest/utest.c +++ b/components/utilities/utest/utest.c @@ -15,14 +15,14 @@ #include "utest.h" #include -#undef DBG_SECTION_NAME -#undef DBG_LEVEL +#undef DBG_TAG +#undef DBG_LVL -#define DBG_SECTION_NAME "utest" +#define DBG_TAG "utest" #ifdef UTEST_DEBUG -#define DBG_LEVEL DBG_LOG +#define DBG_LVL DBG_LOG #else -#define DBG_LEVEL DBG_INFO +#define DBG_LVL DBG_INFO #endif #include diff --git a/components/utilities/utest/utest_log.h b/components/utilities/utest/utest_log.h index c4bd25a80b..0403268351 100644 --- a/components/utilities/utest/utest_log.h +++ b/components/utilities/utest/utest_log.h @@ -15,14 +15,14 @@ #define UTEST_DEBUG -#undef DBG_SECTION_NAME -#undef DBG_LEVEL +#undef DBG_TAG +#undef DBG_LVL -#define DBG_SECTION_NAME "testcase" +#define DBG_TAG "testcase" #ifdef UTEST_DEBUG -#define DBG_LEVEL DBG_LOG +#define DBG_LVL DBG_LOG #else -#define DBG_LEVEL DBG_INFO +#define DBG_LVL DBG_INFO #endif #include diff --git a/examples/network/tcpclient.c b/examples/network/tcpclient.c index be50711e94..2059d9f17f 100644 --- a/examples/network/tcpclient.c +++ b/examples/network/tcpclient.c @@ -12,11 +12,11 @@ #define DEBUG_TCP_CLIENT -#define DBG_SECTION_NAME "TCP" +#define DBG_TAG "TCP" #ifdef DEBUG_TCP_CLIENT -#define DBG_LEVEL DBG_LOG +#define DBG_LVL DBG_LOG #else -#define DBG_LEVEL DBG_INFO /* DBG_ERROR */ +#define DBG_LVL DBG_INFO /* DBG_ERROR */ #endif #include diff --git a/examples/network/tcpserver.c b/examples/network/tcpserver.c index 0837495366..c019ec132f 100644 --- a/examples/network/tcpserver.c +++ b/examples/network/tcpserver.c @@ -12,11 +12,11 @@ #define DEBUG_TCP_SERVER -#define DBG_SECTION_NAME "TCP" +#define DBG_TAG "TCP" #ifdef DEBUG_TCP_SERVER -#define DBG_LEVEL DBG_LOG +#define DBG_LVL DBG_LOG #else -#define DBG_LEVEL DBG_INFO /* DBG_ERROR */ +#define DBG_LVL DBG_INFO /* DBG_ERROR */ #endif #include diff --git a/examples/network/udpclient.c b/examples/network/udpclient.c index d43b46a446..cd870cd758 100644 --- a/examples/network/udpclient.c +++ b/examples/network/udpclient.c @@ -5,11 +5,11 @@ #define DEBUG_UDP_CLIENT -#define DBG_SECTION_NAME "UDP" +#define DBG_TAG "UDP" #ifdef DEBUG_UDP_CLIENT -#define DBG_LEVEL DBG_LOG +#define DBG_LVL DBG_LOG #else -#define DBG_LEVEL DBG_INFO /* DBG_ERROR */ +#define DBG_LVL DBG_INFO /* DBG_ERROR */ #endif #include diff --git a/examples/network/udpserver.c b/examples/network/udpserver.c index 40dd754673..ed63363189 100644 --- a/examples/network/udpserver.c +++ b/examples/network/udpserver.c @@ -12,11 +12,11 @@ #define DEBUG_UDP_SERVER -#define DBG_SECTION_NAME "UDP" +#define DBG_TAG "UDP" #ifdef DEBUG_UDP_SERVER -#define DBG_LEVEL DBG_LOG +#define DBG_LVL DBG_LOG #else -#define DBG_LEVEL DBG_INFO /* DBG_ERROR */ +#define DBG_LVL DBG_INFO /* DBG_ERROR */ #endif #include diff --git a/src/signal.c b/src/signal.c index 2d68562535..06c2055d26 100644 --- a/src/signal.c +++ b/src/signal.c @@ -22,8 +22,8 @@ #define RT_SIG_INFO_MAX 32 #endif -#define DBG_SECTION_NAME "SIGN" -#define DBG_LEVEL DBG_INFO +#define DBG_TAG "SIGN" +#define DBG_LVL DBG_INFO #include #define sig_mask(sig_no) (1u << sig_no) -- cgit v1.3.1 From 6e89f70e92bfaef1a7a3740761d6dd03226ab4b1 Mon Sep 17 00:00:00 2001 From: Bernard Xiong Date: Sun, 28 Apr 2019 09:35:54 +0800 Subject: [examples] remove nanopb example codes --- examples/nanopb/SConscript | 13 -------- examples/nanopb/simple.c | 73 ------------------------------------------ examples/nanopb/simple.options | 1 - examples/nanopb/simple.pb.c | 18 ----------- examples/nanopb/simple.pb.h | 45 -------------------------- examples/nanopb/simple.proto | 10 ------ 6 files changed, 160 deletions(-) delete mode 100644 examples/nanopb/SConscript delete mode 100644 examples/nanopb/simple.c delete mode 100644 examples/nanopb/simple.options delete mode 100644 examples/nanopb/simple.pb.c delete mode 100644 examples/nanopb/simple.pb.h delete mode 100644 examples/nanopb/simple.proto (limited to 'examples') diff --git a/examples/nanopb/SConscript b/examples/nanopb/SConscript deleted file mode 100644 index 7c8bce9f26..0000000000 --- a/examples/nanopb/SConscript +++ /dev/null @@ -1,13 +0,0 @@ -Import('RTT_ROOT') -Import('rtconfig') -from building import * - -src = Split(''' -simple.c -simple.pb.c -''') -CPPPATH = [RTT_ROOT + '/examples/nanopb'] - -group = DefineGroup('Nanopb_test', src, depend = ['RT_USING_NANOPB'], CPPPATH = CPPPATH) - -Return('group') \ No newline at end of file diff --git a/examples/nanopb/simple.c b/examples/nanopb/simple.c deleted file mode 100644 index 2b793c014f..0000000000 --- a/examples/nanopb/simple.c +++ /dev/null @@ -1,73 +0,0 @@ -#include -#include -#include -#include -#include "simple.pb.h" - -int nanopb_test() -{ - /* This is the buffer where we will store our message. */ - uint8_t buffer[128]; - size_t message_length; - bool status; - - /* Encode our message */ - { - /* Allocate space on the stack to store the message data. - * - * Nanopb generates simple struct definitions for all the messages. - * - check out the contents of simple.pb.h! */ - SimpleMessage message = SimpleMessage_init_zero; - - /* Create a stream that will write to our buffer. */ - pb_ostream_t stream = pb_ostream_from_buffer(buffer, sizeof(buffer)); - - /* Fill in the lucky number */ - message.lucky_number = 13; - - /* Now we are ready to encode the message! */ - status = pb_encode(&stream, SimpleMessage_fields, &message); - message_length = stream.bytes_written; - - /* Then just check for any errors.. */ - if (!status) - { - rt_kprintf("Encoding failed: %s\n", PB_GET_ERROR(&stream)); - return 1; - } - } - - /* Now we could transmit the message over network, store it in a file or - * wrap it to a pigeon's leg. - */ - - /* But because we are lazy, we will just decode it immediately. */ - - { - /* Allocate space for the decoded message. */ - SimpleMessage message; - - /* Create a stream that reads from the buffer. */ - pb_istream_t stream = pb_istream_from_buffer(buffer, message_length); - - /* Now we are ready to decode the message. */ - status = pb_decode(&stream, SimpleMessage_fields, &message); - - /* Check for errors... */ - if (!status) - { - rt_kprintf("Decoding failed: %s\n", PB_GET_ERROR(&stream)); - return 1; - } - - /* Print the data contained in the message. */ - rt_kprintf("Your lucky number was %d!\n", message.lucky_number); - } - - return 0; -} - -#ifdef RT_USING_FINSH -#include -FINSH_FUNCTION_EXPORT(nanopb_test, nanopb encode/decode test.) -#endif diff --git a/examples/nanopb/simple.options b/examples/nanopb/simple.options deleted file mode 100644 index 90960d0d34..0000000000 --- a/examples/nanopb/simple.options +++ /dev/null @@ -1 +0,0 @@ -SimpleMessage.name max_size:16 \ No newline at end of file diff --git a/examples/nanopb/simple.pb.c b/examples/nanopb/simple.pb.c deleted file mode 100644 index eaf09e58da..0000000000 --- a/examples/nanopb/simple.pb.c +++ /dev/null @@ -1,18 +0,0 @@ -/* Automatically generated nanopb constant definitions */ -/* Generated by nanopb-0.3.1 at Tue Mar 10 01:16:15 2015. */ - -#include "simple.pb.h" - -#if PB_PROTO_HEADER_VERSION != 30 -#error Regenerate this file with the current version of nanopb generator. -#endif - - - -const pb_field_t SimpleMessage_fields[3] = { - PB_FIELD( 1, INT32 , REQUIRED, STATIC , FIRST, SimpleMessage, lucky_number, lucky_number, 0), - PB_FIELD( 2, BYTES , REQUIRED, STATIC , OTHER, SimpleMessage, name, lucky_number, 0), - PB_LAST_FIELD -}; - - diff --git a/examples/nanopb/simple.pb.h b/examples/nanopb/simple.pb.h deleted file mode 100644 index 47521dee69..0000000000 --- a/examples/nanopb/simple.pb.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Automatically generated nanopb header */ -/* Generated by nanopb-0.3.1 at Tue Mar 10 01:16:15 2015. */ - -#ifndef PB_SIMPLE_PB_H_INCLUDED -#define PB_SIMPLE_PB_H_INCLUDED -#include - -#if PB_PROTO_HEADER_VERSION != 30 -#error Regenerate this file with the current version of nanopb generator. -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* Enum definitions */ -/* Struct definitions */ -typedef PB_BYTES_ARRAY_T(16) SimpleMessage_name_t; - -typedef struct _SimpleMessage { - int32_t lucky_number; - SimpleMessage_name_t name; -} SimpleMessage; - -/* Default values for struct fields */ - -/* Initializer values for message structs */ -#define SimpleMessage_init_default {0, {0, {0}}} -#define SimpleMessage_init_zero {0, {0, {0}}} - -/* Field tags (for use in manual encoding/decoding) */ -#define SimpleMessage_lucky_number_tag 1 -#define SimpleMessage_name_tag 2 - -/* Struct field encoding specification for nanopb */ -extern const pb_field_t SimpleMessage_fields[3]; - -/* Maximum encoded size of messages (where known) */ -#define SimpleMessage_size 29 - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif diff --git a/examples/nanopb/simple.proto b/examples/nanopb/simple.proto deleted file mode 100644 index 1905d0e50b..0000000000 --- a/examples/nanopb/simple.proto +++ /dev/null @@ -1,10 +0,0 @@ -// A very simple protocol definition, consisting of only -// one message. - -message SimpleMessage { - required int32 lucky_number = 1; - required bytes name = 2; -} - - - -- cgit v1.3.1 From 623ddc62b2df57b94674d1a46bfa3ff58593bbcb Mon Sep 17 00:00:00 2001 From: EvalZero Date: Mon, 6 May 2019 19:57:22 +0800 Subject: [components][pm]adapt to the new power management interface --- bsp/es32f0334/drivers/drv_pm.c | 61 +++++++++--------------------------------- bsp/es32f0654/drivers/drv_pm.c | 61 +++++++++--------------------------------- examples/pm/timer_app.c | 2 +- 3 files changed, 25 insertions(+), 99 deletions(-) (limited to 'examples') diff --git a/bsp/es32f0334/drivers/drv_pm.c b/bsp/es32f0334/drivers/drv_pm.c index f9324d7208..1841ce2050 100644 --- a/bsp/es32f0334/drivers/drv_pm.c +++ b/bsp/es32f0334/drivers/drv_pm.c @@ -16,52 +16,26 @@ #ifdef RT_USING_PM -static void _drv_pm_enter(struct rt_pm *pm) +static void _drv_pm_enter(struct rt_pm *pm, uint8_t mode) { - rt_uint32_t mode; - - mode = pm->current_mode; - switch (mode) { - case PM_RUN_MODE_NORMAL: + case PM_SLEEP_MODE_NONE: break; - case PM_SLEEP_MODE_SLEEP: + case PM_SLEEP_MODE_IDLE: __WFI(); break; - case PM_SLEEP_MODE_TIMER: - pmu_stop2_enter(); - break; - - case PM_SLEEP_MODE_SHUTDOWN: - pmu_standby_enter(PMU_STANDBY_PORT_NONE); - break; - - default: - RT_ASSERT(0); - break; - } -} - -static void _drv_pm_exit(struct rt_pm *pm) -{ - rt_uint32_t mode; - - RT_ASSERT(pm != RT_NULL); - - mode = pm->current_mode; - - switch (mode) - { - case PM_RUN_MODE_NORMAL: + case PM_SLEEP_MODE_LIGHT: break; - case PM_SLEEP_MODE_SLEEP: + case PM_SLEEP_MODE_DEEP: + pmu_stop2_enter(); break; - case PM_SLEEP_MODE_TIMER: + case PM_SLEEP_MODE_STANDBY: + pmu_standby_enter(PMU_STANDBY_PORT_NONE); break; case PM_SLEEP_MODE_SHUTDOWN: @@ -73,32 +47,21 @@ static void _drv_pm_exit(struct rt_pm *pm) } } -#if PM_RUN_MODE_COUNT > 1 -static void _drv_pm_frequency_change(struct rt_pm *pm, rt_uint32_t frequency) -{ - return; -} -#endif - static int drv_hw_pm_init(void) { static const struct rt_pm_ops _ops = { _drv_pm_enter, - _drv_pm_exit, - -#if PM_RUN_MODE_COUNT > 1 - _drv_pm_frequency_change, -#endif + RT_NULL, RT_NULL, RT_NULL, RT_NULL }; - rt_uint8_t timer_mask; + rt_uint8_t timer_mask = 0; - /* initialize timer mask */ - timer_mask = 1UL << PM_SLEEP_MODE_TIMER; + /* initialize timer mask(no need tickless) */ + // timer_mask = 1UL << PM_SLEEP_MODE_DEEP; /* initialize system pm module */ rt_system_pm_init(&_ops, timer_mask, RT_NULL); diff --git a/bsp/es32f0654/drivers/drv_pm.c b/bsp/es32f0654/drivers/drv_pm.c index 256634b81d..926ffc05c0 100644 --- a/bsp/es32f0654/drivers/drv_pm.c +++ b/bsp/es32f0654/drivers/drv_pm.c @@ -16,52 +16,26 @@ #ifdef RT_USING_PM -static void _drv_pm_enter(struct rt_pm *pm) +static void _drv_pm_enter(struct rt_pm *pm, uint8_t mode) { - rt_uint32_t mode; - - mode = pm->current_mode; - switch (mode) { - case PM_RUN_MODE_NORMAL: + case PM_SLEEP_MODE_NONE: break; - case PM_SLEEP_MODE_SLEEP: + case PM_SLEEP_MODE_IDLE: __WFI(); break; - case PM_SLEEP_MODE_TIMER: - pmu_stop2_enter(); - break; - - case PM_SLEEP_MODE_SHUTDOWN: - pmu_standby_enter(PMU_STANDBY_PORT_NONE); - break; - - default: - RT_ASSERT(0); - break; - } -} - -static void _drv_pm_exit(struct rt_pm *pm) -{ - rt_uint32_t mode; - - RT_ASSERT(pm != RT_NULL); - - mode = pm->current_mode; - - switch (mode) - { - case PM_RUN_MODE_NORMAL: + case PM_SLEEP_MODE_LIGHT: break; - case PM_SLEEP_MODE_SLEEP: + case PM_SLEEP_MODE_DEEP: + pmu_stop2_enter(); break; - case PM_SLEEP_MODE_TIMER: + case PM_SLEEP_MODE_STANDBY: + pmu_standby_enter(PMU_STANDBY_PORT_NONE); break; case PM_SLEEP_MODE_SHUTDOWN: @@ -73,32 +47,21 @@ static void _drv_pm_exit(struct rt_pm *pm) } } -#if PM_RUN_MODE_COUNT > 1 -static void _drv_pm_frequency_change(struct rt_pm *pm, rt_uint32_t frequency) -{ - return; -} -#endif - static int drv_hw_pm_init(void) { static const struct rt_pm_ops _ops = { _drv_pm_enter, - _drv_pm_exit, - -#if PM_RUN_MODE_COUNT > 1 - _drv_pm_frequency_change, -#endif + RT_NULL, RT_NULL, RT_NULL, RT_NULL }; - rt_uint8_t timer_mask; + rt_uint8_t timer_mask = 0; - /* initialize timer mask */ - timer_mask = 1UL << PM_SLEEP_MODE_TIMER; + /* initialize timer mask(no need tickless) */ + timer_mask = 1UL << PM_SLEEP_MODE_DEEP; /* initialize system pm module */ rt_system_pm_init(&_ops, timer_mask, RT_NULL); diff --git a/examples/pm/timer_app.c b/examples/pm/timer_app.c index 5c20d0f690..66f4c8d4d2 100644 --- a/examples/pm/timer_app.c +++ b/examples/pm/timer_app.c @@ -39,7 +39,7 @@ static int timer_app_init(void) rt_timer_start(timer1); /* keep in timer mode */ - rt_pm_request(PM_SLEEP_MODE_TIMER); + rt_pm_request(PM_SLEEP_MODE_DEEP); return 0; } -- cgit v1.3.1 From d51e0783babc4ffa7286e8dadceb2b2be2129b33 Mon Sep 17 00:00:00 2001 From: EvalZero Date: Tue, 7 May 2019 21:03:48 +0800 Subject: [components][pm]fix some issues with low power components --- bsp/es32f0334/drivers/drv_pm.c | 1 + bsp/es32f0654/drivers/drv_pm.c | 1 + bsp/stm32/libraries/HAL_Drivers/drv_lptim.c | 2 +- bsp/stm32/libraries/HAL_Drivers/drv_lptim.h | 2 +- bsp/stm32/libraries/HAL_Drivers/drv_pm.c | 5 ++-- components/drivers/include/drivers/pm.h | 9 +++---- components/drivers/pm/pm.c | 41 +++++++++++++++-------------- examples/pm/timer_app.c | 1 + 8 files changed, 32 insertions(+), 30 deletions(-) (limited to 'examples') diff --git a/bsp/es32f0334/drivers/drv_pm.c b/bsp/es32f0334/drivers/drv_pm.c index 1841ce2050..22f2c43073 100644 --- a/bsp/es32f0334/drivers/drv_pm.c +++ b/bsp/es32f0334/drivers/drv_pm.c @@ -6,6 +6,7 @@ * Change Logs: * Date Author Notes * 2019-04-08 wangyq the first version + * 2019-05-06 Zero-Free adapt to the new power management interface */ #include diff --git a/bsp/es32f0654/drivers/drv_pm.c b/bsp/es32f0654/drivers/drv_pm.c index 926ffc05c0..aa2f07ec68 100644 --- a/bsp/es32f0654/drivers/drv_pm.c +++ b/bsp/es32f0654/drivers/drv_pm.c @@ -6,6 +6,7 @@ * Change Logs: * Date Author Notes * 2019-04-01 wangyq the first version + * 2019-05-06 Zero-Free adapt to the new power management interface */ #include diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_lptim.c b/bsp/stm32/libraries/HAL_Drivers/drv_lptim.c index 2360cdad78..64e602fa52 100644 --- a/bsp/stm32/libraries/HAL_Drivers/drv_lptim.c +++ b/bsp/stm32/libraries/HAL_Drivers/drv_lptim.c @@ -5,7 +5,7 @@ * * Change Logs: * Date Author Notes - * 2017-08-01 tanek the first version + * 2019-05-06 Zero-Free first version */ #include diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_lptim.h b/bsp/stm32/libraries/HAL_Drivers/drv_lptim.h index 32853c9e73..0fd51b5eac 100644 --- a/bsp/stm32/libraries/HAL_Drivers/drv_lptim.h +++ b/bsp/stm32/libraries/HAL_Drivers/drv_lptim.h @@ -5,7 +5,7 @@ * * Change Logs: * Date Author Notes - * 2012-08-21 heyuanjie87 the first version + * 2019-05-06 Zero-Free first version */ #ifndef __DRV_PMTIMER_H__ diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_pm.c b/bsp/stm32/libraries/HAL_Drivers/drv_pm.c index 66f00b3e02..84ddf6cd41 100644 --- a/bsp/stm32/libraries/HAL_Drivers/drv_pm.c +++ b/bsp/stm32/libraries/HAL_Drivers/drv_pm.c @@ -5,8 +5,7 @@ * * Change Logs: * Date Author Notes - * 2018-07-31 tanek first version - * 2018-05-05 Zero-Free adapt to the new power management interface + * 2019-05-06 Zero-Free first version */ #include @@ -79,7 +78,7 @@ static uint8_t run_speed[PM_RUN_MODE_MAX][2] = {2, 3}, }; -static void run(struct rt_pm *pm, uint8_t mode, uint32_t frequency) +static void run(struct rt_pm *pm, uint8_t mode) { static uint8_t last_mode; static char *run_str[] = PM_RUN_MODE_NAMES; diff --git a/components/drivers/include/drivers/pm.h b/components/drivers/include/drivers/pm.h index 5cffd8d465..e35b21cd48 100644 --- a/components/drivers/include/drivers/pm.h +++ b/components/drivers/include/drivers/pm.h @@ -77,7 +77,7 @@ enum * device control flag to request or release power */ #define RT_PM_DEVICE_CTRL_REQUEST 0x01 -#define RT_PM_DEVICE_CTRL_RELEASE 0x02 +#define RT_PM_DEVICE_CTRL_RELEASE 0x00 struct rt_pm; @@ -87,7 +87,7 @@ struct rt_pm; struct rt_pm_ops { void (*sleep)(struct rt_pm *pm, uint8_t mode); - void (*run)(struct rt_pm *pm, uint8_t mode, uint32_t frequency); + void (*run)(struct rt_pm *pm, uint8_t mode); void (*timer_start)(struct rt_pm *pm, rt_uint32_t timeout); void (*timer_stop)(struct rt_pm *pm); rt_tick_t (*timer_get_tick)(struct rt_pm *pm); @@ -97,7 +97,7 @@ struct rt_device_pm_ops { int (*suspend)(const struct rt_device *device, uint8_t mode); void (*resume)(const struct rt_device *device, uint8_t mode); - int (*frequency_change)(const struct rt_device *device, uint8_t mode, uint32_t frequency); + int (*frequency_change)(const struct rt_device *device, uint8_t mode); }; struct rt_device_pm @@ -122,7 +122,6 @@ struct rt_pm rt_uint8_t device_pm_number; struct rt_device_pm *device_pm; - rt_uint32_t frequency; /* if the mode has timer, the corresponding bit is 1*/ rt_uint8_t timer_mask; rt_uint8_t flags; @@ -144,7 +143,7 @@ struct rt_pm_notify void rt_pm_request(uint8_t sleep_mode); void rt_pm_release(uint8_t sleep_mode); -int rt_pm_run_mode_set(uint8_t run_mode, uint32_t frequency); +int rt_pm_run_enter(uint8_t run_mode); void rt_pm_device_register(struct rt_device *device, const struct rt_device_pm_ops *ops); void rt_pm_device_unregister(struct rt_device *device); diff --git a/components/drivers/pm/pm.c b/components/drivers/pm/pm.c index c273754914..98a993b526 100644 --- a/components/drivers/pm/pm.c +++ b/components/drivers/pm/pm.c @@ -22,12 +22,12 @@ static struct rt_pm_notify _pm_notify; #define RT_PM_TICKLESS_THRESH (2) -RT_WEAK uint32_t rt_pm_enter_critical(void) +RT_WEAK uint32_t rt_pm_enter_critical(uint8_t sleep_mode) { return rt_hw_interrupt_disable(); } -RT_WEAK void rt_pm_exit_critical(uint32_t ctx) +RT_WEAK void rt_pm_exit_critical(uint32_t ctx, uint8_t sleep_mode) { rt_hw_interrupt_enable(ctx); } @@ -37,17 +37,19 @@ RT_WEAK void rt_pm_exit_critical(uint32_t ctx) */ static int _pm_device_suspend(uint8_t mode) { - int index; + int index, ret = RT_EOK; for (index = 0; index < _pm.device_pm_number; index++) { if (_pm.device_pm[index].ops->suspend != RT_NULL) { - return _pm.device_pm[index].ops->suspend(_pm.device_pm[index].device, mode); + ret = _pm.device_pm[index].ops->suspend(_pm.device_pm[index].device, mode); + if(ret != RT_EOK) + break; } } - return RT_EOK; + return ret; } /** @@ -69,7 +71,7 @@ static void _pm_device_resume(uint8_t mode) /** * This function will update the frequency of all registered devices */ -static void _pm_device_frequency_change(uint8_t mode, uint32_t frequency) +static void _pm_device_frequency_change(uint8_t mode) { rt_uint32_t index; @@ -77,7 +79,7 @@ static void _pm_device_frequency_change(uint8_t mode, uint32_t frequency) for (index = 0; index < _pm.device_pm_number; index ++) { if (_pm.device_pm[index].ops->frequency_change != RT_NULL) - _pm.device_pm[index].ops->frequency_change(_pm.device_pm[index].device, mode, frequency); + _pm.device_pm[index].ops->frequency_change(_pm.device_pm[index].device, mode); } } @@ -92,9 +94,9 @@ static void _pm_frequency_scaling(struct rt_pm *pm) { level = rt_hw_interrupt_disable(); /* change system runing mode */ - pm->ops->run(pm, pm->run_mode, pm->frequency); + pm->ops->run(pm, pm->run_mode); /* changer device frequency */ - _pm_device_frequency_change(pm->run_mode, pm->frequency); + _pm_device_frequency_change(pm->run_mode); pm->flags &= ~RT_PM_FREQUENCY_PENDING; rt_hw_interrupt_enable(level); } @@ -138,7 +140,7 @@ static void _pm_change_sleep_mode(struct rt_pm *pm, uint8_t mode) } else { - level = rt_pm_enter_critical(); + level = rt_pm_enter_critical(mode); /* Notify app will enter sleep mode */ if (_pm_notify.notify) @@ -151,7 +153,7 @@ static void _pm_change_sleep_mode(struct rt_pm *pm, uint8_t mode) _pm_device_resume(mode); if (_pm_notify.notify) _pm_notify.notify(RT_PM_EXIT_SLEEP, mode, _pm_notify.data); - rt_pm_exit_critical(level); + rt_pm_exit_critical(level, mode); return; } @@ -202,7 +204,7 @@ static void _pm_change_sleep_mode(struct rt_pm *pm, uint8_t mode) if (_pm_notify.notify) _pm_notify.notify(RT_PM_EXIT_SLEEP, mode, _pm_notify.data); - rt_pm_exit_critical(level); + rt_pm_exit_critical(level, mode); } } @@ -381,11 +383,11 @@ static rt_size_t _rt_pm_device_write(rt_device_t dev, { /* get request */ request = *(unsigned char *)buffer; - if (request == '1') + if (request == 0x01) { rt_pm_request(pos); } - else if (request == '0') + else if (request == 0x00) { rt_pm_release(pos); } @@ -416,7 +418,7 @@ static rt_err_t _rt_pm_device_control(rt_device_t dev, return RT_EOK; } -int rt_pm_run_mode_set(uint8_t mode, uint32_t frequency) +int rt_pm_run_enter(uint8_t mode) { rt_base_t level; struct rt_pm *pm; @@ -429,15 +431,14 @@ int rt_pm_run_mode_set(uint8_t mode, uint32_t frequency) if (mode < pm->run_mode) { /* change system runing mode */ - pm->ops->run(pm, mode, frequency); + pm->ops->run(pm, mode); /* changer device frequency */ - _pm_device_frequency_change(mode, frequency); + _pm_device_frequency_change(mode); } else { pm->flags |= RT_PM_FREQUENCY_PENDING; } - pm->frequency = frequency; pm->run_mode = mode; rt_hw_interrupt_enable(level); @@ -525,9 +526,9 @@ static void rt_pm_run_mode_switch(int argc, char **argv) mode = atoi(argv[1]); } - rt_pm_run_mode_set(mode, 0); + rt_pm_run_enter(mode); } -MSH_CMD_EXPORT_ALIAS(rt_pm_run_mode_switch, pm_run_set, switch power management run mode); +MSH_CMD_EXPORT_ALIAS(rt_pm_run_mode_switch, pm_run, switch power management run mode); static void rt_pm_dump_status(void) { diff --git a/examples/pm/timer_app.c b/examples/pm/timer_app.c index 66f4c8d4d2..b7ff675b39 100644 --- a/examples/pm/timer_app.c +++ b/examples/pm/timer_app.c @@ -6,6 +6,7 @@ * Change Logs: * Date Author Notes * 2018-08-07 Tanek first implementation + * 2019-05-06 Zero-Free adapt to the new power management interface */ #include -- cgit v1.3.1 From b242b1e6f6bb5b40c60989a6096948819ed56748 Mon Sep 17 00:00:00 2001 From: EvalZero Date: Thu, 9 May 2019 20:55:35 +0800 Subject: [examples][pm]add wakeup application for pm. --- examples/pm/wakeup_app.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 examples/pm/wakeup_app.c (limited to 'examples') diff --git a/examples/pm/wakeup_app.c b/examples/pm/wakeup_app.c new file mode 100644 index 0000000000..0d4c42a997 --- /dev/null +++ b/examples/pm/wakeup_app.c @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2019-05-09 Zero-Free first implementation + */ + +#include +#include +#include + +#ifdef RT_USING_PM + +#define WAKEUP_EVENT_BUTTON (1 << 0) +#define PIN_LED_R GET_PIN(E, 7) +#define WAKEUP_PIN GET_PIN(C, 13) +#define WAKEUP_APP_THREAD_STACK_SIZE 1024 + +static rt_event_t wakeup_event; + +static void wakeup_callback(void *args) +{ + rt_event_send(wakeup_event, WAKEUP_EVENT_BUTTON); +} + +static void wakeup_init(void) +{ + rt_pin_mode(WAKEUP_PIN, PIN_MODE_INPUT_PULLUP); + rt_pin_attach_irq(WAKEUP_PIN, PIN_IRQ_MODE_FALLING, wakeup_callback, RT_NULL); + rt_pin_irq_enable(WAKEUP_PIN, 1); +} + +static void wakeup_app_entry(void *parameter) +{ + wakeup_init(); + rt_pm_request(PM_SLEEP_MODE_DEEP); + + while (1) + { + if (rt_event_recv(wakeup_event, + WAKEUP_EVENT_BUTTON, + RT_EVENT_FLAG_AND | RT_EVENT_FLAG_CLEAR, + RT_WAITING_FOREVER, RT_NULL) == RT_EOK) + { + rt_pm_request(PM_SLEEP_MODE_NONE); + + rt_pin_mode(PIN_LED_R, PIN_MODE_OUTPUT); + rt_pin_write(PIN_LED_R, 0); + rt_thread_delay(rt_tick_from_millisecond(500)); + rt_pin_write(PIN_LED_R, 1); + + rt_pm_release(PM_SLEEP_MODE_NONE); + } + } +} + +static int wakeup_app(void) +{ + rt_thread_t tid; + + wakeup_event = rt_event_create("wakup", RT_IPC_FLAG_FIFO); + RT_ASSERT(wakeup_event != RT_NULL); + + tid = rt_thread_create("wakeup_app", wakeup_app_entry, RT_NULL, + WAKEUP_APP_THREAD_STACK_SIZE, RT_MAIN_THREAD_PRIORITY, 20); + RT_ASSERT(tid != RT_NULL); + + rt_thread_startup(tid); + + return 0; +} +INIT_APP_EXPORT(wakeup_app); + +#endif -- cgit v1.3.1