Hier mal die Ansteuerung für die LED bei einem F411RE, sollte aber identisch mit deinem sein.
Code:
#include "stm32f4xx.h"
#include "stm32f4xx_conf.h"
#define LED2_PIN GPIO_Pin_5
#define LED2_GPIO_PORT GPIOA
#define LED2_GPIO_CLK RCC_AHB1Periph_GPIOA
#define USER_BUTTON_PIN GPIO_Pin_13
#define USER_BUTTON_GPIO_PORT GPIOC
#define USER_BUTTON_GPIO_CLK RCC_AHB1Periph_GPIOC
#define USER_BUTTON_EXTI_LINE EXTI_Line13
#define USER_BUTTON_EXTI_PORT_SOURCE GPIO_PortSourceGPIOC
#define USER_BUTTON_EXTI_PIN_SOURCE GPIO_PinSource13
void SysClock_Init(void)
{
RCC_ClocksTypeDef RCC_Clocks;
/* SysTick end of count event each 1ms */
RCC_GetClocksFreq(&RCC_Clocks);
SysTick_Config(RCC_Clocks.HCLK_Frequency / 1000);
}
void LED_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
/* Enable the GPIO Clock */
RCC_AHB1PeriphClockCmd(LED2_GPIO_CLK, ENABLE);
/* Configure the GPIO pin */
GPIO_InitStructure.GPIO_Pin = LED2_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(LED2_GPIO_PORT, &GPIO_InitStructure);
}
void LED_SetOnOff(uint8_t state)
{
if(ON == state)
GPIOA->BSRRL = GPIO_Pin_5;
else
GPIOA->BSRRH = GPIO_Pin_5;
}
void LED_Toggle(void)
{
GPIOA->ODR ^= GPIO_Pin_5;
}
mfg
Lesezeichen