STM32F407GT6 LED灯程序
时间: 2024-05-30 14:14:06 浏览: 100
可以直接回答,以下是一个简单的LED灯程序,仅供参考:
#include "stm32f4xx.h"
#include "stm32f4xx_gpio.h"
#include "stm32f4xx_rcc.h"
#include "misc.h"
#define LED_GPIO GPIOD
#define LED_GPIO_CLK RCC_AHB1Periph_GPIOD
#define LED_RED GPIO_Pin_14
#define LED_BLUE GPIO_Pin_15
#define LED_GREEN GPIO_Pin_12
void GPIO_Configuration();
void Delay(__IO uint32_t nCount);
int main()
{
GPIO_Configuration();
while(1)
{
GPIO_SetBits(LED_GPIO,LED_RED);
Delay(0xFFFFF);
GPIO_ResetBits(LED_GPIO,LED_RED);
Delay(0xFFFFF);
}
}
void GPIO_Configuration()
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_AHB1PeriphClockCmd(LED_GPIO_CLK,ENABLE);
GPIO_InitStructure.GPIO_Pin = LED_RED | LED_BLUE | LED_GREEN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_Init(LED_GPIO,&GPIO_InitStructure);
}
void Delay(__IO uint32_t nCount)
{
while(nCount--);
}
阅读全文