1 void Configuration(void)
2 {
3 USART_InitTypeDef USART_InitStructure;
4 GPIO_InitTypeDef GPIO_InitStructure;
5 RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);
6 //TX
7 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
8 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
9 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
10 GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
11 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
12 GPIO_Init(GPIOB, &GPIO_InitStructure);
13 //RX
14 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;
15 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
16 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
17 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
18 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
19 GPIO_Init(GPIOB, &GPIO_InitStructure);
20
21 GPIO_PinAFConfig(GPIOB, GPIO_PinSource10, GPIO_AF_USART3);
22 GPIO_PinAFConfig(GPIOB, GPIO_PinSource11, GPIO_AF_USART3);
23
24
25 USART_OverSampling8Cmd(USART3, ENABLE);
26 USART_InitStructure.USART_BaudRate = 9600;
27 USART_InitStructure.USART_WordLength = USART_WordLength_8b;
28 USART_InitStructure.USART_StopBits = USART_StopBits_1;
29 USART_InitStructure.USART_Parity = USART_Parity_No;
30 USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
31 USART_InitStructure.USART_Mode = USART_Mode_Rx|USART_Mode_Tx;
32 USART_Init(USART3, &USART_InitStructure);
33 USART_Cmd(USART3, ENABLE);
34 }
35 void UART_PutChar(char Data)
36 {
37 USART_SendData(USART3,Data);
38 while(USART_GetFlagStatus(USART3,USART_FLAG_TC) == RESET){}
39 }
40 void UART_PutStr(char *str)
41 {
42 while (0 != *str)
43 {
44 USART3->SR;
45 UART_PutChar(*str);
46 str++;
47 }
48 }
49 int main(void)
50 {
51 Configuration();
52 UART_PutStr("play,0001,$");
53 }

最新文章

  1. Single Number
  2. Only女装首页HTML+CSS代码实现
  3. angularjs——插值字符串
  4. qooxdoo 3.0 发布,JavaScript 的 GUI 框架
  5. Linux/Unix笔记本
  6. Unix 环境高级编程---线程创建、同步、
  7. cv论文(SPARSE REPRESENTATION相关)
  8. easyui源码翻译1.32--Resizable(调整大小)
  9. 利用squid 搭建简单的透明代理服务器
  10. 利用Python爬取网页图片
  11. [物理学与PDEs]第1章第5节 Maxwell 方程组的数学结构, 电磁场的波动性 5.3 电磁场的波动性, 自由电磁波
  12. python3读取MySQL-Front的MYSQL密码
  13. php 将时间格式 转为时间戳
  14. Python实现常用的逻辑数据结构
  15. (转)git合并多个commit
  16. FTP安装
  17. 0070 过滤器调用Spring的bean操作数据库
  18. Promise实现简易AMD加载器
  19. 二十四种设计模式:迭代器模式(Iterator Pattern)
  20. 洛谷P4495 [HAOI2018]奇怪的背包(数论)

热门文章

  1. Centos7 mysql网络源安装范例(其他系统也可参考)
  2. NLP实践!文本语法纠错模型实战,搭建你的贴身语法修改小助手 ⛵
  3. 疫情可视化part3
  4. (java 实现开箱即用基于 redis 的分布式锁
  5. TabControl控件的简单使用-添加tab
  6. 国产paozhu c++ web framework 正式版发布
  7. Java开发学习(四十九)----MyBatisPlus更新语句之乐观锁
  8. drf快速使用 CBV源码分析 drf之APIView分析 drf之Request对象分析
  9. 控制台运行java
  10. Python自动化结算工资和统计报表|编程一对一教学微信:Jiabcdefh