当前位置:网站首页>STM32 standard firmware library function name (I)
STM32 standard firmware library function name (I)
2022-07-02 14:31:00 【Little BigUs】
Operation register CRH and CRL To configure the IO Mode and speed of port
void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct);operation IDR Register read IO Port data is through GPIO_ReadInputDataBit Functionally implemented
GPIO_ReadInputData(GPIO_TypeDef * GPIOx) uint8_t GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)The return value is 1(Bit_SET) perhaps 0(Bit_RESET);
Set... In the firmware library ODR Register value to control IO The output state of the port is through the function GPIO_Write To achieve
GPIO_WriteBit(GPIO_TypeDef * GPIOx, uint16_t GPIO_Pin, BitAction BitVal) GPIO_Write(GPIO_TypeDef* GPIOx, uint16_t PortVal);adopt BSRR and BRR Set register GPIO The port output is through the function GPIO_SetBits() And the function GPIO_ResetBits() To complete .
void GPIO_SetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); void GPIO_ResetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);peripherals ( A serial port ) Clock enable
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1);Serial reset
void USART_DeInit(USART_TypeDef* USARTx);Initialization of serial port parameters
void USART_Init(USART_TypeDef* USARTx, USART_InitTypeDef* USART_InitStruct);The first parameter is the serial port name , The second parameter is the structure pointer containing initialization parameters
Data sending and receiving
void USART_SendData(USART_TypeDef* USARTx, uint16_t Data); uint16_t USART_ReceiveData(USART_TypeDef* USARTx);Serial port status
The serial port status can be through USART Of SR Register view
[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-51p4uhTX-1655780674551)(C:\Users\luo’xin\AppData\Roaming\Typora\typora-user-images\image-20220620154658850.png)]
Fifth RXNE(read external not enpty) When this bit is set 1 When , It indicates that data has been received , And you can read it . At this time, all we have to do is read it as soon as possible USART_DR, By reading USART_DR This bit can be cleared , You can also write... To this bit 0, Direct removal .
Sixth place TC(transaction complete) When the bit is set , Express USART_DR The data in has been sent . If the interrupt of this bit is set , An interrupt is generated . There are also two ways to clear this bit :1) read USART_SR, Write USART_DR.2) Write directly to this bit 0.
Read the serial port status function :
FlagStatus USART_GetFlagStatus(USART_TypeDef* USARTx, uint16_t USART_FLAG);The first parameter is the serial port name , The second parameter is the status to view , For example, the second parameter can be USART_FLAG_RXNE, USART_FLAG_TC wait .
Serial port enable
USART_Cmd(USART_TypeDef * USARTx, FunctionalState NewState)The first parameter is needless to say , The options for the second parameter are ENABLE , DISABLE.
Serial port interrupt configuration , What situations can be configured ( Such as Count overflow , Data received , Completion of data transmission, etc ) Can trigger an interrupt
// Serial port interrupt configuration USART_ITConfig(USART_TypeDef * USARTx, uint16_t USART_IT, FunctionalState NewState)The second entry parameter of this function is to indicate the type of enable serial port , That is, what kind of interrupt is enabled , Because there are many interrupt types of serial port . For example, when receiving data (RXNE The read data register is not empty ), We need to generate interruptions , So the way we turn on the interrupt is :
USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);At the end of sending data (TC, Send complete ) To generate interrupts , So the way is :
USART_ITConfig(USART1,USART_IT_TC,ENABLE);For more interrupt enable types, please refer to STM32 In the Chinese reference manual USART_CR register
Get the corresponding interrupt status
If enabled, interrupt , When an interrupt occurs, a bit change will occur in the corresponding status register , We can know whether an interrupt has occurred by reading this bit
USART_GetITStatus(USART_TypeDef * USARTx, uint16_t USART_IT)
change , We can know whether an interrupt has occurred by reading this bit
```
USART_GetITStatus(USART_TypeDef * USARTx, uint16_t USART_IT)
```
The return value is SET , RESET,set Represents an interruption ,RESET Represents that there is no interruption .
边栏推荐
- 2、const 型指针
- Default slot, named slot, scope slot
- PTA question bank== > complex four operations, one for one, examination seat number (7-73)
- 【空间&单细胞组学】第1期:单细胞结合空间转录组研究PDAC肿瘤微环境
- Development and design of animation surrounding mall sales website based on php+mysql
- Systemserver process
- Yolov3 & yolov5 output result description
- Using computed in uni app solves the abnormal display of data () value in tab switching
- Chinese science and technology from the Winter Olympics (III): the awakening and evolution of digital people
- Fabric. Keep the original level when JS element is selected
猜你喜欢

php链表创建和遍历

Fabric.js 缩放画布

The most complete analysis of Flink frame window function

Fabric. JS zoom canvas

<口算練習機 方案開發原理圖>口算練習機/口算寶/兒童數學寶/兒童計算器 LCD液晶顯示驅動IC-VK1621B,提供技術支持
![[Hongke technology sharing] how to test DNS server: DNS performance and response time test](/img/f4/d8c21d6c33985fd6d819cd44c22c72.png)
[Hongke technology sharing] how to test DNS server: DNS performance and response time test

kaggle如何使用utility script

Fabric.js 上划线、中划线(删除线)、下划线

Teamtalk source code analysis win client

QT new project
随机推荐
buuctf-pwn write-ups (7)
提示:SQL Server 阻止了对组件‘Ad Hoc Distributed Queries ‘的STATEMENT ‘OpenRowset/OpenDatasource“”
Qt新建项目
< schéma de développement de la machine d'exercice oral > machine d'exercice oral / trésor d'exercice oral / trésor de mathématiques pour enfants / lecteur LCD de calculatrice pour enfants IC - vk1621
threejs的控制器 立方体空间 基本控制器+惯性控制+飞行控制
3. Function pointers and pointer functions
go操作redis
Launcher startup process
Understanding of mongodb
Daily learning 3
Analysis of CPU surge in production environment service
Quick analysis: easy to share the Internet
博睿数据一体化智能可观测平台入选中国信通院2022年“云原生产品名录”
There is no solution to the decryption error of the remote user 'sa' and the service master password mapped from the remote server 'to the local user' (null) /sa '
Development and design of animation surrounding mall sales website based on php+mysql
PyQt5_ Qscrollarea content is saved as a picture
php链表创建和遍历
Fabric.js 自由绘制椭圆
途家木鸟美团夏日折扣对垒,门槛低就一定香吗?
Threejs controller cube space basic controller + inertia control + flight control