STM32学习(一)—STM32固件库的使用
来源:互联网 发布:碣石正车行淘宝店 编辑:程序博客网 时间:2024/05/16 11:07
和我一起学习STM32——STM32固件库的使用
在这里我就不讨论在开发STM32的过程中到底是使用固件库好,还是直接上寄存器好。个人觉得STM32固件库编程思想是很不错的。在利用固件库开发的过程中一方面可以在很大的程度上缩短项目的开发周期,同时我们可以借鉴STM32固件库的编程方式试着为别的单片机写自己的固件库。好了,废话不多说了,下面我们来看看STM32的固件库:
(1)
(2)
Naming conventions
- PPPrefers to any peripheral acronym,for exampleADC.
- System andsource/header file names are preceded by the prefix‘stm32f10x_’.
- Constants used in onefile are defined within this file. A constant used in more than onefile is defined in a header file. All constants are written inupper case.
- Registers areconsidered as constants. Their names are in upper case. In mostcases, the same acronyms as in the STM32F10x reference manualdocument are used.
- Names of peripheral’sfunctions are preceded by the corresponding peripheral acronym inupper case followed by an underscore. The first letter in each wordis in upper case, for exampleUSART_SendData. Onlyone underscore is allowed in a function name to separate theperipheral acronym from the rest of the function name.
- Functions used toinitialize the PPP peripheral according to parameters specified inPPP_InitTypeDef are namedPPP_Init, forexampleTIM_Init.
- Functions used to resetthe PPP peripheral registers to their default values are namedPPP_DeInit, for exampleTIM_DeInit.
- Functions used to fillthe PPP_InitTypeDef structure with the reset values of each memberare namedPPP_StructInit, for exampleUSART_StructInit.
- Functions used toenable or disable the specified PPP peripheral are namedPPP_Cmd, for exampleUSART_Cmd.
- Functions used toenable or disable an interrupt source of the specified PPPperipheral are namedPPP_ITConfig, for exampleRCC_ITConfig.
- Functions used toenable or disable the DMA interface of the specified PPP peripheralare namedPPP_DMAConfig, for exampleTIM_DMAConfig.
- Functions used toconfigure a peripheral function always end with the string‘Config’, for exampleGPIO_PinRemapConfig.
- Functions used to checkwhether the specified PPP flag is set or reset are namedPPP_GetFlagStatus, for exampleI2C_GetFlagStatus.
- Functions used to cleara PPP flag are namedPPP_ClearFlag, for exampleI2C_ClearFlag.
- Functions used to checkwhether the specified PPP interrupt has occurred or not are namedPPP_GetITStatus, for exampleI2C_GetITStatus.
- Functions used to cleara PPP interrupt pending bit are namedPPP_ClearITPendingBit, for exampleI2C_ClearITPendingBit.
及Registersstructure,Peripheraldeclaration,egistersbits,Mappingformula,Exampleof implementation等的命名规则具体见STM32固件库帮助文档中的命名规则。
在这里顺便说一下STM32固件库代码的注释规则,它使用的DOXYGEN注释规则,本人平时码代码也用的是这个工具生成代码的HTML结构。至于下载地址及使用方法,我已经打包放在了我的微盘里了,这里是下载地址:http://vdisk.weibo.com/s/KfopH
(1)
在STM32F10xStandard Peripheral's Drivers里是STM32固件库提供的所有的外设驱动程序,平时写代码时主要也就是查看这些驱动程序。
在这里我们来看一下其中关于STM32的GPIO,在stm32f10x_gpio.c文件下,包含相关寄存器的宏定义和所有相关的函数。并且每个函数下都有该函数的介绍。例:
void
GPIO_AFIODeInit (void)
Deinitializes the Alternate Functions (remap, eventcontrol and EXTI configuration) registers to their default resetvalues.
在stm32f10x_gpio.h头文件中包含相关寄存器的宏定义及相关结构体,枚举及相关函数的声明。
(2)
固件库中对每个外设都提供了相关的例子程序及样板程序,这些程序对我们在做项目开发中是有很大的帮助的,我们可以从中找到许多相关问题的解答。
而且固件库中说明了不同开发平台的移植方法,具体见:
结束语:本人觉得还是官方提供的帮助文档所包含的信息量最大,其实好多问题都可以在相关的官方帮助文档中找到,可是因为都是英文的所以大部分的人都不想去读它,其实我想说的是,你可以不喜欢英语,但是最简单的你要有阅读英文文档的能力。我也是一位学生,刚刚入手的STM32,所以写的这些东西都只是我的个人想法,所以难免会有很多的错误。希望大家可以指出。不过我想我会坚持写下去的,我会在我的微博上和大家分享我学习STM32的经历。
2013年7月16日星期二
- STM32学习(一)—STM32固件库的使用
- STM32学习笔记一—初识STM32
- STM32学习——STM32 独立看门狗的使用
- stm32学习总结(二) STM32固件库的CMSIS简析
- STM32固件库的使用
- STM32学习总结(一)
- stm32串口学习(一)
- stm32学习记录(一)
- 菜鸟之学习STM32(一)暂停C51的复习,开始学习STM32
- stm32学习笔记一
- STM32学习过程一
- STM32学习笔记(一)-------GPIO口的操作
- STM32学习一:那些MDK5的坑
- 基于STM32的ESP8266使用教程(一)
- STM32学习笔记(一)----系统时钟
- stm32学习笔记(一) GPIO
- stm32 窗口看门狗学习(一)
- stm32 输入捕获学习(一)
- C++ primer读书笔记2(表达式)
- Android开机启动检测和连接wifi检测
- 如何在linux上用squid搭建代理服务器_足够详细
- javascript 中with用法
- [转载]计算机视觉领域的一些牛人博客
- STM32学习(一)—STM32固件库的使用
- LA 4255 Guess
- 在.net中使用sql存储过程
- mysql 函数错误
- iis服务器出现:[Microsoft][ODBC …
- ubuntu启动时开启或停止服务
- netbeans add tomcat server in ub…
- Myeclipse下web项目改名
- latex的中文支持