diff options
author | Fredrik Thulin <fredrik@thulin.net> | 2015-12-10 12:37:54 +0100 |
---|---|---|
committer | Fredrik Thulin <fredrik@thulin.net> | 2015-12-10 12:38:02 +0100 |
commit | af155a47288686f9577a2eb642dfe204ab0b5ef7 (patch) | |
tree | 75bf4c83ee252d3cd467ee9059f8effdd7f37496 | |
parent | e057ddb49be64c3e931eae168bb57d36d3c13f7d (diff) |
Abort startup on non-working RCC.
Without this, failure to initialize the HSE will go unnoticed.
-rw-r--r-- | src/led-test/src/stm_init.c | 28 |
1 files 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 |