STM32嵌入式开发学习笔记(七):串口通信(下)
2024-08-23 07:34:00
下面我们进行几个串口通信的实际应用。
实验一:发信实验,让开发板通过串口向电脑发送信息:
#include <stdio.h>
#include <stm32f10x.h>
#include <led.h>
#include <button.h>
#include <systick.h>
#include <time.h>
#include <usart.h>
int main()
{
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
led_configer();
button_configer();
usart_configer();
while()
{
USART1_SData(0x66);
}
}
//main.c
实验二:电脑向串口发送0x55时,开灯,电脑向串口发送0x66时,关灯。
#include <stdio.h>
#include <stm32f10x.h>
#include <led.h>
#include <button.h>
#include <systick.h>
#include <time.h>
#include <usart.h>
int main()
{
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
led_configer();
button_configer();
usart_configer();
while()
{
if(RXData==0x55)
lightup(GPIO_Pin_1);
else if(RXData==0x66)
shutdown(GPIO_Pin_1);
}
}
//main.c
最新文章
- ASP.NET 在 Windows Azure 环境中使用基于 SQLServer 的 Session
- asp.net mvc 4 json大数据异常 提示JSON字符长度超出限制的异常
- JDBC基础一
- linux服务器git pull/push时提示输入账号密码之免除设置
- 使用PHP生成二维码的两种方法(带logo图像)
- java反射获取注解并拼接sql语句
- 使用canvas实现绚丽的时钟特效
- 全栈开发之HTML快速入门(一)
- python_继承supper错误
- 关于IOS开发的基本书籍推荐
- BZOJ.5467.[PKUWC2018]Slay the Spire(DP)
- CTSC2018 被屠记
- Lyrics来源
- 【C++】解析C++运行环境的搭建
- FPN-Feature Pyramid Networks for Object Detection
- oracle No more data to read from socket之ora-07445排查解决
- 20155201 网络攻防技术 实验八 Web基础
- iOS基础知识之排序
- es进行curl请求时报错:missing authentication token for REST request
- 关于map和hashmap
热门文章
- AndroidManifest.xml配置文件详解(转)
- CDQ分治&;整体二分学习个人小结
- 用 Flask 来写个轻博客 (13) — M(V)C_WTForms 服务端表单检验
- PHP面试 MySQL创建高性能索引考点
- Device Drivers
- PAT_A1131#Subway Map
- 关于原生js中ie的attacheEvent事件用匿名函数改变this指向后,不能用detachEvent删除绑定事件的解决办法?
- Python运维-获取当前操作系统的各种信息
- 初探Remoting双向通信(二)
- java爬取猫咪上的图片