当前位置:网站首页>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 .
边栏推荐
- Who is better, Qianyuan projection Xiaoming Q1 pro or Jimi new play? Which configuration is higher than haqu K1?
- Threejs controller cube space basic controller + inertia control + flight control
- 检查密码
- 篇9:XShell免费版安装
- MQ教程 | Exchange(交换机)
- 大顶堆、小顶堆与堆排序
- 《可供方案开发》口算训练机/数学宝/儿童口算宝/智能数学宝 LCD液晶显示驱动IC-VK1622(LQFP64封装),原厂技术支持
- 2022家用投影仪首选!当贝F5强悍音画效果带来极致视听体验
- Teamtalk source code analysis win client
- 卷积神经网络(入门)
猜你喜欢

obsidian安装第三方插件——无法加载插件

万物生长大会在杭召开,当贝入选2022中国未来独角兽TOP100榜单

STM32 library function for GPIO initialization

抓包工具fiddler学习

Tencent cloud tstor unified storage passed the evaluation of the first batch of basic file storage capabilities of the ICT Institute

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

MQ tutorial | exchange (switch)

STM32-DAC实验&高频DAC输出测试

buuctf-pwn write-ups (7)

Chinese science and technology from the Winter Olympics (III): the awakening and evolution of digital people
随机推荐
STM32标准固件库函数名(一)
Fabric. JS dynamically set font size
每日学习2
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
Fabric.js 手动加粗文本iText
跨服务器数据访问的创建链接服务器方法
线性dp求解 最长子序列 —— 小题三则
[to be continued] [UE4 notes] l5ue4 model import
Route (II)
3. Function pointers and pointer functions
threejs的控制器 立方体空间 基本控制器+惯性控制+飞行控制
途家木鸟美团夏日折扣对垒,门槛低就一定香吗?
Daily learning 2
The evolution process of the correct implementation principle of redis distributed lock and the summary of redison's actual combat
一般来讲,如果频繁出现inconsistent tab and space的报错
Golang 快速生成数据库表的 model 和 queryset
快解析:轻松实现共享上网
NLA自然语言分析实现数据分析零门槛
Pycharm连接远程服务器
mongodb的认识