1、IO输出
led.c
#include <stm32f10x_lib.h>
#include "led.h"
//初始输出口.并使能这两个口的时钟
//LED IO初始化
void LED_Init(void)
{
RCC->APB2ENR|=1<<2;    //使能PORTA时钟
RCC->APB2ENR|=1<<3;    //使能PORTB时钟
GPIOA->CRL|=0X00000300;//PA2 推挽输出  
   GPIOA->ODR|=1<<2;      //PA2 输出高
GPIOA->CRL|=0X00003000;//PA3 推挽输出  
   GPIOA->ODR|=1<<3;      //PA3 输出高
GPIOB->CRL|=0X00003000;//PB3 推挽输出  
   GPIOB->ODR|=1<<3;      //PB3 输出高
}
led.h
#ifndef __LED_H
#define __LED_H
#include "sys.h"
//LED端口定义
#define LED0 PAout(2)// PA2
#define LED1 PAout(3)// PA3
#define LED2 PBout(2)// PB2
void LED_Init(void);//初始化
#endif