#define PERIPH_BASE ((unsigned int)0x40000000)
#define APB2PERIPH_BASE (PERIPH_BASE + 0x10000)
#define GPIOA_BASE (APB2PERIPH_BASE + 0x800)
typedef unsigned int uint32_t;
typedef unsigned short uint16_t;
typedef struct
{
uint32_t CRL;
uint32_t CRH;
uint32_t IDR;
uint32_t ODR;
uint32_t BSRR;
uint32_t BRR;
uint32_t LCKR;
}GPIO_TypeDef;
#define GPIOA ((GPIO_TypeDef*)(GPIOA_BASE))
这样写才是对的
#define GPIOA (GPIO_TypeDef*)(GPIOA_BASE)
这样写就会报错, 说GPIOA不是指针(error: member reference type ‘unsigned int’ is not a pointer )
还有
USER\main.c (42): error: #44: expression must have pointer type