另外,对ST的一些寄存器定义也不大习惯,所以也重新做了定义,例如GPIOx_BSRR我另外定义了一个GPIOx_SET,
GPIOx_BRR我另外定义了一个GPIOx_CLR,这样自己记起来轻松多了——男人何必为难自己呢...
看看这个流水灯的程序,看上去是不是容易些了呢……
void main(void)
{
//使能PORTC时钟
RCC_APB2ENR |=(1<<4);
//4个LED连接在PORTC4~7上,将这4个IO设置为50MHz输出口
//GPIOC4
GPIOC_MODE4=3; //50MHz 输出模式
GPIOC_CNF4=0; //通用推挽模式
//GPIOC5
GPIOC_MODE5=3; //50MHz 输出模式
GPIOC_CNF5=0; //通用推挽模式
//GPIO6
GPIOC_MODE6=3; //50MHz 输出模式
GPIOC_CNF6=0; //通用推挽模式
//GPIO7
GPIOC_MODE7=3; //50MHz 输出模式
GPIOC_CNF7=0; //通用推挽模式
//4个LED,当IO口为高电平时LED亮
while(1)
{
GPIOC_CLR=(1<<4); //灭 LED5
GPIOC_SET=(1<<7); //亮 LED2
Delay();
GPIOC_CLR=(1<<7); //灭 LED2
GPIOC_SET=(1<<6); //亮 LED3
Delay();
GPIOC_CLR=(1<<6); //灭 LED3
GPIOC_SET=(1<<5); //亮 LED4
Delay();
GPIOC_CLR=(1<<5); //灭 LED4
GPIOC_SET=(1<<4); //亮 LED5
Delay();
}
}
头文件GPIO.h的内容如下:
#ifndef __GPIO_H__
#define __GPIO_H__
//GPIOx base address
#define GPIOA_BASE 0x40010800
#define GPIOB_BASE 0x40010C00
#define GPIOC_BASE 0x40011000
#define GPIOD_BASE 0x40011400
#define GPIOE_BASE 0x40011800
//Port configuration register low (GPIOx_CRL) (x=A..E)
//Bits 29:28, 25:24, 21:20, 17:16, 13:12, 9:8, 5:4, 1:0
//MODEy[1:0]: Port x mode bits (y= 0 .. 7)
//These bits are written by software to configure the corresponding I/O port.
//00: Input mode (reset state)
//01: Output mode, max speed 10 MHz.
//10: Output mode, max speed 2 MHz.
//11: Output mode, max speed 50 MHz.
//Bits 31:30, 27:26, 23:22, 19:18, 15:14, 11:10, 7:6, 3:2
//CNFy[1:0]: Port x configuration bits (y= 0 .. 7)
//These bits are written by software to configure the corresponding I/O port.
//In input mode (MODE[1:0]=00):
//00: Analog input mode
//01: Floating input (reset state)
//10: Input with pull-up / pull-down
//11: Reserved
//In output mode (MODE[1:0] > 00):
//00: General purpose output push-pull
//01: General purpose output Open-drain
//10: Alternate function output Push-pull
//11: Alternate function output Open-drain
#define GPIOA_CRL (*((volatile unsigned int *)(GPIOA_BASE+0x00)))
#define GPIOB_CRL (*((volatile unsigned int *)(GPIOB_BASE+0x00)))
#define GPIOC_CRL (*((volatile unsigned int *)(GPIOC_BASE+0x00)))
#define GPIOD_CRL (*((volatile unsigned int *)(GPIOD_BASE+0x00)))
#define GPIOE_CRL (*((volatile unsigned int *)(GPIOE_BASE+0x00)))
//Port configuration register high (GPIOx_CRH) (x=A..E)
//Bits 29:28, 25:24, 21:20, 17:16, 13:12, 9:8, 5:4, 1:0
//MODEy[1:0]: Port x mode bits (y= 8 .. 15)
//These bits are written by software to configure the corresponding I/O port.
//00: Input mode (reset state)
//01: Output mode, max speed 10 MHz.
//10: Output mode, max speed 2 MHz.
//11: Output mode, max speed 50 MHz.
//Bits 31:30, 27:26, 23:22, 19:18, 15:14, 11:10, 7:6, 3:2
//CNFy[1:0]: Port x configuration bits (y= 8 .. 15)
//These bits are written by software to configure the corresponding I/O port.
//In input mode (MODE[1:0]=00):
//00: Analog input mode
//01: Floating input (reset state)
//10: Input with pull-up / pull-down
//11: Reserved
//In output mode (MODE[1:0] > 00):
//00: General purpose output push-pull
//01: General purpose output Open-drain
//10: Alternate function output Push-pull
//11: Alternate function output Open-drain
#define GPIOA_CRH (*((volatile unsigned int *)(GPIOA_BASE+0x04)))
#define GPIOB_CRH (*((volatile unsigned int *)(GPIOB_BASE+0x04)))
#define GPIOC_CRH (*((volatile unsigned int *)(GPIOC_BASE+0x04)))
#define GPIOD_CRH (*((volatile unsigned int *)(GPIOD_BASE+0x04)))
#define GPIOE_CRH (*((volatile unsigned int *)(GPIOE_BASE+0x04)))
//Port input data register (GPIOx_IDR) (x=A..E)
#define GPIOA_IDR (*((volatile unsigned int *)(GPIOA_BASE+0x08)))
#define GPIOB_IDR (*((volatile unsigned int *)(GPIOB_BASE+0x08)))
#define GPIOC_IDR (*((volatile unsigned int *)(GPIOC_BASE+0x08)))
#define GPIOD_IDR (*((volatile unsigned int *)(GPIOD_BASE+0x08)))
#define GPIOE_IDR (*((volatile unsigned int *)(GPIOE_BASE+0x08)))
//Port output data register (GPIOx_ODR) (x=A..E)
#define GPIOA_ODR (*((volatile unsigned int *)(GPIOA_BASE+0x0C)))
#define GPIOB_ODR (*((volatile unsigned int *)(GPIOB_BASE+0x0C)))
#define GPIOC_ODR (*((volatile unsigned int *)(GPIOC_BASE+0x0C)))
#define GPIOD_ODR (*((volatile unsigned int *)(GPIOD_BASE+0x0C)))
#define GPIOE_ODR (*((volatile unsigned int *)(GPIOE_BASE+0x0C)))
//Port bit set/reset register (GPIOx_BSRR) (x=A..E)
#define GPIOA_BSRR (*((volatile unsigned int *)(GPIOA_BASE+0x10)))
#define GPIOB_BSRR (*((volatile unsigned int *)(GPIOB_BASE+0x10)))
#define GPIOC_BSRR (*((volatile unsigned int *)(GPIOC_BASE+0x10)))
#define GPIOD_BSRR (*((volatile unsigned int *)(GPIOD_BASE+0x10)))
#define GPIOE_BSRR (*((volatile unsigned int *)(GPIOE_BASE+0x10)))
//Port bit reset register (GPIOx_BRR) (x=A..E)
#define GPIOA_BRR (*((volatile unsigned int *)(GPIOA_BASE+0x14)))
#define GPIOB_BRR (*((volatile unsigned int *)(GPIOB_BASE+0x14)))
#define GPIOC_BRR (*((volatile unsigned int *)(GPIOC_BASE+0x14)))
#define GPIOD_BRR (*((volatile unsigned int *)(GPIOD_BASE+0x14)))
#define GPIOE_BRR (*((volatile unsigned int *)(GPIOE_BASE+0x14)))
//Port configuration lock register (GPIOx_LCKR) (x=A..E)
#define GPIOA_LCKR (*((volatile unsigned int *)(GPIOA_BASE+0x18)))
#define GPIOB_LCKR (*((volatile unsigned int *)(GPIOB_BASE+0x18)))
#define GPIOC_LCKR (*((volatile unsigned int *)(GPIOC_BASE+0x18)))
#define GPIOD_LCKR (*((volatile unsigned int *)(GPIOD_BASE+0x18)))
#define GPIOE_LCKR (*((volatile unsigned int *)(GPIOE_BASE+0x18)))
//Bit field of GPIOx_CRL and GPIOx_CRH
typedef struct bGPIOx_CRL
{
unsigned int MODE0 :2;
unsigned int CNF0 :2;
unsigned int MODE1 :2;
unsigned int CNF1 :2;
unsigned int MODE2 :2;
unsigned int CNF2 :2;
unsigned int MODE3 :2;
unsigned int CNF3 :2;
unsigned int MODE4 :2;
unsigned int CNF4 :2;
unsigned int MODE5 :2;
unsigned int CNF5 :2;
unsigned int MODE6 :2;
unsigned int CNF6 :2;
unsigned int MODE7 :2;
unsigned int CNF7 :2;
}bGPIOx_CRL;
typedef struct bGPIOx_CRH
{
unsigned int MODE8 :2;
unsigned int CNF8 :2;
unsigned int MODE9 :2;
unsigned int CNF9 :2;
unsigned int MODE10 :2;
unsigned int CNF10 :2;
unsigned int MODE11 :2;
unsigned int CNF11 :2;
unsigned int MODE12 :2;
unsigned int CNF12 :2;
unsigned int MODE13 :2;
unsigned int CNF13 :2;
unsigned int MODE14 :2;
unsigned int CNF14 :2;
unsigned int MODE15 :2;
unsigned int CNF15 :2;
}bGPIOx_CRH;
//GPIOA MODE
#define GPIOA_MODE0 (((volatile bGPIOx_CRL *)(&GPIOA_CRL))->MODE0)
#define GPIOA_MODE1 (((volatile bGPIOx_CRL *)(&GPIOA_CRL))->MODE1)
#define GPIOA_MODE2 (((volatile bGPIOx_CRL *)(&GPIOA_CRL))->MODE2)
#define GPIOA_MODE3 (((volatile bGPIOx_CRL *)(&GPIOA_CRL))->MODE3)
#define GPIOA_MODE4 (((volatile bGPIOx_CRL *)(&GPIOA_CRL))->MODE4)
#define GPIOA_MODE5 (((volatile bGPIOx_CRL *)(&GPIOA_CRL))->MODE5)
#define GPIOA_MODE6 (((volatile bGPIOx_CRL *)(&GPIOA_CRL))->MODE6)
#define GPIOA_MODE7 (((volatile bGPIOx_CRL *)(&GPIOA_CRL))->MODE7)
#define GPIOA_MODE8 (((volatile bGPIOx_CRH *)(&GPIOA_CRH))->MODE8)
#define GPIOA_MODE9 (((volatile bGPIOx_CRH *)(&GPIOA_CRH))->MODE9)
#define GPIOA_MODE10 (((volatile bGPIOx_CRH *)(&GPIOA_CRH))->MODE10)
#define GPIOA_MODE11 (((volatile bGPIOx_CRH *)(&GPIOA_CRH))->MODE11)
#define GPIOA_MODE12 (((volatile bGPIOx_CRH *)(&GPIOA_CRH))->MODE12)
#define GPIOA_MODE13 (((volatile bGPIOx_CRH *)(&GPIOA_CRH))->MODE13)
#define GPIOA_MODE14 (((volatile bGPIOx_CRH *)(&GPIOA_CRH))->MODE14)
#define GPIOA_MODE15 (((volatile bGPIOx_CRH *)(&GPIOA_CRH))->MODE15)
//GPIOA CNF(Configuration)
#define GPIOA_CNF0 (((volatile bGPIOx_CRL *)(&GPIOA_CRL))->CNF0)
#define GPIOA_CNF1 (((volatile bGPIOx_CRL *)(&GPIOA_CRL))->CNF1)
#define GPIOA_CNF2 (((volatile bGPIOx_CRL *)(&GPIOA_CRL))->CNF2)
#define GPIOA_CNF3 (((volatile bGPIOx_CRL *)(&GPIOA_CRL))->CNF3)
#define GPIOA_CNF4 (((volatile bGPIOx_CRL *)(&GPIOA_CRL))->CNF4)
#define GPIOA_CNF5 (((volatile bGPIOx_CRL *)(&GPIOA_CRL))->CNF5)
#define GPIOA_CNF6 (((volatile bGPIOx_CRL *)(&GPIOA_CRL))->CNF6)
#define GPIOA_CNF7 (((volatile bGPIOx_CRL *)(&GPIOA_CRL))->CNF7)
#define GPIOA_CNF8 (((volatile bGPIOx_CRH *)(&GPIOA_CRH))->CNF8)
#define GPIOA_CNF9 (((volatile bGPIOx_CRH *)(&GPIOA_CRH))->CNF9)
#define GPIOA_CNF10 (((volatile bGPIOx_CRH *)(&GPIOA_CRH))->CNF10)
#define GPIOA_CNF11 (((volatile bGPIOx_CRH *)(&GPIOA_CRH))->CNF11)
#define GPIOA_CNF12 (((volatile bGPIOx_CRH *)(&GPIOA_CRH))->CNF12)
#define GPIOA_CNF13 (((volatile bGPIOx_CRH *)(&GPIOA_CRH))->CNF13)
#define GPIOA_CNF14 (((volatile bGPIOx_CRH *)(&GPIOA_CRH))->CNF14)
#define GPIOA_CNF15 (((volatile bGPIOx_CRH *)(&GPIOA_CRH))->CNF15)
//GPIOB MODE
#define GPIOB_MODE0 (((volatile bGPIOx_CRL *)(&GPIOB_CRL))->MODE0)
#define GPIOB_MODE1 (((volatile bGPIOx_CRL *)(&GPIOB_CRL))->MODE1)
#define GPIOB_MODE2 (((volatile bGPIOx_CRL *)(&GPIOB_CRL))->MODE2)
#define GPIOB_MODE3 (((volatile bGPIOx_CRL *)(&GPIOB_CRL))->MODE3)
#define GPIOB_MODE4 (((volatile bGPIOx_CRL *)(&GPIOB_CRL))->MODE4)
#define GPIOB_MODE5 (((volatile bGPIOx_CRL *)(&GPIOB_CRL))->MODE5)
#define GPIOB_MODE6 (((volatile bGPIOx_CRL *)(&GPIOB_CRL))->MODE6)
#define GPIOB_MODE7 (((volatile bGPIOx_CRL *)(&GPIOB_CRL))->MODE7)
#define GPIOB_MODE8 (((volatile bGPIOx_CRH *)(&GPIOB_CRH))->MODE8)
#define GPIOB_MODE9 (((volatile bGPIOx_CRH *)(&GPIOB_CRH))->MODE9)
#define GPIOB_MODE10 (((volatile bGPIOx_CRH *)(&GPIOB_CRH))->MODE10)
#define GPIOB_MODE11 (((volatile bGPIOx_CRH *)(&GPIOB_CRH))->MODE11)
#define GPIOB_MODE12 (((volatile bGPIOx_CRH *)(&GPIOB_CRH))->MODE12)
#define GPIOB_MODE13 (((volatile bGPIOx_CRH *)(&GPIOB_CRH))->MODE13)
#define GPIOB_MODE14 (((volatile bGPIOx_CRH *)(&GPIOB_CRH))->MODE14)
#define GPIOB_MODE15 (((volatile bGPIOx_CRH *)(&GPIOB_CRH))->MODE15)
//GPIOB CNF(Configuration)
#define GPIOB_CNF0 (((volatile bGPIOx_CRL *)(&GPIOB_CRL))->CNF0)
#define GPIOB_CNF1 (((volatile bGPIOx_CRL *)(&GPIOB_CRL))->CNF1)
#define GPIOB_CNF2 (((volatile bGPIOx_CRL *)(&GPIOB_CRL))->CNF2)
#define GPIOB_CNF3 (((volatile bGPIOx_CRL *)(&GPIOB_CRL))->CNF3)
#define GPIOB_CNF4 (((volatile bGPIOx_CRL *)(&GPIOB_CRL))->CNF4)
#define GPIOB_CNF5 (((volatile bGPIOx_CRL *)(&GPIOB_CRL))->CNF5)
#define GPIOB_CNF6 (((volatile bGPIOx_CRL *)(&GPIOB_CRL))->CNF6)
#define GPIOB_CNF7 (((volatile bGPIOx_CRL *)(&GPIOB_CRL))->CNF7)
#define GPIOB_CNF8 (((volatile bGPIOx_CRH *)(&GPIOB_CRH))->CNF8)
#define GPIOB_CNF9 (((volatile bGPIOx_CRH *)(&GPIOB_CRH))->CNF9)
#define GPIOB_CNF10 (((volatile bGPIOx_CRH *)(&GPIOB_CRH))->CNF10)
#define GPIOB_CNF11 (((volatile bGPIOx_CRH *)(&GPIOB_CRH))->CNF11)
#define GPIOB_CNF12 (((volatile bGPIOx_CRH *)(&GPIOB_CRH))->CNF12)
#define GPIOB_CNF13 (((volatile bGPIOx_CRH *)(&GPIOB_CRH))->CNF13)
#define GPIOB_CNF14 (((volatile bGPIOx_CRH *)(&GPIOB_CRH))->CNF14)
#define GPIOB_CNF15 (((volatile bGPIOx_CRH *)(&GPIOB_CRH))->CNF15)
//GPIOC MODE
#define GPIOC_MODE0 (((volatile bGPIOx_CRL *)(&GPIOC_CRL))->MODE0)
#define GPIOC_MODE1 (((volatile bGPIOx_CRL *)(&GPIOC_CRL))->MODE1)
#define GPIOC_MODE2 (((volatile bGPIOx_CRL *)(&GPIOC_CRL))->MODE2)
#define GPIOC_MODE3 (((volatile bGPIOx_CRL *)(&GPIOC_CRL))->MODE3)
#define GPIOC_MODE4 (((volatile bGPIOx_CRL *)(&GPIOC_CRL))->MODE4)
#define GPIOC_MODE5 (((volatile bGPIOx_CRL *)(&GPIOC_CRL))->MODE5)
#define GPIOC_MODE6 (((volatile bGPIOx_CRL *)(&GPIOC_CRL))->MODE6)
#define GPIOC_MODE7 (((volatile bGPIOx_CRL *)(&GPIOC_CRL))->MODE7)
#define GPIOC_MODE8 (((volatile bGPIOx_CRH *)(&GPIOC_CRH))->MODE8)
#define GPIOC_MODE9 (((volatile bGPIOx_CRH *)(&GPIOC_CRH))->MODE9)
#define GPIOC_MODE10 (((volatile bGPIOx_CRH *)(&GPIOC_CRH))->MODE10)
#define GPIOC_MODE11 (((volatile bGPIOx_CRH *)(&GPIOC_CRH))->MODE11)
#define GPIOC_MODE12 (((volatile bGPIOx_CRH *)(&GPIOC_CRH))->MODE12)
#define GPIOC_MODE13 (((volatile bGPIOx_CRH *)(&GPIOC_CRH))->MODE13)
#define GPIOC_MODE14 (((volatile bGPIOx_CRH *)(&GPIOC_CRH))->MODE14)
#define GPIOC_MODE15 (((volatile bGPIOx_CRH *)(&GPIOC_CRH))->MODE15)
//GPIOC CNF(Configuration)
#define GPIOC_CNF0 (((volatile bGPIOx_CRL *)(&GPIOC_CRL))->CNF0)
#define GPIOC_CNF1 (((volatile bGPIOx_CRL *)(&GPIOC_CRL))->CNF1)
#define GPIOC_CNF2 (((volatile bGPIOx_CRL *)(&GPIOC_CRL))->CNF2)
#define GPIOC_CNF3 (((volatile bGPIOx_CRL *)(&GPIOC_CRL))->CNF3)
#define GPIOC_CNF4 (((volatile bGPIOx_CRL *)(&GPIOC_CRL))->CNF4)
#define GPIOC_CNF5 (((volatile bGPIOx_CRL *)(&GPIOC_CRL))->CNF5)
#define GPIOC_CNF6 (((volatile bGPIOx_CRL *)(&GPIOC_CRL))->CNF6)
#define GPIOC_CNF7 (((volatile bGPIOx_CRL *)(&GPIOC_CRL))->CNF7)
#define GPIOC_CNF8 (((volatile bGPIOx_CRH *)(&GPIOC_CRH))->CNF8)
#define GPIOC_CNF9 (((volatile bGPIOx_CRH *)(&GPIOC_CRH))->CNF9)
#define GPIOC_CNF10 (((volatile bGPIOx_CRH *)(&GPIOC_CRH))->CNF10)
#define GPIOC_CNF11 (((volatile bGPIOx_CRH *)(&GPIOC_CRH))->CNF11)
#define GPIOC_CNF12 (((volatile bGPIOx_CRH *)(&GPIOC_CRH))->CNF12)
#define GPIOC_CNF13 (((volatile bGPIOx_CRH *)(&GPIOC_CRH))->CNF13)
#define GPIOC_CNF14 (((volatile bGPIOx_CRH *)(&GPIOC_CRH))->CNF14)
#define GPIOC_CNF15 (((volatile bGPIOx_CRH *)(&GPIOC_CRH))->CNF15)
//GPIOD MODE
#define GPIOD_MODE0 (((volatile bGPIOx_CRL *)(&GPIOD_CRL))->MODE0)
#define GPIOD_MODE1 (((volatile bGPIOx_CRL *)(&GPIOD_CRL))->MODE1)
#define GPIOD_MODE2 (((volatile bGPIOx_CRL *)(&GPIOD_CRL))->MODE2)
#define GPIOD_MODE3 (((volatile bGPIOx_CRL *)(&GPIOD_CRL))->MODE3)
#define GPIOD_MODE4 (((volatile bGPIOx_CRL *)(&GPIOD_CRL))->MODE4)
#define GPIOD_MODE5 (((volatile bGPIOx_CRL *)(&GPIOD_CRL))->MODE5)
#define GPIOD_MODE6 (((volatile bGPIOx_CRL *)(&GPIOD_CRL))->MODE6)
#define GPIOD_MODE7 (((volatile bGPIOx_CRL *)(&GPIOD_CRL))->MODE7)
#define GPIOD_MODE8 (((volatile bGPIOx_CRH *)(&GPIOD_CRH))->MODE8)
#define GPIOD_MODE9 (((volatile bGPIOx_CRH *)(&GPIOD_CRH))->MODE9)
#define GPIOD_MODE10 (((volatile bGPIOx_CRH *)(&GPIOD_CRH))->MODE10)
#define GPIOD_MODE11 (((volatile bGPIOx_CRH *)(&GPIOD_CRH))->MODE11)
#define GPIOD_MODE12 (((volatile bGPIOx_CRH *)(&GPIOD_CRH))->MODE12)
#define GPIOD_MODE13 (((volatile bGPIOx_CRH *)(&GPIOD_CRH))->MODE13)
#define GPIOD_MODE14 (((volatile bGPIOx_CRH *)(&GPIOD_CRH))->MODE14)
#define GPIOD_MODE15 (((volatile bGPIOx_CRH *)(&GPIOD_CRH))->MODE15)
//GPIOD CNF(Configuration)
#define GPIOD_CNF0 (((volatile bGPIOx_CRL *)(&GPIOD_CRL))->CNF0)
#define GPIOD_CNF1 (((volatile bGPIOx_CRL *)(&GPIOD_CRL))->CNF1)
#define GPIOD_CNF2 (((volatile bGPIOx_CRL *)(&GPIOD_CRL))->CNF2)
#define GPIOD_CNF3 (((volatile bGPIOx_CRL *)(&GPIOD_CRL))->CNF3)
#define GPIOD_CNF4 (((volatile bGPIOx_CRL *)(&GPIOD_CRL))->CNF4)
#define GPIOD_CNF5 (((volatile bGPIOx_CRL *)(&GPIOD_CRL))->CNF5)
#define GPIOD_CNF6 (((volatile bGPIOx_CRL *)(&GPIOD_CRL))->CNF6)
#define GPIOD_CNF7 (((volatile bGPIOx_CRL *)(&GPIOD_CRL))->CNF7)
#define GPIOD_CNF8 (((volatile bGPIOx_CRH *)(&GPIOD_CRH))->CNF8)
#define GPIOD_CNF9 (((volatile bGPIOx_CRH *)(&GPIOD_CRH))->CNF9)
#define GPIOD_CNF10 (((volatile bGPIOx_CRH *)(&GPIOD_CRH))->CNF10)
#define GPIOD_CNF11 (((volatile bGPIOx_CRH *)(&GPIOD_CRH))->CNF11)
#define GPIOD_CNF12 (((volatile bGPIOx_CRH *)(&GPIOD_CRH))->CNF12)
#define GPIOD_CNF13 (((volatile bGPIOx_CRH *)(&GPIOD_CRH))->CNF13)
#define GPIOD_CNF14 (((volatile bGPIOx_CRH *)(&GPIOD_CRH))->CNF14)
#define GPIOD_CNF15 (((volatile bGPIOx_CRH *)(&GPIOD_CRH))->CNF15)
//GPIOE MODE
#define GPIOE_MODE0 (((volatile bGPIOx_CRL *)(&GPIOE_CRL))->MODE0)
#define GPIOE_MODE1 (((volatile bGPIOx_CRL *)(&GPIOE_CRL))->MODE1)
#define GPIOE_MODE2 (((volatile bGPIOx_CRL *)(&GPIOE_CRL))->MODE2)
#define GPIOE_MODE3 (((volatile bGPIOx_CRL *)(&GPIOE_CRL))->MODE3)
#define GPIOE_MODE4 (((volatile bGPIOx_CRL *)(&GPIOE_CRL))->MODE4)
#define GPIOE_MODE5 (((volatile bGPIOx_CRL *)(&GPIOE_CRL))->MODE5)
#define GPIOE_MODE6 (((volatile bGPIOx_CRL *)(&GPIOE_CRL))->MODE6)
#define GPIOE_MODE7 (((volatile bGPIOx_CRL *)(&GPIOE_CRL))->MODE7)
#define GPIOE_MODE8 (((volatile bGPIOx_CRH *)(&GPIOE_CRH))->MODE8)
#define GPIOE_MODE9 (((volatile bGPIOx_CRH *)(&GPIOE_CRH))->MODE9)
#define GPIOE_MODE10 (((volatile bGPIOx_CRH *)(&GPIOE_CRH))->MODE10)
#define GPIOE_MODE11 (((volatile bGPIOx_CRH *)(&GPIOE_CRH))->MODE11)
#define GPIOE_MODE12 (((volatile bGPIOx_CRH *)(&GPIOE_CRH))->MODE12)
#define GPIOE_MODE13 (((volatile bGPIOx_CRH *)(&GPIOE_CRH))->MODE13)
#define GPIOE_MODE14 (((volatile bGPIOx_CRH *)(&GPIOE_CRH))->MODE14)
#define GPIOE_MODE15 (((volatile bGPIOx_CRH *)(&GPIOE_CRH))->MODE15)
//GPIOE CNF(Configuration)
#define GPIOE_CNF0 (((volatile bGPIOx_CRL *)(&GPIOE_CRL))->CNF0)
#define GPIOE_CNF1 (((volatile bGPIOx_CRL *)(&GPIOE_CRL))->CNF1)
#define GPIOE_CNF2 (((volatile bGPIOx_CRL *)(&GPIOE_CRL))->CNF2)
#define GPIOE_CNF3 (((volatile bGPIOx_CRL *)(&GPIOE_CRL))->CNF3)
#define GPIOE_CNF4 (((volatile bGPIOx_CRL *)(&GPIOE_CRL))->CNF4)
#define GPIOE_CNF5 (((volatile bGPIOx_CRL *)(&GPIOE_CRL))->CNF5)
#define GPIOE_CNF6 (((volatile bGPIOx_CRL *)(&GPIOE_CRL))->CNF6)
#define GPIOE_CNF7 (((volatile bGPIOx_CRL *)(&GPIOE_CRL))->CNF7)
#define GPIOE_CNF8 (((volatile bGPIOx_CRH *)(&GPIOE_CRH))->CNF8)
#define GPIOE_CNF9 (((volatile bGPIOx_CRH *)(&GPIOE_CRH))->CNF9)
#define GPIOE_CNF10 (((volatile bGPIOx_CRH *)(&GPIOE_CRH))->CNF10)
#define GPIOE_CNF11 (((volatile bGPIOx_CRH *)(&GPIOE_CRH))->CNF11)
#define GPIOE_CNF12 (((volatile bGPIOx_CRH *)(&GPIOE_CRH))->CNF12)
#define GPIOE_CNF13 (((volatile bGPIOx_CRH *)(&GPIOE_CRH))->CNF13)
#define GPIOE_CNF14 (((volatile bGPIOx_CRH *)(&GPIOE_CRH))->CNF14)
#define GPIOE_CNF15 (((volatile bGPIOx_CRH *)(&GPIOE_CRH))->CNF15)
//GPIO input
#define GPIOA_IN GPIOA_IDR
#define GPIOB_IN GPIOB_IDR
#define GPIOC_IN GPIOB_IDR
#define GPIOD_IN GPIOC_IDR
#define GPIOE_IN GPIOD_IDR
//GPIOx input bit field
typedef struct bGPIOx_IN
{
unsigned int IN0 :1;
unsigned int IN1 :1;
unsigned int IN2 :1;
unsigned int IN3 :1;
unsigned int IN4 :1;
unsigned int IN5 :1;
unsigned int IN6 :1;
unsigned int IN7 :1;
unsigned int IN8 :1;
unsigned int IN9 :1;
unsigned int IN10 :1;
unsigned int IN11 :1;
unsigned int IN12 :1;
unsigned int IN13 :1;
unsigned int IN14 :1;
unsigned int IN15 :1;
}bGPIOx_IN;
//GPIOA input bit field
#define GPIOA_IN0 (((volatile bGPIOx_IN *)(&GPIOA_IN))->IN0)
#define GPIOA_IN1 (((volatile bGPIOx_IN *)(&GPIOA_IN))->IN1)
#define GPIOA_IN2 (((volatile bGPIOx_IN *)(&GPIOA_IN))->IN2)
#define GPIOA_IN3 (((volatile bGPIOx_IN *)(&GPIOA_IN))->IN3)
#define GPIOA_IN4 (((volatile bGPIOx_IN *)(&GPIOA_IN))->IN4)
#define GPIOA_IN5 (((volatile bGPIOx_IN *)(&GPIOA_IN))->IN5)
#define GPIOA_IN6 (((volatile bGPIOx_IN *)(&GPIOA_IN))->IN6)
#define GPIOA_IN7 (((volatile bGPIOx_IN *)(&GPIOA_IN))->IN7)
#define GPIOA_IN8 (((volatile bGPIOx_IN *)(&GPIOA_IN))->IN8)
#define GPIOA_IN9 (((volatile bGPIOx_IN *)(&GPIOA_IN))->IN9)
#define GPIOA_IN10 (((volatile bGPIOx_IN *)(&GPIOA_IN))->IN10)
#define GPIOA_IN11 (((volatile bGPIOx_IN *)(&GPIOA_IN))->IN11)
#define GPIOA_IN12 (((volatile bGPIOx_IN *)(&GPIOA_IN))->IN12)
#define GPIOA_IN13 (((volatile bGPIOx_IN *)(&GPIOA_IN))->IN13)
#define GPIOA_IN14 (((volatile bGPIOx_IN *)(&GPIOA_IN))->IN14)
#define GPIOA_IN15 (((volatile bGPIOx_IN *)(&GPIOA_IN))->IN15)
//GPIOB input bit field
#define GPIOB_IN0 (((volatile bGPIOx_IN *)(&GPIOB_IN))->IN0)
#define GPIOB_IN1 (((volatile bGPIOx_IN *)(&GPIOB_IN))->IN1)
#define GPIOB_IN2 (((volatile bGPIOx_IN *)(&GPIOB_IN))->IN2)
#define GPIOB_IN3 (((volatile bGPIOx_IN *)(&GPIOB_IN))->IN3)
#define GPIOB_IN4 (((volatile bGPIOx_IN *)(&GPIOB_IN))->IN4)
#define GPIOB_IN5 (((volatile bGPIOx_IN *)(&GPIOB_IN))->IN5)
#define GPIOB_IN6 (((volatile bGPIOx_IN *)(&GPIOB_IN))->IN6)
#define GPIOB_IN7 (((volatile bGPIOx_IN *)(&GPIOB_IN))->IN7)
#define GPIOB_IN8 (((volatile bGPIOx_IN *)(&GPIOB_IN))->IN8)
#define GPIOB_IN9 (((volatile bGPIOx_IN *)(&GPIOB_IN))->IN9)
#define GPIOB_IN10 (((volatile bGPIOx_IN *)(&GPIOB_IN))->IN10)
#define GPIOB_IN11 (((volatile bGPIOx_IN *)(&GPIOB_IN))->IN11)
#define GPIOB_IN12 (((volatile bGPIOx_IN *)(&GPIOB_IN))->IN12)
#define GPIOB_IN13 (((volatile bGPIOx_IN *)(&GPIOB_IN))->IN13)
#define GPIOB_IN14 (((volatile bGPIOx_IN *)(&GPIOB_IN))->IN14)
#define GPIOB_IN15 (((volatile bGPIOx_IN *)(&GPIOB_IN))->IN15)
//GPIOC input bit field
#define GPIOC_IN0 (((volatile bGPIOx_IN *)(&GPIOC_IN))->IN0)
#define GPIOC_IN1 (((volatile bGPIOx_IN *)(&GPIOC_IN))->IN1)
#define GPIOC_IN2 (((volatile bGPIOx_IN *)(&GPIOC_IN))->IN2)
#define GPIOC_IN3 (((volatile bGPIOx_IN *)(&GPIOC_IN))->IN3)
#define GPIOC_IN4 (((volatile bGPIOx_IN *)(&GPIOC_IN))->IN4)
#define GPIOC_IN5 (((volatile bGPIOx_IN *)(&GPIOC_IN))->IN5)
#define GPIOC_IN6 (((volatile bGPIOx_IN *)(&GPIOC_IN))->IN6)
#define GPIOC_IN7 (((volatile bGPIOx_IN *)(&GPIOC_IN))->IN7)
#define GPIOC_IN8 (((volatile bGPIOx_IN *)(&GPIOC_IN))->IN8)
#define GPIOC_IN9 (((volatile bGPIOx_IN *)(&GPIOC_IN))->IN9)
#define GPIOC_IN10 (((volatile bGPIOx_IN *)(&GPIOC_IN))->IN10)
#define GPIOC_IN11 (((volatile bGPIOx_IN *)(&GPIOC_IN))->IN11)
#define GPIOC_IN12 (((volatile bGPIOx_IN *)(&GPIOC_IN))->IN12)
#define GPIOC_IN13 (((volatile bGPIOx_IN *)(&GPIOC_IN))->IN13)
#define GPIOC_IN14 (((volatile bGPIOx_IN *)(&GPIOC_IN))->IN14)
#define GPIOC_IN15 (((volatile bGPIOx_IN *)(&GPIOC_IN))->IN15)
//GPIOD input bit field
#define GPIOD_IN0 (((volatile bGPIOx_IN *)(&GPIOD_IN))->IN0)
#define GPIOD_IN1 (((volatile bGPIOx_IN *)(&GPIOD_IN))->IN1)
#define GPIOD_IN2 (((volatile bGPIOx_IN *)(&GPIOD_IN))->IN2)
#define GPIOD_IN3 (((volatile bGPIOx_IN *)(&GPIOD_IN))->IN3)
#define GPIOD_IN4 (((volatile bGPIOx_IN *)(&GPIOD_IN))->IN4)
#define GPIOD_IN5 (((volatile bGPIOx_IN *)(&GPIOD_IN))->IN5)
#define GPIOD_IN6 (((volatile bGPIOx_IN *)(&GPIOD_IN))->IN6)
#define GPIOD_IN7 (((volatile bGPIOx_IN *)(&GPIOD_IN))->IN7)
#define GPIOD_IN8 (((volatile bGPIOx_IN *)(&GPIOD_IN))->IN8)
#define GPIOD_IN9 (((volatile bGPIOx_IN *)(&GPIOD_IN))->IN9)
#define GPIOD_IN10 (((volatile bGPIOx_IN *)(&GPIOD_IN))->IN10)
#define GPIOD_IN11 (((volatile bGPIOx_IN *)(&GPIOD_IN))->IN11)
#define GPIOD_IN12 (((volatile bGPIOx_IN *)(&GPIOD_IN))->IN12)
#define GPIOD_IN13 (((volatile bGPIOx_IN *)(&GPIOD_IN))->IN13)
#define GPIOD_IN14 (((volatile bGPIOx_IN *)(&GPIOD_IN))->IN14)
#define GPIOD_IN15 (((volatile bGPIOx_IN *)(&GPIOD_IN))->IN15)
//GPIOE input bit field
#define GPIOE_IN0 (((volatile bGPIOx_IN *)(&GPIOE_IN))->IN0)
#define GPIOE_IN1 (((volatile bGPIOx_IN *)(&GPIOE_IN))->IN1)
#define GPIOE_IN2 (((volatile bGPIOx_IN *)(&GPIOE_IN))->IN2)
#define GPIOE_IN3 (((volatile bGPIOx_IN *)(&GPIOE_IN))->IN3)
#define GPIOE_IN4 (((volatile bGPIOx_IN *)(&GPIOE_IN))->IN4)
#define GPIOE_IN5 (((volatile bGPIOx_IN *)(&GPIOE_IN))->IN5)
#define GPIOE_IN6 (((volatile bGPIOx_IN *)(&GPIOE_IN))->IN6)
#define GPIOE_IN7 (((volatile bGPIOx_IN *)(&GPIOE_IN))->IN7)
#define GPIOE_IN8 (((volatile bGPIOx_IN *)(&GPIOE_IN))->IN8)
#define GPIOE_IN9 (((volatile bGPIOx_IN *)(&GPIOE_IN))->IN9)
#define GPIOE_IN10 (((volatile bGPIOx_IN *)(&GPIOE_IN))->IN10)
#define GPIOE_IN11 (((volatile bGPIOx_IN *)(&GPIOE_IN))->IN11)
#define GPIOE_IN12 (((volatile bGPIOx_IN *)(&GPIOE_IN))->IN12)
#define GPIOE_IN13 (((volatile bGPIOx_IN *)(&GPIOE_IN))->IN13)
#define GPIOE_IN14 (((volatile bGPIOx_IN *)(&GPIOE_IN))->IN14)
#define GPIOE_IN15 (((volatile bGPIOx_IN *)(&GPIOE_IN))->IN15)
//GPIOx set
#define GPIOA_SET GPIOA_BSRR
#define GPIOB_SET GPIOB_BSRR
#define GPIOC_SET GPIOC_BSRR
#define GPIOD_SET GPIOD_BSRR
#define GPIOE_SET GPIOE_BSRR
//GPIOx clr
#define GPIOA_CLR GPIOA_BRR
#define GPIOB_CLR GPIOB_BRR
#define GPIOC_CLR GPIOC_BRR
#define GPIOD_CLR GPIOD_BRR
#define GPIOE_CLR GPIOE_BRR
#endif
用户829600 2010-4-6 09:50
用户232263 2009-10-26 19:58
用户1205831 2008-9-28 14:23
用户551677 2008-7-23 20:07
用户1144655 2008-7-19 11:13
jizzll_617398179 2008-7-14 23:22