当前位置:网站首页>[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);
边栏推荐
- 【深度学习】(3) Transformer 中的 Encoder 机制,附Pytorch完整代码
- Business atlas in super factory
- 小样本利器2.文本对抗+半监督 FGSM & VAT & FGM代码实现
- Small sample sharp weapon 2 Text confrontation + semi supervised FGSM & VAT & FGM code implementation
- TDD和自动化测试
- Google Earth Engine(GEE)——利用sentinel-2数据进行农作物提取分析
- 2022-06-28:以下golang代码输出什么?A:true;B:false;C:panic;D:编译失败。 package main import “fm
- 【kotlin】好看的弹出框、自定义弹出框(对话框)、扩展函数、菊花等待条、消息提示框
- Didn't find an internship. He summed it up
- 想问问,股票开账户如何优惠开户?网上开户安全么?
猜你喜欢

两栏布局左边图片显示部分由右边内容高度决定

The love digital smart 2022 summit opens, sharing data strategy and building data-driven organization methodology

Wave picking of WMS warehouse management system module

如何使用伦敦金画出支撑阻力线

k线图基础知识图解——单根K线的含义

lock4j--分布式锁中间件--使用/实例

The picture display on the left of the two column layout is determined by the content height on the right

Web API learning notes 1

Fanuc robot_ Introduction to Karel programming (2)_ Usage of general IO signal

Zadig + sonarqube, ensuring the safety of the development process
随机推荐
一文读懂,WMS仓储管理系统与ERP有什么区别
见丰知夏|国漫鼻祖丰子恺,数字藏品独家发售
【Word 教程系列第 2 篇】Word 中如何设置每页的表格都有表头
Zadig + sonarqube, ensuring the safety of the development process
Non scientific class! The road of self-study!
长投学堂帮忙开证券账户是安全靠谱的吗?个人如何开
Chapter V virtual memory exercise
浅析搭建校园在线教学视频汇聚平台的必要性及解决方案
Encounter with avita 11: long lost freshness under strong product power
flowable 边界定时器
老家出资,俞敏洪设立两支基金
在DialogFragment的onStop(完全不可见)时调用dismiss退出界面报错解决办法
[sword finger offer] 50 First character that appears only once
Interpretation of papers (DCN) towards k-means-friendly spaces: simultaneous deep learning and clustering
第四章 存储器管理练习
How to analyze the trend chart of London gold market with the moving average
Keil project, RTT cannot print after too many programs are written
[gateway development] handle the IP address segment represented by CIDR when NGX nested Lua
The love digital smart 2022 summit opens, sharing data strategy and building data-driven organization methodology
月薪6万,互联网“降本增效”后,这类人开始被疯抢