好文档 - 专业文书写作范文服务资料分享网站

STM32固件库详解

天下 分享 时间: 加入收藏 我要投稿 点赞

41 typedef volatile unsigned long vu32; 42

43 typedef volatile unsigned short vu16; 44

45 typedef volatile unsigned char vu8; 46

47 typedef volatile unsigned long const vuc32; /* Read Only */ 48

49 typedef volatile unsigned short const vuc16; /* Read Only */ 50

51 typedef volatile unsigned char const vuc8; /* Read Only */

以后的版本中使用了CMSIS数据类型,变量的定义有所不同,但是出于兼容旧版本的目的,以上的数据类型仍然兼容。CMSIS的IO类型限定词如表 5-7所示,CMSIS和STM32固件库的数据类型对比如表 5-8所示。这些数据类型可以在中找到具体的定义,此部分定义如下。

1 /*!< STM32F10x Standard Peripheral Library old types (maintained for legacy purpose) */ 2

3 typedef int32_t s32; 4

5 typedef int16_t s16; 6

7 typedef int8_t s8; 8

9 typedef const int32_t sc32; /*!< Read Only */ 10

11 typedef const int16_t sc16; /*!< Read Only */ 12

13 typedef const int8_t sc8; /*!< Read Only */ 14

15 typedef __IO int32_t vs32; 16

17 typedef __IO int16_t vs16; 18

19 typedef __IO int8_t vs8; 20

21 typedef __I int32_t vsc32; /*!< Read Only */ 22

23 typedef __I int16_t vsc16; /*!< Read Only */ 24

25 typedef __I int8_t vsc8; /*!< Read Only */ 26

27 typedef uint32_t u32; 28

29 typedef uint16_t u16; 30

31 typedef uint8_t u8; 32

33 typedef const uint32_t uc32; /*!< Read Only */ 34

35 typedef const uint16_t uc16; /*!< Read Only */

36

37 typedef const uint8_t uc8; /*!< Read Only */ 38

39 typedef __IO uint32_t vu32; 40

41 typedef __IO uint16_t vu16; 42

43 typedef __IO uint8_t vu8; 44

45 typedef __I uint32_t vuc32; /*!< Read Only */ 46

47 typedef __I uint16_t vuc16; /*!< Read Only */ 48

49 typedef __I uint8_t vuc8; /*!< Read Only */

表 5-7 CMSIS IO类型限定词 IO类限定词 _I _O _IO #define volatile const volatile volatile 描述 只读访问 只写访问 读和写访问 表 5-8 固件库与CMSIS数据类型对比 固件库类型 CMSIS类型 描述 s32 s16 int32_t int16_t 易挥发只读有符号32位数据 易挥发只读有符号16位数据 s8 sc32 sc16 sc8 vs32 vs16 vs8 int8_t const int32_t const int16_t const int8_t _IO int32_t _IO int16_t _IO int8_t 易挥发只读有符号8位数据 只读有符号32位数据 只读有符号16位数据 只读有符号8位数据 易挥发读写访问有符号32位数据 易挥发读写访问有符号16位数据 易挥发读写访问有符号8位数据 vsc32 vsc16 _I int32_t _I int16_t 易挥发只读有符号32位数据 易挥发只读有符号16位数据 vsc8 u32 u16 _I int8_t uint32_t uint16_t 易挥发只读有符号8位数据 无符号32位数据 无符号16位数据 u8 uc32 uc16 uint8_t const uint32_t const uint16_t 无符号8位数据 只读无符号32位数据 只读无符号16位数据 uc8 vu32 const uint8_t _IO uint32_t 只读无符号8位数据 易挥发读写访问无符号32位数据 vu16 vu8 vuc32 vuc16 vuc8 _IO uint16_t _IO uint8_t _I uint32_t _I uint16_t _I uint8_t 易挥发读写访问无符号16位数据 易挥发读写访问无符号8位数据 易挥发只读无符号32位数据 易挥发只读无符号16位数据 易挥发只读无符号8位数据 文件中还包含了常用的布尔形变量定义,如:

1 typedef enum {RESET = 0, SET = !RESET} FlagStatus, ITStatus; 2

3 typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState; 4

5 #define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE)) 6

7 typedef enum {ERROR = 0, SUCCESS = !ERROR} ErrorStatus;

不同版本的标准外设库的变量定义略有不同,如版本中就没有之前版本的TRUE和FALSE的定义,用户也可以根据自己的需求按照上面的格式定义自己的布尔形变量。在使用标准外设库进行开发遇到相关的定义问题时应首先找到对应的头文件定义。

4. 使用步骤

STM32固件库详解

41typedefvolatileunsignedlongvu32;4243typedefvolatileunsignedshortvu16;4445typedefvolatileunsignedcharvu8;4647typedefvolatileunsignedlongconstvuc3
推荐度:
点击下载文档文档为doc格式
332v18t3o5797950lpza3sk4u09qt500fjy
领取福利

微信扫码领取福利

微信扫码分享