//peripheral:外设
#include"stm32f4xx.h"//peripheral
#define PERIPHERAL ((unsigned int)(0x40000000))
#define AHB1_BASE ((unsigned int)(PERIPHERAL + 0x0002 0000))
#define GPIOA_BASE ((unsigned int)(AHB1_BASE+0x0000 0000))
#define GPIOB_BASE ((unsigned int)(AHB1_BASE+0x0002 0400))
#define GPIOC_BASE ((unsigned int)(AHB1_BASE+0x0002 0800))
#define GPIOD_BASE ((unsigned int)(AHB1_BASE+0x0002 0c00))
#define GPIOE_BASE ((unsigned int)(AHB1_BASE+0x0002 1000))
#define GPIOF_BASE ((unsigned int)(AHB1_BASE+0x0002 1400)
#define GPIOG_BASE ((unsigned int)(AHB1_BASE+0x0002 1800))
#define GPIOH_BASE ((unsigned int)(AHB1_BASE+0x0002 1C00))
#define GPIOI_BASE ((unsigned int)(AHB1_BASE+0x0002 2000))// #define GPIOH_MODER *(unsigned int*)(GPIOH_BASE+0x00)// #define GPIOH_OTYPER *(unsigned int*)(GPIOH_BASE+0x04)// #define GPIOH_OSPEEDR *(unsigned int*)(GPIOH_BASE+0x08)// #define GPIOH_PUPDR *(unsigned int*)(GPIOH_BASE+0x0c)// #define GPIOH_IDR *(unsigned int*)(GPIOH_BASE+0x10)// #define GPIOH_ODR *(unsigned int*)(GPIOH_BASE+0x14)// #define GPIOH_BSRR *(unsigned int*)(GPIOH_BASE+0x18)// #define GPIOH_LCKR *(unsigned int*)(GPIOH_BASE+0x1c)// #define GPIOH_AFRL *(unsigned int*)(GPIOH_BASE+0x20)// #define GPIOH_AFRH *(unsigned int*)(GPIOH_BASE+0x24)typedef unsigned int uint32_t;
typedef unsigned int uint16_t;typedef struct
{uint32_t MODER;uint32_t OTYPER;uint32_t OSPEEDR;uint32_t PUPDR;uint32_t IDR;uint32_t ODR;uint16_t BSRRL;uint16_t BSSRH;uint32_t LCKR;uint32_t AFR[2];
}GPIO_Typedef;//将GPIOA_BASE变成一个结构体指针
#define GPIOA ((GPIO_Typedef *)(GPIOA_BASE))
#define GPIOB ((GPIO_Typedef *)(GPIOB_BASE))
#define GPIOC ((GPIO_Typedef *)(GPIOC_BASE))
#define GPIOD ((GPIO_Typedef *)(GPIOD_BASE))
#define GPIOE ((GPIO_Typedef *)(GPIOE_BASE))
#define GPIOF ((GPIO_Typedef *)(GPIOF_BASE))
#define GPIOG ((GPIO_Typedef *)(GPIOG_BASE))
#define GPIOH ((GPIO_Typedef *)(GPIOH_BASE))
#define GPIOI ((GPIO_Typedef *)(GPIOI_BASE))int main(void)
{RCCAHB1PERIPH_BASE |= (1<<7);// GPIOH_MODER &= ~(3<<2*10); // GPIOH_MODER |= (1<<2*10); GPIOH->MODER &= ~(3<<2*10);GPIO->MODER |= (1<<2*10);//PH10输出低电平GPIOH_ODR &= ~(1<<10); while(1);
}