aboutsummaryrefslogtreecommitdiff
path: root/libraries
diff options
context:
space:
mode:
authorFredrik Thulin <fredrik@thulin.net>2016-05-21 13:16:58 +0200
committerFredrik Thulin <fredrik@thulin.net>2016-05-21 13:16:58 +0200
commit3d16ad028d69acc581095430d20463ed66f65779 (patch)
treefcc475d12213bdd24f5b5e0071750e4c78b93e5a /libraries
parent8204c137d39d936da4fb4f2dc13ed56d0bcec5e5 (diff)
Add code to access the keystore memory (SPI flash).
Diffstat (limited to 'libraries')
-rw-r--r--libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F4/TARGET_CRYPTECH_ALPHA/stm32f4xx_hal_msp.c33
1 files changed, 27 insertions, 6 deletions
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 d0f814e..6d1d029 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
@@ -200,7 +200,6 @@ void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c)
/* Peripheral clock enable */
__I2C2_CLK_ENABLE();
}
-
}
void HAL_I2C_MspDeInit(I2C_HandleTypeDef* hi2c)
@@ -214,10 +213,25 @@ void HAL_I2C_MspDeInit(I2C_HandleTypeDef* hi2c)
void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
{
GPIO_InitTypeDef GPIO_InitStruct;
- if (hspi->Instance == SPI2) {
- /* Peripheral clock enable */
- __SPI2_CLK_ENABLE();
+ if (hspi->Instance == SPI1) {
+ /* SPI1 is the keystore memory.
+ *
+ * SPI1 GPIO Configuration
+ * PA5 ------> SPI2_SCK
+ * PA6 ------> SPI2_MISO
+ * PA7 ------> SPI2_MOSI
+ */
+ __GPIOA_CLK_ENABLE();
+ GPIO_InitStruct.Pin = GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
+ GPIO_InitStruct.Alternate = GPIO_AF5_SPI1;
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+ /* Peripheral clock enable */
+ __SPI1_CLK_ENABLE();
+ } else if (hspi->Instance == SPI2) {
/* SPI2 is the FPGA config memory.
*
* SPI2 GPIO Configuration
@@ -225,19 +239,26 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
* PB14 ------> SPI2_MISO
* PB15 ------> SPI2_MOSI
*/
+ __GPIOB_CLK_ENABLE();
GPIO_InitStruct.Pin = GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
+
+ /* Peripheral clock enable */
+ __SPI2_CLK_ENABLE();
}
}
void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi)
{
-
- if (hspi->Instance == SPI2) {
+ if (hspi->Instance == SPI1) {
+ /* Peripheral clock disable */
+ __HAL_RCC_SPI1_CLK_DISABLE();
+ HAL_GPIO_DeInit(GPIOB, GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7);
+ } else if (hspi->Instance == SPI2) {
/* Peripheral clock disable */
__HAL_RCC_SPI2_CLK_DISABLE();
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15);