|
Naming conventions 4 j- j# u8 f( M! h" P. |1 A STM32库标识符命名规则5 ?# B! e4 E$ e: A7 g! ^% s% e The STM32F10x Standard Peripherals Library uses the following naming conventions: STM32F10x 标准外设库使用如下的命名规则1 X: `4 _! {8 @ PPP refers to any peripheral acronym, for example ADC. $ r6 V0 @% v( y2 M PPP表示外设缩写,比如ADC) Z# g* D7 W) p m' P4 U System and source/header file names are preceded by the prefix ‘stm32f10x_’. 1 N3 @1 {: g4 e1 |9 \+ D* \ 系统文件或者源文件以及头文件名以stm32f10x_作为前缀 6 Z1 z6 G3 n' x2 P# x Constants used in one file are defined within this file. A constant used in more than one file is defined in a header file. . R8 o" j X* ^ All constants are written in upper case. & Z% f2 n" O- ]) r7 j$ v+ R 常量:只在一个文件中使用的常量在该文件中定义,在多于一个文件中使用的常量在头文件中定义。所用常量名使用大写; j: c4 y% `/ \$ b Registers are considered as constants. Their names are in upper case. In most cases, the same acronyms as in the STM32F10x reference manual document are used. V, [2 s$ o& X3 ]' `, K" u$ [ 寄存器被考虑成常量。名字采用大写。绝大多数情况下,采用与STM32F10x参考手册中相同的缩写作为其名字。 2 C5 f6 v- z! b Names of peripheral’s functions are preceded by the corresponding peripheral acronym in upper case followed by an underscore. # l: J" Z' X+ X& w1 }# m The first letter in each word is in upper case, for example USART_SendData. Only one underscore is allowed in a function name to separate the peripheral acronym from the rest of the function name. 0 x6 i U1 A% x% A4 N: _5 Q 外设函数名采用相应的大写的外设缩写作为前缀,之后紧跟一个下划线(表示分割),每个词的首字母大写,函数名只允许只用一个下划线以分割函数外设缩写与函数名的其他部分。* G+ Q$ M% {2 C0 v' i 3 w+ C$ H/ b5 C u ' T: x8 B/ v. R1 w: E Functions used to initialize the PPP peripheral according to parameters specified in PPP_InitTypeDef are named PPP_Init, for example TIM_Init. 用于初始化PPP外设的函数命名为PPP_Init,PPP_Init函数根据在结构体PPP_InitTypeDef中指定的参数初始化PPP外设。 3 }8 t( e4 v' ~0 V" e Functions used to reset the PPP peripheral registers to their default values are named PPP_DeInit, for example TIM_DeInit. 用于将外设PPP复位为其默认值的函数命名为PPP_DeInit,例如TIM_DeInit.- @0 t' i9 g3 F: n$ ` Functions used to fill the PPP_InitTypeDef structure with the reset values of each member are named PPP_StructInit, for example USART_StructInit. 用于将PPP外设初始化结构体InitTypeDef填充为系统复位默认值的函数命名为PPP_StructInit,例如USART_StructInit Functions used to enable or disable the specified PPP peripheral are named PPP_Cmd, for example USART_Cmd. + n0 N, W8 X' T$ ?& E, ^0 c9 [ 用于禁止或者使能PPP外设的函数命名为PPP_Cmd,例如USART_Cmd.* c6 O. X0 k! ^! S 4 r* z* m4 M+ @' h9 d ] 3 B# v) o" `- A9 l Functions used to enable or disable an interrupt source of the specified PPP peripheral are named PPP_ITConfig, for example RCC_ITConfig. 用于禁止或者使能PPP外设中断源的函数命名为PPP_ITConfig,例如RCC_ITConfig.! k/ V, f4 c* \ ) ]( e1 O2 A& X' Q: L# |) E& m ! H/ s7 Z$ z# u/ k3 `4 u Functions used to enable or disable the DMA interface of the specified PPP peripheral are named PPP_DMAConfig, for example TIM_DMAConfig. 用于禁止或者使能PPP外设DMA接口的函数命名为PPP_DMAConfig,例如TIM_DMAConfig. ) ~/ E N# z: O Functions used to configure a peripheral function always end with the string ‘Config’, for example GPIO_PinRemapConfig. 用于配置外设功能的函数总是以字符串“Config”结束,例如GPIO_PinRemapConfig. 6 _& q) v' b9 q2 L+ T Functions used to check whether the specified PPP flag is set or reset are named PPP_GetFlagStatus, for example I2C_GetFlagStatus. / }/ L' E4 M( ]3 ^ J7 N 用于检查外设是否置位或者复位的函数命名为PPP_GetFlagStatus,例如I2CGetFlagStatus.' e+ t+ L+ J5 g . ?0 {0 Z5 Y) h$ u1 z# V1 J; x + z' N# b1 ~2 q; l3 D( F4 M4 S Functions used to clear a PPP flag are named PPP_ClearFlag, for example I2C_ClearFlag. 用于清除PPP外设标志位的函数命名为PPP_ClearFlag,例如I2C_ClearFlag.) m8 M& L6 a: s( e: w0 |8 l( T; d ' M _! m# Q* U5 } Functions used to check whether the specified PPP interrupt has occurred or not are named PPP_GetITStatus, for example I2C_GetITStatus. 用于检查PPP外设中断是否发生的函数命名为PPP_GetITStatus,例如I2C_GetITStatus.8 }/ t t* z& `- O7 P 3 g5 {! T- v& u* {, I* H, h5 E* { Functions used to clear a PPP interrupt pending bit are named PPP_ClearITPendingBit, for example I2C_ClearITPendingBit. 用于清除PPP外设待处理中断位的函数命名为PPP_ClearITPendingBit,例如I2C_ClearITPendingbit." y0 F) ]' J) P% Q0 c$ j g0 s- \ 1 |4 H+ P& x% l% | 4 j5 z" ?' Q7 G" d7 u 希望对初学者阅读库有帮助,翻译自STM32标准外设库3.5说明部分: g% A* `9 a% N U$ J, ? 另一方面,建议大家自己认真阅读这些英文,提高自己阅读手册的能力。阅读手册是你绕不过的“砍”- b1 F5 B4 K, h2 ^7 f / g+ U; T+ {1 ], W$ o( p( P 6 X! g# x( E7 u9 s6 Y2 Q 外设缩写 J+ ?% N% A, h& @ . p( T5 _' Y' y$ Q9 c# O" ~ ADC Analog/digital converter 3 i+ O) [' v4 X+ j9 v4 b 9 f/ K- p+ o I% W( Y + _5 k- `6 \. ^5 r* R BKP Backup registers " a: a/ E" H- V" o) Y8 T 9 z ~5 _* {( u" ?1 X4 h3 Q0 i0 H CAN Controller area network CEC " l# _6 C- T/ w9 S9 q* D0 M Consumer Electronics Control # S) A! [' ]/ v5 j6 W2 [& \3 W) g 6 z4 u7 X9 _" v: U4 b, f; { CRC / p+ b$ z: _0 l' n+ T1 e CRC calculation unit : o4 O$ e; i/ P% P, ? 0 S( @, I; c8 v. r q; z' h DAC Digital to analog converter " i, ~& o, T! L1 L/ x6 _ 2 v7 ? Q6 _ s/ x V& R* y8 D DBGMCU ; n3 U8 ~0 W5 k ^- E8 ] Debug MCU ; C% c1 L' k" m) R6 N6 Y1 q DMA # O! |/ ]# P; [- p( u* e" @5 T$ X DMA controller # _0 {, Y" D, c# { e : F+ K' k: p; q' C/ ^4 c EXTI / M0 {- f/ `4 N4 ^; _- D6 t' h External interrupt/event controller . F8 V9 X( e' \2 t ; c4 h. X1 t5 ^5 D. P' H% c) M# I/ a FSMC h8 L7 U- e( V0 x( a3 J Flexible static memory controller FLASH ' l+ Z2 j' P5 n: g2 z Flash memory ( ~3 y1 F4 s. J) [1 B# J & j/ g( M, n% d5 q GPIO + {8 b# a, H; J General purpose I/O " T& R7 I5 Z z" J4 J I2C Inter-integrated circuit " c8 J, d" ]4 m- l/ ]" U I2S Inter-integrated sound - m; M7 o/ m9 C/ S $ m: D8 V# u# \# x. ?1 D IWDG + i: y1 s! C! w/ [ Independent watchdog ' u8 s; |! r2 Y: H NVIC Nested vectored interrupt controller $ R" }' M# ?1 m; ^& N PWR Power controller RCC * l0 X5 M {: u3 C/ ^ Reset and clock controller & E) V7 Q! n& ` RTC Reset and clock controller 7 o% c- S4 ]* z1 M ) e& Y* l& @" l) T SDIO ! z) d- j! _/ C1 W0 U SDIO interface 1 ?: H1 l' B6 n+ K% z: y) q2 z9 Q SPI Serial peripheral interface 7 t0 c) m' V4 O6 @" C ) L' v( I- y6 o" _. {; n Y SysTick : N8 f8 P/ U3 p System tick timer TIM 6 w+ U2 ~, l3 }0 V" k Advanced-control, general-purpose or basic timer USART * P: W/ v7 e3 d' } Universal synchronous asynchronous receiver transmitter 2 y$ I: X) ^$ }0 G8 Q3 |- Q0 Z1 o WWDG Window watchdog |
微信公众号
手机版
一起学习,共同进步
水经验,你可以不看啊。