OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 3997|回复: 1

串口发送字符串

[复制链接]

22

主题

44

帖子

0

精华

初级会员

Rank: 2

积分
81
金钱
81
注册时间
2016-3-29
在线时间
31 小时
发表于 2016-5-24 11:05:09 | 显示全部楼层 |阅读模式
1金钱
求各位大神,有没有串口发送字符串的函数,模板给提供一个,比如发送‘SET_WZERO’,谢谢了,简洁明了的

最佳答案

查看完整内容[请看2#楼]

#include #ifdef __GNUC__ /* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf set to 'Yes') calls __io_putchar() */ #define PUTCHAR_PROTOTYPE int __io_putchar(int ch) #else #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f) #endif /* __GNUC__ */ /** * @brief Retargets the C library printf function to the USART. * @param None * @retval N ...
正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

4

主题

290

帖子

0

精华

金牌会员

Rank: 6Rank: 6

积分
1130
金钱
1130
注册时间
2015-8-4
在线时间
107 小时
发表于 2016-5-24 11:05:10 | 显示全部楼层
本帖最后由 kingnike 于 2016-5-24 11:20 编辑

#include <stdio.h>
#ifdef __GNUC__
  /* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf
     set to 'Yes') calls __io_putchar() */
  #define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#else
  #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
#endif /* __GNUC__ */

/**
  * @brief  Retargets the C library printf function to the USART.
  * @param  None
  * @retval None
  */
PUTCHAR_PROTOTYPE
{
  /* Place your implementation of fputc here */
  /* e.g. write a character to the USART */
  USART_SendData(USART1, (u8) ch);

  /* Loop until the end of transmission */
  while (USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET)
  {}
//        USART3_send_char((U8)ch);


  return ch;
}





int main(void)
{
   char buff[20];
   printf("hello world!\r\n");
   sprintf(buff,"%s","stm32 test");
  printf(buff);

}
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-2-27 08:32

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表