[Cryptech-Commits] [sw/stm32] 01/07: Initialize I/O pins of SPI3, which is used to configure iCE40-based MKM.

git at cryptech.is git at cryptech.is
Mon Sep 13 09:04:45 UTC 2021


This is an automated email from the git hooks/post-receive script.

meisterpaul1 at yandex.ru pushed a commit to branch ice40mkm
in repository sw/stm32.

commit 71f6c636d73e218baa2c5f8dc5057f54029132ea
Author: Pavel V. Shatov (Meister) <meisterpaul1 at yandex.ru>
AuthorDate: Mon Sep 13 11:45:09 2021 +0300

    Initialize I/O pins of SPI3, which is used to configure iCE40-based MKM.
    
    Note, that SPI3 is alternate function 6, unlike SPI1 & SPI2 which are both AF5.
---
 .../TARGET_CRYPTECH_ALPHA/stm32f4xx_hal_msp.c          | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F4/TARGET_CRYPTECH_ALPHA/stm32f4xx_hal_msp.c b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F4/TARGET_CRYPTECH_ALPHA/stm32f4xx_hal_msp.c
index f64e6ce..6983c70 100644
--- a/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F4/TARGET_CRYPTECH_ALPHA/stm32f4xx_hal_msp.c
+++ b/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F4/TARGET_CRYPTECH_ALPHA/stm32f4xx_hal_msp.c
@@ -295,6 +295,24 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
 
 	/* Peripheral clock enable */
 	__SPI2_CLK_ENABLE();
+    } else if (hspi->Instance == SPI3) {
+	/* SPI3 is the iCE40 MKM slave config interface
+	 *
+	 * SPI3 GPIO Configuration
+	 * PC10     ------> SPI3_SCK
+	 * PC11     ------> SPI3_MISO
+	 * PC12     ------> SPI3_MOSI
+	*/
+	__GPIOC_CLK_ENABLE();
+	GPIO_InitStruct.Pin = GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12;
+	GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+	GPIO_InitStruct.Pull = GPIO_NOPULL;
+	GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
+	GPIO_InitStruct.Alternate = GPIO_AF6_SPI3;
+	HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
+
+	/* Peripheral clock enable */
+	__SPI3_CLK_ENABLE();
     }
 }
 



More information about the Commits mailing list