#include "sys.h"
#include "delay.h"
#include "usart.h"
#include "led.h"
//ALIENTEK 探索者STM32F407开发板 实验1
//跑马灯实验 -库函数版本
//广州市星翼电子科技有限公司
//作者:正点原子 @ALIENTEK
int main(void)
{
delay_init(168); //初始化延时函数
LED_Init(); //初始化LED端口
/**下面是通过直接操作库函数的方式实现IO控制**/
while(1)
{
GPIO_ResetBits(GPIOF,GPIO_Pin_9); //LED0对应引脚GPIOF.9拉低,亮 等同LED0=0;
GPIO_SetBits(GPIOF,GPIO_Pin_10); //LED1对应引脚GPIOF.10拉高,灭 等同LED1=1;
delay_ms(500); //延时300ms
GPIO_SetBits(GPIOF,GPIO_Pin_9); //LED0对应引脚GPIOF.0拉高,灭 等同LED0=1;
GPIO_ResetBits(GPIOF,GPIO_Pin_10); //LED1对应引脚GPIOF.10拉低,亮 等同LED1=0;
delay_ms(500); //延时300ms
}
}
/**
*******************下面注释掉的代码是通过 位带 操作实现IO口控制**************************************
int main(void)
{
delay_init(168); //初始化延时函数
LED_Init(); //初始化LED端口
while(1)
{
LED0=0; //LED0亮
LED1=1; //LED1灭
delay_ms(500);
LED0=1; //LED0灭
LED1=0; //LED1亮
delay_ms(500);
}
}
**************************************************************************************************
**/
/**
*******************下面注释掉的代码是通过 直接操作寄存器 方式实现IO口控制**************************************
int main(void)
{
delay_init(168); //初始化延时函数
LED_Init(); //初始化LED端口
while(1)
{
GPIOF->BSRRH=GPIO_Pin_9;//LED0亮
GPIOF->BSRRL=GPIO_Pin_10;//LED1灭
delay_ms(500);
GPIOF->BSRRL=GPIO_Pin_9;//LED0灭
GPIOF->BSRRH=GPIO_Pin_10;//LED1亮
delay_ms(500);
}
}
**************************************************************************************************
**/
|