我试图弄清楚如何切换 Nucleo 板上的 LED,但我只是没有看到用户 LED 切换。在网上看似乎这就是你所要做的。有没有其他人遇到过这个问题?
#include "stm32f4xx.h"
#include "stm32f4xx_gpio.h"
#include "stm32f4xx_rcc.h"
int main(void)
{
int counter = 0;
SystemInit();
GPIO_InitTypeDef temp;
temp.GPIO_Mode = GPIO_Mode_OUT;
temp.GPIO_OType = GPIO_OType_PP; // Push Pull
temp.GPIO_Pin = GPIO_Pin_5;
temp.GPIO_Speed = GPIO_Low_Speed;
temp.GPIO_PuPd = GPIO_PuPd_NOPULL;
RCC_APB2PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
GPIO_Init( GPIOA, &temp );
while( 1 )
{
if ( counter++ > 10000 )
{
GPIO_ToggleBits( GPIOA, GPIO_Pin_5 );
counter = 0;
}
}
}