赞
踩
利用Clion对STM32进行编程实现printf重定向及注意事项。
#ifdef __GNUC__
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#else
#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
#endif
PUTCHAR_PROTOTYPE
{
HAL_UART_Transmit(&huart1, (uint8_t *) &ch, 1, 0xFFFF);
return ch;
}
#include <stdio.h>
注意事项,在Clion中printf中必须加上\r\n,否则没有输出,keil中不加有输出
static float i = 3.14;
printf("你好\r\n");
printf("%.1f\r\n", i);
HAL_Delay(500);
利用Clion进行STM32的编程有许多问题是需要注意的。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。