热搜关键词: 电路基础ADC数字信号处理封装库PLC

pdf

STM32固件库

  • 1星
  • 2015-02-06
  • 4.38MB
  • 需要1积分
  • 2次下载
标签: STM32

STM32

STM32固件库使用手册的中文翻译版

UM0427
用户手册
32
½基于
ARM
微控制器
STM32F101xx
STM32F103xx
固件½数库
介绍
本手册介绍了
32
½基于
ARM
微控制器
STM32F101xx
STM32F103xx
的固件½数库。
该½数库是一个固件½数包,它由程序、数据结构和宏组成,包括了微控制器所有外设的性½特征。该½
数库还包括每一个外设的驱动描述和应用实例。通过½用本固件½数库,无需深入掌握细节,用户也可以
½松应用每一个外设。因此,½用本固态½数库可以大大减少用户的程序编写时间,进而降½开发成本。
每个外设驱动½由一组½数组成,这组½数覆盖了该外设所有功½。每个器件的开发½由一个通用
API
(application programming interface
应用编程界面)驱动,API 对该驱动程序的结构,½数和参数名称½进行
了标准化。
所有的驱动源代码½符合“Strict
ANSI-C”标准(项目于范例文件符合扩充 ANSI-C
标准)
。我们已经把驱动
源代码文档化,他们同时兼容
MISRA-C 2004
标准(根据需要,我们可以提供兼容矩阵)
。由于整个固态
½数库按照“Strict
ANSI-C”标准编写,它不受不同开发环境的½响。仅对话启动文件取决于开发环境。
该固态½数库通过校验所有库½数的输入值来实现实时错误检测。该动态校验提高了½件的鲁棒性。实时
检测适合于用户应用程序的开发和调试。½这会增加了成本,可以在最终应用程序代码中移去,以优化代
码大小和执行速度。想要了解更多细节,请参阅
Section 2.5。
因为该固件库是通用的,并且包括了所有外设的功½,所以应用程序代码的大小和执行速度可½不是最优
的。对大多数应用程序来说,用户可以直接½用之,对于那些在代码大小和执行速度方面有严格要求的应
用程序,该固件库驱动程序可以½为如½设½外设的一½参考资料,根据实际需求对其进行调整。
此½固件库用户手册的整½架构如下:
定义,文档约定和固态½数库规则。
固态½数库概述(包的内容,库的架构)
,安装指南,库½用实例。
固件库具½描述:设½架构和每个外设的½数。
STM32F101xx
STM32F103xx
在整个文档中被写½
STM32F101x。
1/368
译文英文原版为
UM0427 Oct. 2007 Rev 2,
译文仅供参考,与英文版冲突的,以英文版为准
目½
目½
1.1
缩写
.......................................................................................................................................................... 27
1.2
½名规则
.................................................................................................................................................. 27
1.3
编码规则
.................................................................................................................................................. 28
1.3.1
变量
................................................................................................................................................ 28
1.3.2
布尔型
............................................................................................................................................ 28
1.3.3
标志½状态类型
........................................................................................................................... 29
1.3.4
功½状态类型
............................................................................................................................... 29
1.3.5
错误状态类型
............................................................................................................................... 29
1.3.6
外设
............................................................................................................................................... 29
2.1
压缩包描述
.............................................................................................................................................. 32
2.1.1
文件夹Examples............................................................................................................................
32
2.1.2
文件夹Library
............................................................................................................................... 32
2.1.3
文件夹Project
................................................................................................................................ 33
2.2
固件½数库文件描述
.............................................................................................................................. 33
2.3
外设的初始化和设½
.............................................................................................................................. 34
2.4
½段(Bit-Banding)...............................................................................................................................
35
2.4.1
映射公式
....................................................................................................................................... 35
2.4.2
应用实例
....................................................................................................................................... 35
2.5
运行时间检测
.......................................................................................................................................... 36
4.1 ADC寄存器结构 ....................................................................................................................................... 39
4.2 ADC库½数 ............................................................................................................................................... 40
4.2.1
½数ADC_DeInit...........................................................................................................................
42
4.2.2
½数ADC_Init
............................................................................................................................... 42
4.2.3
½数ADC_StructInit......................................................................................................................
44
4.2.4
½数ADC_Cmd
............................................................................................................................. 44
4.2.5
½数ADC_DMACmd....................................................................................................................
45
4.2.6
½数ADC_ITConfig
...................................................................................................................... 45
4.2.7
½数ADC_ResetCalibration
.......................................................................................................... 46
4.2.8
½数ADC_GetResetCalibrationStatus...........................................................................................
46
4.2.9
½数ADC_StartCalibration
........................................................................................................... 46
4.2.10
½数ADC_GetCalibrationStatus..................................................................................................
47
4.2.11
½数ADC_SoftwareStartConvCmd.............................................................................................
47
4.2.12
½数ADC_GetSoftwareStartConvStatus
..................................................................................... 48
4.2.13
½数ADC_DiscModeChannelCountConfig
................................................................................ 48
4.2.14
½数ADC_DiscModeCmd...........................................................................................................
49
4.2.15
½数ADC_RegularChannelConfig
.............................................................................................. 49
4.2.16
½数ADC_ExternalTrigConvConfig
........................................................................................... 51
4.2.17
½数ADC_GetConversionValue..................................................................................................
51
4.2.18
½数ADC_GetDuelModeConversionValue.................................................................................
52
4.2.19
½数ADC_AutoInjectedConvCmd..............................................................................................
52
4.2.20
½数ADC_InjectedDiscModeCmd..............................................................................................
53
4.2.21
½数ADC_ExternalTrigInjectedConvConfig
.............................................................................. 53
4.2.22
½数ADC_ExternalTrigInjectedConvCmd..................................................................................
54
4.2.23
½数ADC_SoftwareStartinjectedConvCmd
................................................................................ 54
4.2.24
½数ADC_GetsoftwareStartinjectedConvStatus
......................................................................... 55
4.2.25
½数ADC_InjectedChannleConfig..............................................................................................
55
4.2.26
½数ADC_InjectedSequencerLengthConfig
............................................................................... 56
4.2.27
½数ADC_SetinjectedOffset
....................................................................................................... 56
4.2.28
½数ADC_GetInjectedConversionValue
..................................................................................... 57
4.2.29
½数ADC_AnalogWatchdogCmd
............................................................................................... 57
2/368
译文英文原版为
UM0427 Oct. 2007 Rev 2,
译文仅供参考,与英文版冲突的,以英文版为准
目½
4.2.30
½数ADC_AnalogWatchdongThresholdsConfig
........................................................................ 58
4.2.31
½数ADC_AnalogWatchdongSingleChannelConfig...................................................................
58
4.2.32
½数ADC_TampSensorVrefintCmd
............................................................................................ 59
4.2.33
½数ADC_GetFlagStatus
............................................................................................................ 59
4.2.34
½数ADC_ClearFlag
................................................................................................................... 60
4.2.35
½数ADC_GetITStatus................................................................................................................
60
4.2.36
½数ADC_ClearITPendingBit.....................................................................................................
61
5.1 BKP寄存器结构..................................................................................................................................... 62
5.2 BKP库½数 ............................................................................................................................................... 63
5.2.1
½数BKP_DeInit
........................................................................................................................... 64
5.2.2
½数BKP_TamperPinLevelConfig
................................................................................................ 64
5.2.3
½数BKP_TamperPinCmd
............................................................................................................ 65
5.2.4
½数BKP_ITConfig.......................................................................................................................
65
5.2.5
½数BKP_RTCOutputConfig
........................................................................................................ 66
5.2.6
½数BKP_SetRTCCalibrationValue
.............................................................................................. 66
5.2.7
½数BKP_WriteBackupRegister
................................................................................................... 67
5.2.8
½数BKP_ReadBackupRegister
.................................................................................................... 67
5.2.9
½数BKP_GetFlagStatus
............................................................................................................... 68
5.2.10
½数BKP_ClearFlag....................................................................................................................
68
5.2.11
½数BKP_GetITStatus.................................................................................................................
69
5.2.12
½数BKP_ClearITPendingBit
..................................................................................................... 69
6.1 CAN寄存器结构....................................................................................................................................... 70
6.2 CAN库½数............................................................................................................................................... 72
6.2.1
½数CAN_DeInit...........................................................................................................................
72
6.2.2
½数CAN_Init
............................................................................................................................... 73
6.2.3
½数CAN_FilterInit.......................................................................................................................
75
6.2.4
½数CAN_StructInit......................................................................................................................
76
6.2.5
½数CAN_ITConfig
...................................................................................................................... 77
6.2.6
½数CAN_Transmit.......................................................................................................................
78
6.2.7
½数CAN_TransmitStatus
............................................................................................................. 79
6.2.8
½数CAN_CancelTransmit............................................................................................................
79
6.2.9
½数CAN_FIFORelease................................................................................................................
80
6.2.10
½数CAN_MessagePending........................................................................................................
80
6.2.11
½数CAN_Receive
...................................................................................................................... 81
6.2.12
½数CAN_Sleep
.......................................................................................................................... 82
6.2.13
½数CAN_WakeUp
..................................................................................................................... 82
6.2.14
½数CAN_GetFlagStatus
............................................................................................................ 83
6.2.15
½数CAN_ClearFlag
................................................................................................................... 83
6.2.16
½数CAN_GetITStatus................................................................................................................
84
6.2.17
½数CAN_ClearITPendingBit.....................................................................................................
85
7.1 DMA寄存器结构 ...................................................................................................................................... 86
7.2 DMA库½数.............................................................................................................................................. 88
7.2.1
½数DMA_DeInit..........................................................................................................................
89
7.2.2
½数DMA_Init
.............................................................................................................................. 89
7.2.3
½数DMA_StructInit
..................................................................................................................... 92
7.2.4
½数DMA_Cmd
............................................................................................................................ 92
7.2.5
½数DMA_ITConfig
..................................................................................................................... 93
7.2.6
½数DMA_GetCurrDataCounte
.................................................................................................... 93
7.2.7
½数DMA_GetFlagStatus
............................................................................................................. 94
7.2.8
½数DMA_ClearFlag
.................................................................................................................... 95
7.2.9
½数DMA_GetITStatus.................................................................................................................
95
7.2.10
½数DMA_ClearITPendingBit....................................................................................................
96
8.1 EXTI寄存器结构 ...................................................................................................................................... 97
3/368
译文英文原版为
UM0427 Oct. 2007 Rev 2,
译文仅供参考,与英文版冲突的,以英文版为准
目½
8.2 EXTI库½数 .............................................................................................................................................. 98
8.2.1
½数EXTI_DeInit
.......................................................................................................................... 98
8.2.2
½数EXTI_Init...............................................................................................................................
99
8.2.3
½数EXTI_StructInit
................................................................................................................... 100
8.2.4
½数EXTI_GenerateSWInterrupt
................................................................................................ 101
8.2.5
½数EXTI_GetFlagStatus............................................................................................................
101
8.2.6
½数EXTI_ClearFlag
.................................................................................................................. 102
8.2.7
½数EXTI_GetITStatus
............................................................................................................... 102
8.2.8
½数EXTI_ClearITPendingBit....................................................................................................
103
9.1 FLASH寄存器结构................................................................................................................................. 104
9.2 FLASH库½数......................................................................................................................................... 105
9.2.1
½数FLASH_SetLatency.............................................................................................................
106
9.2.2
½数FLASH_HalfCycleAccessCmd
........................................................................................... 107
9.2.3
½数FLASH_PrefetchBufferCmd
............................................................................................... 107
9.2.4
½数FLASH_Unlock...................................................................................................................
108
9.2.5
½数FLASH_Lock
...................................................................................................................... 108
9.2.6
½数FLASH_ErasePage
.............................................................................................................. 109
9.2.7
½数FLASH_EraseAllPages
....................................................................................................... 109
9.2.8
½数FLASH_EraseOptionBytes...................................................................................................110
9.2.9
½数FLASH_ProgramWord
.........................................................................................................110
9.2.10
½数FLASH_ProgramHalfWord
................................................................................................111
9.2.11
½数FLASH_ProgramOptionByteData
......................................................................................111
9.2.12
½数FLASH_EnableWriteProtection
.........................................................................................112
9.2.13
½数FLASH_ReadOutProtection
...............................................................................................113
9.2.14
½数FLASH_UserOptionByteConfig.........................................................................................114
9.2.15
½数FLASH_GetUserOptionByte..............................................................................................115
9.2.16
½数FLASH_GetWriteProtectionOptionByte
............................................................................115
9.2.17
½数FLASH_GetReadOutProtectionStatus................................................................................116
9.2.18
½数FLASH_GetPrefetchBufferStatus.......................................................................................116
9.2.19
½数FLASH_ITConfig...............................................................................................................117
9.2.20
½数FLASH_GetFlagStatus
.......................................................................................................117
9.2.21
½数FLASH_ClearFlag
..............................................................................................................118
9.2.22
½数FLASH_GetStatus
..............................................................................................................119
9.2.23
½数FLASH_WaitForLastOperation
..........................................................................................119
10.1 GPIO寄存器结构 .................................................................................................................................. 120
10.2 GPIO库½数 .......................................................................................................................................... 122
10.2.1
½数GPIO_DeInit......................................................................................................................
123
10.2.2
½数GPIO_AFIODeInit.............................................................................................................
123
10.2.3
½数GPIO_Init
.......................................................................................................................... 124
10.2.4
½数GPIO_StructInit
................................................................................................................. 126
10.2.5
½数GPIO_ReadInputDataBit
................................................................................................... 126
10.2.6
½数GPIO_ReadInputData........................................................................................................
127
10.2.7
½数GPIO_ReadOutputDataBit
................................................................................................ 127
10.2.8
½数GPIO_ReadOutputData
..................................................................................................... 128
10.2.9
½数GPIO_SetBits
.................................................................................................................... 128
10.2.10
½数GPIO_ResetBits...............................................................................................................
129
10.2.11
½数GPIO_WriteBit
................................................................................................................ 129
10.2.12
½数GPIO_Write
..................................................................................................................... 130
10.2.13
½数GPIO_PinLockConfig
..................................................................................................... 130
10.2.14
½数GPIO_EventOutputConfig...............................................................................................
131
10.2.15
½数GPIO_EventOutputCmd
.................................................................................................. 131
10.2.16
½数GPIO_PinRemapConfig
.................................................................................................. 132
10.2.17
½数GPIO_EXTILineConfig...................................................................................................
133
4/368
译文英文原版为
UM0427 Oct. 2007 Rev 2,
译文仅供参考,与英文版冲突的,以英文版为准
目½
11.1 I2C寄存器结构 ..................................................................................................................................... 134
11.2 I2C库½数 ............................................................................................................................................. 135
11.2.1
½数I2C_DeInit
......................................................................................................................... 136
11.2.2
½数I2C_
Init............................................................................................................................. 137
11.2.3
½数I2C_
StructInit ................................................................................................................... 138
11.2.4
½数I2C_
Cmd........................................................................................................................... 139
11.2.5
½数I2C_
DMACmd ................................................................................................................. 139
11.2.6
½数I2C_
DMALastTransferCmd ............................................................................................. 140
11.2.7
½数I2C_
GenerateSTART ........................................................................................................ 140
11.2.8
½数I2C_
GenerateSTOP .......................................................................................................... 141
11.2.9
½数I2C_
AcknowledgeConfig.................................................................................................. 141
11.2.10
½数I2C_
OwnAddress2Config............................................................................................... 142
11.2.11
½数I2C_
DualAddressCmd .................................................................................................... 142
11.2.12
½数I2C_
GeneralCallCmd...................................................................................................... 143
11.2.13
½数I2C_
ITConfig.................................................................................................................. 143
11.2.14
½数I2C_
SendData ................................................................................................................. 144
11.2.15
½数I2C_
ReceiveData ............................................................................................................ 144
11.2.16
½数I2C_
Send7bitAddress ..................................................................................................... 145
11.2.17
½数I2C_
ReadRegister ........................................................................................................... 145
11.2.18
½数I2C_
SoftwareResetCmd.................................................................................................. 146
11.2.19
½数I2C_
SMBusAlertConfig ................................................................................................. 147
11.2.20
½数I2C_
TransmitPEC ........................................................................................................... 147
11.2.21
½数I2C_
PECPositionConfig ................................................................................................. 148
11.2.22
½数I2C_
CalculatePEC .......................................................................................................... 148
11.2.23
½数I2C_
GetPEC ................................................................................................................... 149
11.2.24
½数I2C_
ARPCmd ................................................................................................................. 149
11.2.25
½数I2C_
StretchClockCmd .................................................................................................... 150
11.2.26
½数I2C_
FastModeDutyCycleConfig .................................................................................... 150
11.2.27
½数I2C_
GetLastEvent........................................................................................................... 151
11.2.29
½数I2C_
GetFlagStatus .......................................................................................................... 152
11.2.30
½数I2C_
ClearFlag................................................................................................................. 153
11.2.31
½数I2C_
GetITStatus ............................................................................................................. 154
11.2.32
½数I2C_
ClearITPendingBit .................................................................................................. 155
12.1 IWDG寄存器结构 ................................................................................................................................ 156
12.2 IWDG库½数 ........................................................................................................................................ 157
12.2.1
½数IWDG_WriteAccessCmd...................................................................................................
157
12.2.2
½数IWDG_SetPrescaler...........................................................................................................
158
12.2.3
½数IWDG_SetReload
.............................................................................................................. 158
12.2.4
½数IWDG_ReloadCounter
...................................................................................................... 159
12.2.5
½数IWDG_Enable
................................................................................................................... 159
12.2.6
½数IWDG_GetFlagStatus
........................................................................................................ 159
13.1 NVIC寄存器结构.................................................................................................................................. 161
13.2 NVIC库½数 ......................................................................................................................................... 163
13.2.1
½数NVIC_DeInit
..................................................................................................................... 164
13.2.2
½数NVIC_SCBDeInit..............................................................................................................
164
13.2.3
½数NVIC_PriorityGroupConfig
.............................................................................................. 165
13.2.4
½数NVIC_Init
.......................................................................................................................... 166
13.2.5
½数NVIC_StructInit.................................................................................................................
168
13.2.6
½数NVIC_SETPRIMASK.......................................................................................................
169
13.2.7
½数NVIC_RESETPRIMASK..................................................................................................
169
13.2.8
½数NVIC_SETFAULTMASK.................................................................................................
170
13.2.9
½数NVIC_RESETFAULTMASK............................................................................................
170
13.2.10
½数NVIC_BASEPRICONFIG
.............................................................................................. 171
5/368
译文英文原版为
UM0427 Oct. 2007 Rev 2,
译文仅供参考,与英文版冲突的,以英文版为准
展开预览

猜您喜欢

评论

登录/注册

意见反馈

求资源

回顶部

推荐内容

热门活动

热门器件

随便看看

 
EEWorld订阅号

 
EEWorld服务号

 
汽车开发圈

电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved
×