diff --git a/kernel/common/printk.c b/kernel/common/printk.c index e9f41e3d..63ec2993 100644 --- a/kernel/common/printk.c +++ b/kernel/common/printk.c @@ -890,4 +890,16 @@ void printk_enable_animation() void printk_disable_animation() { sw_show_scroll_animation = false; +} + +int sprintk(char *buf, const char *fmt, ...) +{ + int count = 0; + va_list args; + + va_start(args, fmt); + count = vsprintf(buf, fmt, args); + va_end(args); + + return count; } \ No newline at end of file diff --git a/kernel/common/printk.h b/kernel/common/printk.h index d790e949..6df01d42 100644 --- a/kernel/common/printk.h +++ b/kernel/common/printk.h @@ -157,3 +157,13 @@ void printk_enable_animation(); * */ void printk_disable_animation(); + +/** + * @brief 格式化字符串并输出到buf + * + * @param buf 输出缓冲区 + * @param fmt 格式 + * @param ... 参数 + * @return int 字符串长度 + */ +int sprintk(char *buf, const char *fmt, ...);