没有合适的资源?快使用搜索试试~ 我知道了~
STM32F10xxx_固件库(UM0427 英文版).pdf
5星 · 超过95%的资源 需积分: 50 172 下载量 9 浏览量
2010-05-21
16:42:33
上传
评论
收藏 2.72MB PDF 举报
温馨提示
试读
527页
STM32F10xxx_固件库(UM0427 英文版).pdf 与中文版相比多了FSMC部分。
资源推荐
资源详情
资源评论
September 2008 Rev 6 1/527
UM0427
User manual
ARM®-based 32-bit MCU STM32F101xx and STM32F103xx
firmware library
Introduction
This document describes the ARM
®
-based 32-bit MCU STM32F101xx and STM32F103xx
firmware library.
This library is a firmware package which contains a collection of routines, data structures
and macros covering the features of all peripherals. It includes a description of the device
drivers plus a set of examples for each peripheral. The firmware library allows any device to
be used in the user application without the need for in-depth study of each peripheral
specifications. As a result, using the firmware library saves significant time that would
otherwise be spent in coding, while reducing the application development and integration
cost.
Each device driver consists of a set of functions covering all peripheral functionalities. The
development of each driver is driven by a common API (application programming interface)
which standardizes the driver structure, the functions and the names of parameters.
The driver source code is developed in ‘Strict ANSI-C’ (relaxed ANSI-C for projects and
examples files). It is fully documented and is MISRA-C 2004 compliant (the compliancy
matrix is available upon request). Writing the whole library in ‘Strict ANSI-C’ makes it
independent from the software toolchain. Only the start-up files depend on the toolchain.
The firmware library implements run-time failure detection by checking the input values for
all library functions. This dynamic checking contributes to enhance the robustness of the
software. Run-time detection is suitable for user application development and debugging. It
adds an overhead and can be removed from the final application code to minimize code size
and execution speed. For more details refer to Section 2.5: Run-time checking on page 48.
Since the firmware library is generic and covers all peripherals functionalities, the size and/or
execution speed of the application code may not be optimized. For many applications, the
library may be used as is. However, for applications having tough constraints in terms of
code size and/or execution speed, the library drivers should be used as a reference on how
to configure the peripheral and tailor them to specific application requirements.
The firmware library user manual is structured as follows:
■ Definitions, document conventions and firmware library rules
■ Overview of the firmware library (package content, library structure), installation
guidelines, and example on how to use the library.
■ Detailed description the firmware library: configuration structure and software functions
for each peripheral.
STM32F101xx and STM32F103xx will be referred to as STM32F10xxx throughout the
document.
www.st.com
Contents UM0427
2/527
Contents
1 Document and library rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
1.1 Acronyms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
1.2 Naming conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
1.3 Coding rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
1.3.1 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
1.3.2 Boolean type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
1.3.3 FlagStatus type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
1.3.4 FunctionalState type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
1.3.5 ErrorStatus type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
1.3.6 Peripherals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
2 Firmware library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
2.1 Package description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
2.1.1 Examples folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
2.1.2 Library folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
2.1.3 Project folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
2.2 Description of firmware library files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
2.3 Peripheral initialization and configuration . . . . . . . . . . . . . . . . . . . . . . . . . 46
2.4 Bit-Banding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
2.4.1 Mapping formula . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
2.4.2 Example of implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
2.5 Run-time checking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
3 Peripheral firmware overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
4 Analog/digital converter (ADC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
4.1 ADC register structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
4.2 ADC library functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
4.2.1 ADC_DeInit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
4.2.2 ADC_Init function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
ADC_InitTypeDef structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
4.2.3 ADC_StructInit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
4.2.4 ADC_Cmd function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
UM0427 Contents
3/527
4.2.5 ADC_DMACmd function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
4.2.6 ADC_ITConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
4.2.7 ADC_ResetCalibration function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
4.2.8 ADC_GetResetCalibrationStatus function . . . . . . . . . . . . . . . . . . . . . . . 63
4.2.9 ADC_StartCalibration function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
4.2.10 ADC_GetCalibrationStatus function . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
4.2.11 ADC_SoftwareStartConvCmd function . . . . . . . . . . . . . . . . . . . . . . . . . 65
4.2.12 ADC_GetSoftwareStartConvStatus function . . . . . . . . . . . . . . . . . . . . . 65
4.2.13 ADC_DiscModeChannelCountConfig function . . . . . . . . . . . . . . . . . . . 66
4.2.14 ADC_DiscModeCmd function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
4.2.15 ADC_RegularChannelConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . 67
4.2.16 ADC_ExternalTrigConvCmd function . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
4.2.17 ADC_GetConversionValue function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
4.2.18 ADC_GetDualModeConversionValue function . . . . . . . . . . . . . . . . . . . 70
4.2.19 ADC_AutoInjectedConvCmd function . . . . . . . . . . . . . . . . . . . . . . . . . . 70
4.2.20 ADC_InjectedDiscModeCmd function . . . . . . . . . . . . . . . . . . . . . . . . . . 71
4.2.21 ADC_ExternalTrigInjectedConvConfig function . . . . . . . . . . . . . . . . . . . 71
4.2.22 ADC_ExternalTrigInjectedConvCmd function . . . . . . . . . . . . . . . . . . . . 73
4.2.23 ADC_SoftwareStartInjectedConvCmd function . . . . . . . . . . . . . . . . . . . 73
4.2.24 ADC_GetSoftwareStartInjectedConvStatus function . . . . . . . . . . . . . . . 74
4.2.25 ADC_InjectedChannelConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . 75
4.2.26 ADC_InjectedSequencerLengthConfig function . . . . . . . . . . . . . . . . . . 76
4.2.27 ADC_SetInjectedOffset function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
4.2.28 ADC_GetInjectedConversionValue function . . . . . . . . . . . . . . . . . . . . . 77
4.2.29 ADC_AnalogWatchdogCmd function . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
4.2.30 ADC_AnalogWatchdogThresholdsConfig function . . . . . . . . . . . . . . . . 79
4.2.31 ADC_AnalogWatchdogSingleChannelConfig function . . . . . . . . . . . . . . 79
4.2.32 ADC_TempSensorVrefintCmd function . . . . . . . . . . . . . . . . . . . . . . . . . 80
4.2.33 ADC_GetFlagStatus function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
4.2.34 ADC_ClearFlag function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
4.2.35 ADC_GetITStatus function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
4.2.36 ADC_ClearITPendingBit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
5 Backup registers (BKP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
5.1 BKP register structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
5.2 Firmware library functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
5.2.1 BKP_DeInit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Contents UM0427
4/527
5.2.2 BKP_TamperPinLevelConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . 87
5.2.3 BKP_TamperPinCmd function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
5.2.4 BKP_ITConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
5.2.5 BKP_RTCOutputConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
5.2.6 BKP_SetRTCCalibrationValue function . . . . . . . . . . . . . . . . . . . . . . . . . 89
5.2.7 BKP_WriteBackupRegister function . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
5.2.8 BKP_ReadBackupRegister function . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
5.2.9 BKP_GetFlagStatus function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
5.2.10 BKP_ClearFlag function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
5.2.11 BKP_GetITStatus function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
5.2.12 BKP_ClearITPendingBit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
6 Controller area network (CAN) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
6.1 CAN register structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
6.2 Firmware library functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
6.2.1 CAN_DeInit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
6.2.2 CAN_Init function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
CAN_InitTypeDef structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
6.2.3 CAN_FilterInit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
CAN_FilterInitTypeDef structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
6.2.4 CAN_StructInit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
6.2.5 CAN_ITConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
6.2.6 CAN_Transmit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
CanTxMsg . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
6.2.7 CAN_TransmitStatus function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
6.2.8 CAN_CancelTransmit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
6.2.9 CAN_FIFORelease function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
6.2.10 CAN_MessagePending function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
6.2.11 CAN_Receive function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
CanRxMsg structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
6.2.12 CAN_Sleep function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
6.2.13 CAN_WakeUp function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
6.2.14 CAN_GetFlagStatus function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
6.2.15 CAN_ClearFlag function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
6.2.16 CAN_GetITStatus function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
6.2.17 CAN_ClearITPendingBit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
UM0427 Contents
5/527
7 DMA controller (DMA) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
7.1 DMA register structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
7.2 Firmware library functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
7.2.1 DMA_DeInit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
7.2.2 DMA_Init function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
DMA_InitTypeDef structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
7.2.3 DMA_StructInit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
7.2.4 DMA_Cmd function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
7.2.5 DMA_ITConfig function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
7.2.6 DMA_GetCurrDataCounter function . . . . . . . . . . . . . . . . . . . . . . . . . . 129
7.2.7 DMA_GetFlagStatus function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
7.2.8 DMA_ClearFlag function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
7.2.9 DMA_GetITStatus function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
7.2.10 DMA_ClearITPendingBit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
8 External interrupt/event controller (EXTI) . . . . . . . . . . . . . . . . . . . . . . 136
8.1 EXTI register structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
8.2 Firmware library functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
8.2.1 EXTI_DeInit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
8.2.2 EXTI_Init function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
EXTI_InitTypeDef structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
8.2.3 EXTI_Struct function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
8.2.4 EXTI_GenerateSWInterrupt function . . . . . . . . . . . . . . . . . . . . . . . . . . 142
8.2.5 EXTI_GetFlagStatus function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
8.2.6 EXTI_ClearFlag function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
8.2.7 EXTI_GetITStatus function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
8.2.8 EXTI_ClearITPendingBit function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
9 Flash memory (FLASH) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
9.1 FLASH register structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
9.2 Firmware library functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
9.2.1 FLASH_SetLatency function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
9.2.2 FLASH_HalfCycleAccessCmd function . . . . . . . . . . . . . . . . . . . . . . . . 149
9.2.3 FLASH_PrefetchBufferCmd function . . . . . . . . . . . . . . . . . . . . . . . . . . 150
9.2.4 FLASH_Unlock function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
9.2.5 FLASH_Lock function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
剩余526页未读,继续阅读
xmuzhengli
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- AIS2024 valid
- 最入门的爬虫代码 python.docx
- 爬虫零基础入门-爬取天气预报.pdf
- 最通俗易懂的 MongoDB 非结构化文档存储数据库教程.zip
- 以mongodb为数据库的订单物流小项目.zip
- 腾讯云-mongodb数据库, 项目部署.zip
- 腾讯 APIJSON 的 MongoDB 数据库插件.zip
- 理解非关系型数据库和关系型数据库的区别.zip
- 操作简单的Mongodb网页web管理工具,基于Spring Boot2.0支持mongodb集群.zip
- tms-mongodb-web,提供访问mongodb数据的REST API和可灵活扩展的mongodb web 客户端.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
前往页