From 1b801508baf58b8053bb30d101efce018b159a5e Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Tue, 12 Oct 2021 13:32:46 -0400 Subject: stm32: Add comments to configuration of OSPEEDR gpio speed Signed-off-by: Kevin O'Connor --- src/stm32/stm32f4.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/stm32/stm32f4.c') diff --git a/src/stm32/stm32f4.c b/src/stm32/stm32f4.c index 06312832..6cbfd22a 100644 --- a/src/stm32/stm32f4.c +++ b/src/stm32/stm32f4.c @@ -68,6 +68,8 @@ gpio_clock_enable(GPIO_TypeDef *regs) RCC->AHB1ENR; } +#define STM_OSPEED 0x2 // ~50Mhz at 40pF on STM32F4 (~25Mhz at 40pF on STM32F2) + // Set the mode and extended function of a pin void gpio_peripheral(uint32_t gpio, uint32_t mode, int pullup) @@ -88,7 +90,7 @@ gpio_peripheral(uint32_t gpio, uint32_t mode, int pullup) regs->MODER = (regs->MODER & ~m_msk) | (mode_bits << m_shift); regs->PUPDR = (regs->PUPDR & ~m_msk) | (pup << m_shift); regs->OTYPER = (regs->OTYPER & ~(1 << pos)) | (od << pos); - regs->OSPEEDR = (regs->OSPEEDR & ~m_msk) | (0x02 << m_shift); + regs->OSPEEDR = (regs->OSPEEDR & ~m_msk) | (STM_OSPEED << m_shift); } #define USB_BOOT_FLAG_ADDR (CONFIG_RAM_START + CONFIG_RAM_SIZE - 4096) -- cgit v1.2.3-70-g09d2