当前位置:网站首页>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 .
边栏推荐
猜你喜欢

Certik released the defi security report in 2021, disclosing key data of industry development (PDF download link attached)

YOLOv3&YOLOv5输出结果说明

抓包工具fiddler学习

每日学习3

博睿数据一体化智能可观测平台入选中国信通院2022年“云原生产品名录”

socket(套接字)与socket地址

Pychart connects to the remote server

Essential elements of science fiction 3D scenes - City

< schematic diagram of oral arithmetic exercise machine program development> oral arithmetic exercise machine / oral arithmetic treasure / children's math treasure / children's calculator LCD LCD driv

Chinese science and technology from the Winter Olympics (III): the awakening and evolution of digital people
随机推荐
NLA natural language analysis makes data analysis more intelligent
万物生长大会在杭召开,当贝入选2022中国未来独角兽TOP100榜单
MQ tutorial | exchange (switch)
Use of freemaker
Talk about idempotent design
[deep learning] simple implementation of neural network forward propagation
C语言高级用法--函数指针:回调函数;转换表
Federated Search: all requirements in search
HMS core machine learning service helps zaful users to shop conveniently
MySQL 45 lecture - learning the actual battle of MySQL in Geek time 45 Lecture Notes - 05 | easy to understand index (Part 2)
Fabric. JS free draw circle
PyQt5_ Qscrollarea content is saved as a picture
Fabric.js 自由绘制椭圆
Quarkus learning IV - project development to deployment
【空间&单细胞组学】第1期:单细胞结合空间转录组研究PDAC肿瘤微环境
Pychart connects to the remote server
关于Flink框架窗口(window)函数最全解析
STM32库函数进行GPIO初始化
2. Const pointer
Available solution development oral arithmetic training machine / math treasure / children's oral arithmetic treasure / intelligent math treasure LCD LCD driver ic-vk1622 (lqfp64 package), original te