diff options
author | H. Gregor Molter <gregor.molter@secretlab.de> | 2023-02-20 19:52:36 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2023-02-20 19:55:25 -0500 |
commit | d7bd7f1f4ba6cecd19daa566fdc1864561269ae1 (patch) | |
tree | d57d02e2dd5fb12359b2ba95080241483f02fbb0 /src/stm32/gpioperiph.c | |
parent | 848a78d1a548cfe28af20d5d0ab021558368cfae (diff) | |
download | kutter-d7bd7f1f4ba6cecd19daa566fdc1864561269ae1.tar.gz kutter-d7bd7f1f4ba6cecd19daa566fdc1864561269ae1.tar.xz kutter-d7bd7f1f4ba6cecd19daa566fdc1864561269ae1.zip |
stm32: Add sdio support
Adds sdio support for the stm32f4 to allow for SD card flash updates
without power cycling some boards, e.g. BTT Octopus Pro.
Signed-off-by: H. Gregor Molter <gregor.molter@secretlab.de>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/stm32/gpioperiph.c')
-rw-r--r-- | src/stm32/gpioperiph.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/stm32/gpioperiph.c b/src/stm32/gpioperiph.c index 06cdaa05..ef421c77 100644 --- a/src/stm32/gpioperiph.c +++ b/src/stm32/gpioperiph.c @@ -6,7 +6,7 @@ #include "internal.h" // gpio_peripheral -// Set the mode and extended function of a pin +// Set the mode, extended function and speed of a pin void gpio_peripheral(uint32_t gpio, uint32_t mode, int pullup) { @@ -16,7 +16,8 @@ gpio_peripheral(uint32_t gpio, uint32_t mode, int pullup) gpio_clock_enable(regs); // Configure GPIO - uint32_t mode_bits = mode & 0xf, func = (mode >> 4) & 0xf, od = mode >> 8; + uint32_t mode_bits = mode & 0xf, func = (mode >> 4) & 0xf; + uint32_t od = (mode >> 8) & 0x1, hs = (mode >> 9) & 0x1; uint32_t pup = pullup ? (pullup > 0 ? 1 : 2) : 0; uint32_t pos = gpio % 16, af_reg = pos / 8; uint32_t af_shift = (pos % 8) * 4, af_msk = 0x0f << af_shift; @@ -33,6 +34,6 @@ gpio_peripheral(uint32_t gpio, uint32_t mode, int pullup) // stm32f4 is ~50Mhz at 40pF // stm32g0 is ~30Mhz at 50pF // stm32h7 is ~85Mhz at 50pF - uint32_t ospeed = CONFIG_MACH_STM32F0 ? 0x01 : 0x02; + uint32_t ospeed = hs ? 0x03 : (CONFIG_MACH_STM32F0 ? 0x01 : 0x02); regs->OSPEEDR = (regs->OSPEEDR & ~m_msk) | (ospeed << m_shift); } |