typedef struct { unsigned short b0:1; unsigned short b1:1; unsigned short b2:1; unsigned short b3:1; unsigned short b4:1; unsigned short b5:1; unsigned short b6:1; unsigned short b7:1; unsigned short b8:1; unsigned short b9:1; unsigned short b10:1; unsigned short b11:1; unsigned short b12:1; unsigned short b13:1; unsigned short b14:1; unsigned short b15:1; }REG16_TypeDef;
typedef struct { unsigned long b0:1; unsigned long b1:1; unsigned long b2:1; unsigned long b3:1; unsigned long b4:1; unsigned long b5:1; unsigned long b6:1; unsigned long b7:1; unsigned long b8:1; unsigned long b9:1; unsigned long b10:1; unsigned long b11:1; unsigned long b12:1; unsigned long b13:1; unsigned long b14:1; unsigned long b15:1; unsigned long b16:1; unsigned long b17:1; unsigned long b18:1; unsigned long b19:1; unsigned long b20:1; unsigned long b21:1; unsigned long b22:1; unsigned long b23:1; unsigned long b24:1; unsigned long b25:1; unsigned long b26:1; unsigned long b27:1; unsigned long b28:1; unsigned long b29:1; unsigned long b30:1; unsigned long b31:1; }REG32_TypeDef; //定义位域:R8(GPIOA->ODR)b0=1等同于GPIOA->ODR的bit0置1 #define R8(reg) ((volatile REG8_TypeDef*)&(reg))-> #define R16(reg) ((volatile REG16_TypeDef*)&(reg))-> #define R32(reg) ((volatile REG32_TypeDef*)&(reg))->
{
unsigned char b0:1;
unsigned char b1:1;
unsigned char b2:1;
unsigned char b3:1;
unsigned char b4:1;
unsigned char b5:1;
unsigned char b6:1;
unsigned char b7:1;
}REG8_TypeDef;
typedef struct
{
unsigned short b0:1;
unsigned short b1:1;
unsigned short b2:1;
unsigned short b3:1;
unsigned short b4:1;
unsigned short b5:1;
unsigned short b6:1;
unsigned short b7:1;
unsigned short b8:1;
unsigned short b9:1;
unsigned short b10:1;
unsigned short b11:1;
unsigned short b12:1;
unsigned short b13:1;
unsigned short b14:1;
unsigned short b15:1;
}REG16_TypeDef;
typedef struct
{
unsigned long b0:1;
unsigned long b1:1;
unsigned long b2:1;
unsigned long b3:1;
unsigned long b4:1;
unsigned long b5:1;
unsigned long b6:1;
unsigned long b7:1;
unsigned long b8:1;
unsigned long b9:1;
unsigned long b10:1;
unsigned long b11:1;
unsigned long b12:1;
unsigned long b13:1;
unsigned long b14:1;
unsigned long b15:1;
unsigned long b16:1;
unsigned long b17:1;
unsigned long b18:1;
unsigned long b19:1;
unsigned long b20:1;
unsigned long b21:1;
unsigned long b22:1;
unsigned long b23:1;
unsigned long b24:1;
unsigned long b25:1;
unsigned long b26:1;
unsigned long b27:1;
unsigned long b28:1;
unsigned long b29:1;
unsigned long b30:1;
unsigned long b31:1;
}REG32_TypeDef;
//定义位域:R8(GPIOA->ODR)b0=1等同于GPIOA->ODR的bit0置1
#define R8(reg) ((volatile REG8_TypeDef*)&(reg))->
#define R16(reg) ((volatile REG16_TypeDef*)&(reg))->
#define R32(reg) ((volatile REG32_TypeDef*)&(reg))->
应该通用的!!!
一周热门 更多>