当前位置:网站首页>[stm32 Hal library] serial port communication
[stm32 Hal library] serial port communication
2022-06-28 23:09:00 【おもいね】
1.cubemx Configure serial port communication

Mode :
- Asynchronous : asynchronous , The whole process , It won't hinder the sender's work .
- Synchronous : Sync , Once the synchronization information is sent , The sender has to wait for the answer , To continue the subsequent line
by . - Single Wire : Single bus , Half duplex .

Baud rate and some parity bit settings , The sending and receiving settings are the same ok.
2. Use of serial port code
I usually use printf Function for serial port output
Redirect fputc function
int fputc (int ch , FILE *f){
uint8_t temp[1] = {
ch};
HAL_UART_Transmit(&huart1,temp,1,2);
return ch;
}


3. Write function code
// send data
HAL_StatusTypeDef HAL_UART_Transmit(UART_HandleTypeDef *huart, uint8_t *pData,
uint16_t Size, uint32_t Timeout);
// receive data
HAL_StatusTypeDef HAL_UART_Receive(UART_HandleTypeDef *huart, uint8_t *pData,
uint16_t Size, uint32_t Timeout);
// Send interrupt
HAL_StatusTypeDef HAL_UART_Transmit_IT(UART_HandleTypeDef *huart, uint8_t *
pData, uint16_t Size);
// Receive interrupt
HAL_StatusTypeDef HAL_UART_Receive_IT(UART_HandleTypeDef *huart, uint8_t *pData
, uint16_t Size);
// Use DMA send out
HAL_StatusTypeDef HAL_UART_Transmit_DMA(UART_HandleTypeDef *huart, uint8_t *
pData, uint16_t Size);
// Use DMA receive
HAL_StatusTypeDef HAL_UART_Receive_DMA(UART_HandleTypeDef *huart, uint8_t *
pData, uint16_t Size);
//DMA Pause
HAL_StatusTypeDef HAL_UART_DMAPause(UART_HandleTypeDef *huart);
//DMA recovery
HAL_StatusTypeDef HAL_UART_DMAResume(UART_HandleTypeDef *huart);
//DMA stop it
HAL_StatusTypeDef HAL_UART_DMAStop(UART_HandleTypeDef *huart);
边栏推荐
- O & M troubleshooting - use hcache plug-in to troubleshoot excessive buffer/cache occupancy
- LeetCode 324 摆动排序 II[排序 双指针] HERODING的LeetCode之路
- 他原来是这么刷题的!
- Google Earth engine (GEE) -- crop extraction and analysis using sentinel-2 data
- Wechat red envelope cover making tutorial and use guide with link jump
- 论文解读(DCN)《Towards K-means-friendly Spaces: Simultaneous Deep Learning and Clustering》
- Web API learning notes 1
- 自媒体行业内卷严重:企业自媒体应该何去何从
- 【kotlin】好看的弹出框、自定义弹出框(对话框)、扩展函数、菊花等待条、消息提示框
- 笔记
猜你喜欢

Master the usage of const

On the necessity and solution of building a campus online teaching video convergence platform

如何结合均线分析伦敦金行情走势线图

This simple little function saves 213 hours for our production research team in half a year

Powerful open source API interface visual management platform Yapi

After crossing, she said that the multiverse really exists

【深度学习】(2) Transformer 网络解析,代码复现,附Pytorch完整代码

深入虚拟内存(Virtual Memory,VM)

Go language - reflect

两栏布局左边图片显示部分由右边内容高度决定
随机推荐
【Flutter 问题系列第 71 篇】Flutter 中 Uint8List 和 Image 之间的相互转换
Powerful open source API interface visual management platform Yapi
Jointly explore digital technology and information security, and the fourth China Russia Digital Forum was successfully held
【Word 教程系列第 1 篇】如何去除 Word 表格中的箭头
LeCun预言AGI:大模型和强化学习都是斜道!我的世界模型才是新路
云计算的迷路者
Is it safe and reliable for changtou school to help open a securities account? How to drive
没找到实习,他总结了这些
hiredis的代码示例
【Try to Hack】nmap
The love digital smart 2022 summit opens, sharing data strategy and building data-driven organization methodology
What is the difference between WMS warehouse management system and ERP
C語言-單詞分析解析
非科班!自学之路!
深入虚拟内存(Virtual Memory,VM)
Google Earth Engine(GEE)——利用sentinel-2数据进行农作物提取分析
Sample code of using redis to realize the like function
复杂嵌套的对象池(4)——管理多类实例和多阶段实例的对象池
【深度学习】(3) Transformer 中的 Encoder 机制,附Pytorch完整代码
小样本利器2.文本对抗+半监督 FGSM & VAT & FGM代码实现