当前位置:网站首页>Hal library IIC simulation in punctual atom STM32 `define SDA_ IN() {GPIOB->MODER&=~(3<<(9*2));GPIOB->MODER|=0<<9*2;}` // PB9 input mode
Hal library IIC simulation in punctual atom STM32 `define SDA_ IN() {GPIOB->MODER&=~(3<<(9*2));GPIOB->MODER|=0<<9*2;}` // PB9 input mode
2022-07-26 11:34:00 【yanwu_ nuc】
The punctual atoms hal Library simulation iic Involved in the #define SDA_IN() {GPIOB->MODER&=~(3<<(9*2));GPIOB->MODER|=0<<9*2;} //PB9 The input mode
#define SDA_OUT() {GPIOB->MODER&=~(3<<(9*2));GPIOB->MODER|=1<<9*2;} //PB9 The output mode
stm32 In the Chinese reference manual I/O Port control register Is explained as follows :
Every GPIO Yes 4 individual 32 Bit memory mapped control registers ( GPIOx_MODER、 GPIOx_OTYPER、GPIOx_OSPEEDR、 GPIOx_PUPDR), Can be configured up to 16 individual I/O. GPIOx_MODER Registers are used to select I/O Direction ( Input 、 Output 、 AF、 simulation ). GPIOx_OTYPER and GPIOx_OSPEEDR Registers are used to select the output type respectively ( Push and pull or open the leak ) And speed ( Whatever kind of I/O Direction , Will directly put I/O The speed pin is connected to the corresponding GPIOx_OSPEEDR Register bit ). Whatever kind of I/O Direction , GPIOx_PUPDR Registers are used to select pull up / The drop-down .
GPIO Port mode register (GPIOx_MODER) (x = A…I) Here's the picture 
The value of the register can be modified by software , To decide I/O The direction of .
The first part GPIOB->MODER&=~(3<<(9*2)); Is decimal 3( Binary is 11) Move left (9*2) bits , Also is to 18,19 Set the position to 11, And then the reverse becomes 00, And again GPIOB->MODER And operation , here GPIOB->MODER Of 18,19 A into 00. The first sentence is to GPIOB->MODER Of 18,19 Location 0. here PB9 Is the input mode
Rear part GPIOB->MODER|=0<<9*2 and GPIOB->MODER|=1<<9*2 That is, assign values to these two positions according to the input and output of the reference manual , The process is the same as above .
There is also a method of standard library Register operation port mode #define SDA_IN() /#define SDA_OUT()( The punctual STM32-IIC experiment )
边栏推荐
- js使用WebUploader做大文件的分块和断点续传
- 【转载】多元高斯分布(The Multivariate normal distribution)
- Rigorous proof of Behrman's expectation equation
- [vscode] how to connect to the server remotely
- 服务器内存故障预测居然可以这样做!
- Caused by: scala. MatchError: None (of class scala.None$)
- 社区点赞业务缓存设计优化探索
- Cmake常用命令总结
- C notes
- How to configure the jdbcrealm data source?
猜你喜欢

【万字长文】使用 LSM-Tree 思想基于.Net 6.0 C# 实现 KV 数据库(案例版)

Data type of SQL Server database

Simple use of MySQL database

702马力破百仅4.5秒!最强皮卡来袭,安全、舒适一个不落
![[idea]如何新建一个项目](/img/33/f210d59ccd3664487f401929dac24c.png)
[idea]如何新建一个项目

Three properties of concurrency

PyQt5快速开发与实战 第1章 认识PyQt5

MongoDB-使用$type查询某个字段的类型是否为xxx

MySQL deadlock analysis
![[报错]Exception: Found duplicate column(s) in the data schema: `value`;](/img/df/ca676633ca6d5e8c0a870be0732707.png)
[报错]Exception: Found duplicate column(s) in the data schema: `value`;
随机推荐
[error reporting] what do you read in the log
PostgreSQL in Linux and windows installation and introductory basic tutorial
MySQL事务详解
How to configure the jdbcrealm data source?
js使用WebUploader做大文件的分块和断点续传
[learning progress] may
SQL statement of SQL server creates database
社区点赞业务缓存设计优化探索
Real time streaming protocol --rtsp
Smart contract DAPP system development process technology
[报错]看日志看什么
Relationship between pixels and memory
What does it mean that the configuration file ends in RC
Basic recursive equation of DP
leetcode-209. 长度最小的子数组(二分、前缀和、滑动窗口)
HCI interface
记录个人遇到的错误
脉冲波形的产生与变换
剑指 Offer 25. 合并两个排序的链表
承认吧 投新能源就是为了安全感