Estoy usando el código fuente de Zhengdian Atom. Nunca entendí cómo asignar valores a los registros relevantes durante la inicialización . Lo pensé hoy:
Primero, se crea una variable de estructura GPIO_InitStructure de tipo GPIO_InitTypeDef.
GPIO_InitTypeDef GPIO_InitStructure;
Luego asigne un valor a cada variable miembro a través de [nombre de estructura.nombre de miembro]
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9 | GPIO_Pin_10; // LED0 y LED1 corresponden a los puertos IO, GPIO_InitStructure.GPIO_Mode =
GPIO_Mode_OUT ; //Modo de salida normal GPIO_InitStructure.GPIO_OType = GPIO_OType_PP ; // Salida push-pull GPIO_InitStructure.GPIO_Speed = GPIO_ Velocidad_ 100MHz; //100MHz GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ;//Pull-up
Luego llame a la función GPIO_Init()
GPIO_Init(GPIOF, &GPIO_InitStructure);
El proceso de implementación específico es el siguiente: involucra los siguientes archivos
stm32f4xx.h
stm32f4xx_gpio.h
led.c
El diagrama aproximado es el siguiente: