|
庫函數(shù):
#define PERIPH_BASE ((unsigned int)0x40000000)
#define APB1PERIPH_BASE PERIPH_BASE
#define APB2PERIPH_BASE (PERIPH_BASE+0x10000)
#define AHBPERIPH_BASE (PERIPH_BASE+0x20000)
#define RCC_BASE (AHBPERIPH_BASE+0x1000)
#define GPIOB_BASE (APB2PERIPH_BASE+0x0C00)
#define RCC_APB2ENR *(unsigned int*)(RCC_BASE+0x18)
#define GPIOB ((GPIO_TypeDef*)GPIOB_BASE)
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;
主函數(shù):
#include "stm32f10x.h"
int main(void)
{
GPIOB->ODR |=((1)<<(4*0));
//打開GPIOB端口時(shí)鐘
RCC_APB2ENR |= ((1)<< 3 );
}
void SystemInit()
{
//do nothing
}
報(bào)錯(cuò)main.c(6): error: #20: identifier "GPIO_TypeDef" is undefined
這是什么情況?庫函數(shù)編譯沒有錯(cuò),主函數(shù)里加入GPIOB就報(bào)錯(cuò),時(shí)鐘是對的
|
|