Estoy tratando de encontrar algún recurso en línea para descubrir cómo configurar los registros GPIO en una placa STM32F4 Cortex M4. Solo tengo ejemplos para el Cortex M4
typedef struct
{
__IO uint32_t MODER; /*!< GPIO port mode register, Address offset: 0x00 */
__IO uint32_t OTYPER; /*!< GPIO port output type register, Address offset: 0x04 */
__IO uint32_t OSPEEDR; /*!< GPIO port output speed register, Address offset: 0x08 */
__IO uint32_t PUPDR; /*!< GPIO port pull-up/pull-down register, Address offset: 0x0C */
__IO uint32_t IDR; /*!< GPIO port input data register, Address offset: 0x10 */
__IO uint32_t ODR; /*!< GPIO port output data register, Address offset: 0x14 */
__IO uint16_t BSRRL; /*!< GPIO port bit set/reset low register, Address offset: 0x18 */
__IO uint16_t BSRRH; /*!< GPIO port bit set/reset high register, Address offset: 0x1A */
__IO uint32_t LCKR; /*!< GPIO port configuration lock register, Address offset: 0x1C */
__IO uint32_t AFR[2]; /*!< GPIO alternate function registers, Address offset: 0x24-0x28 */
} GPIO_TypeDef;
Aquí están los registros. Pero no hay nada en línea que me muestre cómo configurar realmente un pin para decir salida/entrada, etc. ¿Puede alguien señalarme un recurso?
Si está utilizando la biblioteca ST Standard Peripheral (descargable desde la página STM32F4, también está la biblioteca USB , y más cosas ), lea la documentación (es un archivo .chm en el nivel superior del zip) y verifique el código de ejemplo. Todas las funciones para configurar IO, periféricos, etc. están ahí.
Aquí hay un par de fragmentos que muestran la inicialización y el uso de un pin IO de parte de mi código.
Configuración de pines:
#include "stm32f4xx.h"
void LED_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
/* Enable the GPIO_LED Clock */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
GPIO_InitStructure.GPIO_Pin = LED1 | LED2 | LED3 | LED4;
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_50MHz;
GPIO_Init(GPIOD, &GPIO_InitStructure);
}
LED de alternancia:
GPIO_SetBits(GPIOD, LED1);
GPIO_ResetBits(GPIOD, LED2);
mate joven
Raaj
viejo contador de tiempo
Alexey Shmalko