51 typedef volatile unsigned char const vuc8; /* Read Only */
3.0以后的版本中使用了CMSIS數(shù)據(jù)類型,變量的定義有所不同,但是出于兼容舊版本的目的,以上的數(shù)據(jù)類型仍然兼容。CMSIS的IO類型限定詞如表 57所示,CMSIS和STM32固件庫的數(shù)據(jù)類型對比如表 58所示。這些數(shù)據(jù)類型可以在STM32F10x_StdPeriph_Lib_V3.4.0\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\stm32f10x.h中找到具體的定義,此部分定義如下。
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 */
表 57 CMSIS IO類型限定詞
IO類限定詞 #define 描述 _I volatile const 只讀訪問 _O volatile 只寫訪問 _IO volatile 讀和寫訪問
表 58 固件庫與CMSIS數(shù)據(jù)類型對比
固件庫類型 CMSIS類型 描述 s32 int32_t 易揮發(fā)只讀有符號32位數(shù)據(jù) s16 int16_t 易揮發(fā)只讀有符號16位數(shù)據(jù) s8 int8_t 易揮發(fā)只讀有符號8位數(shù)據(jù) sc32 const int32_t 只讀有符號32位數(shù)據(jù) sc16 const int16_t 只讀有符號16位數(shù)據(jù) sc8 const int8_t 只讀有符號8位數(shù)據(jù) vs32 _IO int32_t 易揮發(fā)讀寫訪問有符號32位數(shù)據(jù) vs16 _IO int16_t 易揮發(fā)讀寫訪問有符號16位數(shù)據(jù) vs8 _IO int8_t 易揮發(fā)讀寫訪問有符號8位數(shù)據(jù) vsc32 _I int32_t 易揮發(fā)只讀有符號32位數(shù)據(jù) vsc16 _I int16_t 易揮發(fā)只讀有符號16位數(shù)據(jù) vsc8 _I int8_t 易揮發(fā)只讀有符號8位數(shù)據(jù) u32 uint32_t 無符號32位數(shù)據(jù) u16 uint16_t 無符號16位數(shù)據(jù) u8 uint8_t 無符號8位數(shù)據(jù) uc32 const uint32_t 只讀無符號32位數(shù)據(jù) uc16 const uint16_t 只讀無符號16位數(shù)據(jù) uc8 const uint8_t 只讀無符號8位數(shù)據(jù) vu32 _IO uint32_t 易揮發(fā)讀寫訪問無符號32位數(shù)據(jù) vu16 _IO uint16_t 易揮發(fā)讀寫訪問無符號16位數(shù)據(jù) vu8 _IO uint8_t 易揮發(fā)讀寫訪問無符號8位數(shù)據(jù) vuc32 _I uint32_t 易揮發(fā)只讀無符號32位數(shù)據(jù) vuc16 _I uint16_t 易揮發(fā)只讀無符號16位數(shù)據(jù) vuc8 _I uint8_t 易揮發(fā)只讀無符號8位數(shù)據(jù)
stm32f10x.h文件中還包含了常用的布爾形變量定義,如:
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;
評論
查看更多