21ic问答首页 -
- //加入以下代码,支持printf函数,而不需要选择use MicroLIB
- #if 1
- #pragma import(__use_no_semihosting)
- //标准库需要的支持函数
- struct __FILE
- {
- int handle;
- };
- FILE __stdout;
- //定义_sys_exit()以避免使用半主机模式
- void _sys_exit(int x)
- {
- x = x;
- }
- //重定义fputc函数
- int fputc(int ch, FILE *f)
- {
- while((USART1->SR&0X40)==0);//循环发送,直到发送完毕
- USART1->DR = (u8) ch;
- return ch;
- }
- #endif
赞0
评论
2025-01-11
赞0
评论
2025-01-07
赞0
评论
2025-01-02
赞0
评论
2024-12-20
赞0
评论
2024-12-20
赞0
评论
2024-12-20
赞0
评论
2024-12-20
赞0
评论
2024-12-20
赞0
va_list args;
va_start(args, format);
while (*format) {
if (*format == '%') {
format++;
if (*format == 'd') {
int value = va_arg(args, int);
// 将value转换为字符串并输出
}
} else {
// 输出普通字符
}
format++;
}
va_end(args);
}
评论
2024-12-19
您需要登录后才可以回复 登录 | 注册