提交 4e3839d7 编写于 作者: B bernard.xiong@gmail.com

add RT_USING_DEVICE definition.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1259 bbd45198-f89e-11dd-88c7-29a3b14d5316
上级 86e7b772
...@@ -339,7 +339,9 @@ rt_int32_t rt_vsprintf(char *dest, const char *format, va_list arg_ptr); ...@@ -339,7 +339,9 @@ rt_int32_t rt_vsprintf(char *dest, const char *format, va_list arg_ptr);
rt_int32_t rt_sprintf(char *buf ,const char *format,...); rt_int32_t rt_sprintf(char *buf ,const char *format,...);
rt_int32_t rt_snprintf(char *buf, rt_size_t size, const char *format, ...); rt_int32_t rt_snprintf(char *buf, rt_size_t size, const char *format, ...);
#ifdef RT_USING_DEVICE
rt_device_t rt_console_set_device(const char* name); rt_device_t rt_console_set_device(const char* name);
#endif
void rt_kprintf(const char *fmt, ...); void rt_kprintf(const char *fmt, ...);
rt_err_t rt_get_errno(void); rt_err_t rt_get_errno(void);
......
...@@ -31,7 +31,9 @@ int errno; ...@@ -31,7 +31,9 @@ int errno;
#else #else
#include <errno.h> #include <errno.h>
#endif #endif
#ifdef RT_USING_DEVICE
static rt_device_t _console_device = RT_NULL; static rt_device_t _console_device = RT_NULL;
#endif
/* /*
* This function will get errno * This function will get errno
...@@ -902,6 +904,7 @@ rt_int32_t rt_sprintf(char *buf ,const char *format,...) ...@@ -902,6 +904,7 @@ rt_int32_t rt_sprintf(char *buf ,const char *format,...)
return n; return n;
} }
#ifdef RT_USING_DEVICE
/** /**
* This function will set a device as console device. * This function will set a device as console device.
* After set a device to console, all output of rt_kprintf will be * After set a device to console, all output of rt_kprintf will be
...@@ -935,6 +938,7 @@ rt_device_t rt_console_set_device(const char* name) ...@@ -935,6 +938,7 @@ rt_device_t rt_console_set_device(const char* name)
return old; return old;
} }
#endif
#if defined(__GNUC__) #if defined(__GNUC__)
void rt_hw_console_output(const char* str) __attribute__((weak)); void rt_hw_console_output(const char* str) __attribute__((weak));
...@@ -965,6 +969,7 @@ void rt_kprintf(const char *fmt, ...) ...@@ -965,6 +969,7 @@ void rt_kprintf(const char *fmt, ...)
va_start(args, fmt); va_start(args, fmt);
length = vsnprintf(rt_log_buf, sizeof(rt_log_buf), fmt, args); length = vsnprintf(rt_log_buf, sizeof(rt_log_buf), fmt, args);
#ifdef RT_USING_DEVICE
if (_console_device == RT_NULL) if (_console_device == RT_NULL)
{ {
rt_hw_console_output(rt_log_buf); rt_hw_console_output(rt_log_buf);
...@@ -973,7 +978,9 @@ void rt_kprintf(const char *fmt, ...) ...@@ -973,7 +978,9 @@ void rt_kprintf(const char *fmt, ...)
{ {
rt_device_write(_console_device, 0, rt_log_buf, length); rt_device_write(_console_device, 0, rt_log_buf, length);
} }
#else
rt_hw_console_output(rt_log_buf);
#endif
va_end(args); va_end(args);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册