STM32示例代码中变量名开头的“uw”代表什么含义?
What does the
uw prefix mean in STM32 variable names? Great question! Those uw prefixes you're spotting follow STMicroelectronics' internal variable naming convention—a modified take on Hungarian notation tailored to their microcontroller architectures.
Breaking down the two letters:
u: Stands for unsigned—this tells you the variable holds an unsigned integer value, no negative numbers allowed.w: Stands for word—in STM32 terminology, a "word" refers to a 32-bit data type. This aligns perfectly with theuint32_ttype used in your examples (likestatic __IO uint32_t uwLsiFreq = 0;), sinceuint32_tis a 32-bit unsigned integer.
Putting it all together, a name like uwLsiFreq translates to "unsigned 32-bit word representing LSI frequency"—it's a quick way to grasp both the variable's data type and purpose just by looking at its name.
You might run into other similar prefixes in STM32 code too, such as:
uifor unsigned 16-bit integers (matchinguint16_t)ucfor unsigned 8-bit integers (matchinguint8_t)swfor signed 32-bit integers (matchingint32_t)
示例来源:STM32Cube_FW_F2_V1.7.0/Projects/STM32F207ZG-Nucleo/Examples/IWDG/IWDG_Example/Src/main.c
内容的提问来源于stack exchange,提问作者Gabriel Staples
相关产品推荐
相关产品推荐

