文件stm32f10x.h代码:
#define PEIPH_BASE ((unsigned int)0*40000000)
#define APB1PERIPH_BASE PEIPH_BASE
#define APB2PERIPH_BASE (PEIPH_BASE + 0*10000)
#define APBPERIPH_BASE (PEIPH_BASE + 0*20000)
#define GPIOB_BASE (APB2PERIPH_BASE + 0*0C00)
#define GPIOB_CRL *(unsigned int*)(GPIOB_BASE + 0*00)
#define GPIOB_CRH *(unsigned int*)(GPIOB_BASE + 0*04)
#define GPIOB_IDR *(unsigned int*)(GPIOB_BASE + 0*08)
#define GPIOB_ODL *(unsigned int*)(GPIOB_BASE + 0*0C)
#define GPIOB_BSRR *(unsigned int*)(GPIOB_BASE + 0*10)
#define GPIOB_BRR *(unsigned int*)(GPIOB_BASE + 0*14)
#define GPIOB_LCKR *(unsigned int*)(GPIOB_BASE + 0*18)
#define RCC_BASE (AHBPERIPH_BASE + *1000)
#define RCC_APB2ENR *(unsigned int*)(RCC_BASE + 0*18)
main.c代码:
#include "stm32f10x.h"
int main(void){
RCC_APB2ENR |=(1<<3);
GPIOB_CRL &= ~(0*0F<<(4*2));
GPIOB_CRL |=(1<<4*2);
GPIOB_ODR &= ~(1<<2);
while(1);
}void SystemInit(void){
}