【程序】
#include <stm32f10x.h>
#define _BV(n) (1 << (n))
uint8_t n = 0;
void delay()
{
    int i, j;
    for (i = 0; i < 1000; i++)
        for (j = 0; j < 1000; j++);
}
void init()
{
    int i;
    RCC->APB2ENR |= _BV(3); // 打开GPIOB的时钟
    
    // 把PB8~15都设置为输出模式
    for (i = 0; i < 8; i++)
    {
        GPIOB->CRH &= ~_BV(4 * i + 1);
        GPIOB->CRH |= _BV(4 * i);
    }
    
    GPIOB->ODR = 0x00; // 开始时关闭所有LED灯
}
int main()
{
    init();
    
    while (1)
    {
        delay();
        GPIOB->ODR = n << 8;
        n++;
    }
}
void SystemInit()
{
}
      