printf 函数支持
来源:互联网 发布:unity3d工程师薪资 编辑:程序博客网 时间:2024/06/04 00:24
printf 函数支持
这段引入 printf 函数支持的代码在 usart.h 头文件的最上方,这段代码加入之后便可以
通过 printf 函数向串口发送我们需要的内容,方便开发过程中查看代码执行情况以及一些
变量值。这段代码不需要修改,引入到 usart.h 即可。
这段代码为:
//加入以下代码,支持 printf 函数,而不需要选择 use MicroLIB
#if 1
#pragma import(__use_no_semihosting)
//标准库需要的支持函数
struct __FILE
{
int handle;
};
FILE __stdout;
//定义_sys_exit()以避免使用半主机模式
_sys_exit(int x)
{
x = x;
}
//重定义 fputc 函数
int fputc(int ch, FILE *f)
{
while(USART_GetFlagStatus(USART1,USART_FLAG_TC)==RESET);
USART_SendData(USART1,(uint8_t)ch);
return ch;
}
#endif
这段引入 printf 函数支持的代码在 usart.h 头文件的最上方,这段代码加入之后便可以
通过 printf 函数向串口发送我们需要的内容,方便开发过程中查看代码执行情况以及一些
变量值。这段代码不需要修改,引入到 usart.h 即可。
这段代码为:
//加入以下代码,支持 printf 函数,而不需要选择 use MicroLIB
#if 1
#pragma import(__use_no_semihosting)
//标准库需要的支持函数
struct __FILE
{
int handle;
};
FILE __stdout;
//定义_sys_exit()以避免使用半主机模式
_sys_exit(int x)
{
x = x;
}
//重定义 fputc 函数
int fputc(int ch, FILE *f)
{
while(USART_GetFlagStatus(USART1,USART_FLAG_TC)==RESET);
USART_SendData(USART1,(uint8_t)ch);
return ch;
}
#endif
阅读全文
0 0
- printf 函数支持
- Eclipse支持printf()函数吗?
- 让单片机直接支持printf函数
- win32 下 支持浮点的printf系列函数
- printf函数
- printf()函数
- printf函数
- printf () 函数
- printf()函数
- printf函数
- printf函数
- 函数----printf
- printf函数
- printf()函数
- printf函数
- printf函数
- printf函数
- printf()函数
- poj-1041-John's trip
- Linux 第二课
- Veeam Bakcup Hyper-v
- 腾讯笔试模拟题(int foo[]={1,2,3,4,5,6};cout << (1+3)[foo]-foo[0]+(foo+1)[2])
- 数据库存储大数据量(千万条记录级别)数据的考虑要点
- printf 函数支持
- Linux第三课 Makefile GDB Shell
- centos7.3下安装maven3.5.0
- QT之Hello World
- 一个用户scott中的表导到另一个用户lnsf中的表
- 51nod 1004 n^n问题
- 细说分布式Session管理
- mysql压缩版的安装
- Mac安装android studio后卡在building gradle project info的解决方法