LED灯代码:
#define PERIPH_BASE ((unsigned int)0x40000000)
#define AHB1PERIPH_BASE (PERIPH_BASE + 0x00020000)
#define GPIOF_BASE (AHB1PERIPH_BASE + 0x1400)
#define GPIOF_MODER *(unsigned int*)(GPIOF_BASE+0x00)
#define GPIOF_BSRR *(unsigned int*)(GPIOF_BASE+0x18)
#define RCC_BASE (AHB1PERIPH_BASE + 0x3800)
#define RCC_AHB1ENR *(unsigned int*)(RCC_BASE+0x30)
main.c
#include "stm32f4xx.h"
typedef unsigned int u32; //unsigned int -- u32
void SystemInit()
{
}
void delay(u32 i)
{
while(i--);
}
int main()
{
RCC_AHB1ENR |= 1<<5;
//GPIOF_MODER = (1<<(2*9));
GPIOF_MODER = (5<<(2*9));;
while(1)
{
GPIOF_BSRR=(3<<(16+9));
delay(0xFFFFF);
GPIOF_BSRR=(3<<(9));
delay(0xFFFFF);
}
}