[code]
#define PERIPH_BASE (unsigned int 0x40000000)
#define AHBPERIPH_BASE (PERIPH_BASE+20000)
#define APB2PERIPH_BASE (PERIPH_BASE+10000)
#define APB1PERIPH_BASE PERIPH_BASE
#define RCC_BASE (AHBPERIPH_BASE+1000)
#define GPIOB_BASE (AHBPERIPH_BASE+0X00)
#define RCC_APB2 *(unsigned int*)(RCC_BASE+0X18)
#define GPIOB_CRL *(unsigned int*)(GPIOB_BASE+0X00)
#define GPIOB_CRH *(unsigned int*)(GPIOB_BASE+0X04)
#define GPIOB_BSRR *(unsigned int*)(GPIOB_BASE+0X10)
#include "stm32f10x.h"
int main(void)
{
// 打开 GPIOB 端口的时钟
RCC_APB2 |= ( (1) << 3 );
// 配置IO口为输出
GPIOB_CRL &= ~( (0x0f) << (4*0) );
GPIOB_CRL |= ( (1) << (4*0) );
// 控制 ODR 寄存器
GPIOB_BSRR |= (1<<16);
}
void SystemInit(void)
{
} |