[Cryptech-Commits] [user/ft/stm32-dev-bridge] 01/04: Abort startup on non-working RCC.

git at cryptech.is git at cryptech.is
Mon Dec 14 14:36:35 UTC 2015


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

fredrik at thulin.net pushed a commit to branch master
in repository user/ft/stm32-dev-bridge.

commit af155a47288686f9577a2eb642dfe204ab0b5ef7
Author: Fredrik Thulin <fredrik at thulin.net>
Date:   Thu Dec 10 12:37:54 2015 +0100

    Abort startup on non-working RCC.
    
    Without this, failure to initialize the HSE will go unnoticed.
---
 src/led-test/src/stm_init.c | 28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/src/led-test/src/stm_init.c b/src/led-test/src/stm_init.c
index 971f1ef..3df5d3e 100644
--- a/src/led-test/src/stm_init.c
+++ b/src/led-test/src/stm_init.c
@@ -85,7 +85,18 @@ void SystemClock_Config(void)
   RCC_OscInitStruct.PLL.PLLN = 360;
   RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
   RCC_OscInitStruct.PLL.PLLQ = 4;
-  HAL_RCC_OscConfig(&RCC_OscInitStruct);
+  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
+    volatile uint32_t i;
+
+    MX_GPIO_Init();
+
+    HAL_GPIO_WritePin(LED_PORT, LED_RED, GPIO_PIN_SET);
+    HAL_GPIO_WritePin(LED_PORT, LED_BLUE, GPIO_PIN_SET);
+
+    while (1) {
+      i++; /* To not get optimized away */
+    }
+  }
 
   HAL_PWREx_ActivateOverDrive();
 
@@ -94,7 +105,20 @@ void SystemClock_Config(void)
   RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
   RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
   RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
-  HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5);
+  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK) {
+    volatile uint32_t j;
+
+    MX_GPIO_Init();
+
+    HAL_GPIO_WritePin(LED_PORT, LED_RED, GPIO_PIN_SET);
+    if(__HAL_RCC_GET_FLAG(RCC_FLAG_HSERDY) == RESET) {
+      HAL_GPIO_WritePin(LED_PORT, LED_YELLOW, GPIO_PIN_SET);
+    }
+
+    while (1) {
+      j++; /* To not get optimized away */
+    }
+  }
 }
 
 /** Configure pins as



More information about the Commits mailing list