aboutsummaryrefslogtreecommitdiffstats
path: root/src/stm32f4/spi.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/stm32f4/spi.c')
-rw-r--r--src/stm32f4/spi.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/stm32f4/spi.c b/src/stm32f4/spi.c
index a7e96874..f8852be9 100644
--- a/src/stm32f4/spi.c
+++ b/src/stm32f4/spi.c
@@ -19,10 +19,12 @@ spi_setup(uint32_t bus, uint8_t mode, uint32_t rate)
shutdown("Invalid spi bus");
// Enable SPI
- enable_pclock(SPI2_BASE);
- gpio_peripheral(GPIO('B', 14), GPIO_FUNCTION(5), 1);
- gpio_peripheral(GPIO('B', 15), GPIO_FUNCTION(5), 0);
- gpio_peripheral(GPIO('B', 13), GPIO_FUNCTION(5), 0);
+ if (!is_enabled_pclock(SPI2_BASE)) {
+ enable_pclock(SPI2_BASE);
+ gpio_peripheral(GPIO('B', 14), GPIO_FUNCTION(5), 1);
+ gpio_peripheral(GPIO('B', 15), GPIO_FUNCTION(5), 0);
+ gpio_peripheral(GPIO('B', 13), GPIO_FUNCTION(5), 0);
+ }
// Calculate CR1 register
uint32_t pclk = get_pclock_frequency(SPI2_BASE);