test
Diff: SysClockConf.cpp
- Revision:
- 8:2582ee8cc84c
- Parent:
- 5:9fbbea76d6f6
- Child:
- 11:e0edd7ea602a
--- a/SysClockConf.cpp Tue Aug 02 19:37:40 2016 +0000 +++ b/SysClockConf.cpp Sat May 27 09:31:15 2017 +0000 @@ -8,7 +8,7 @@ ****************************************************************************** * @attention * - * <h2><center>© COPYRIGHT(c) 2016 Zoltan Hudak <hudakz@inbox.com> + * <h2><center>© COPYRIGHT(c) 2016 Zoltan Hudak <hudakz@outlook.com> * * All rights reserved. @@ -29,8 +29,12 @@ #include "SysClockConf.h" #include "mbed.h" -bool HSE_SystemClock_Config(void) { +extern volatile uint32_t tim_it_counter; +volatile uint32_t tim_init; + +void HSE_SystemClock_Config(void) { RCC_OscInitTypeDef RCC_OscInitStruct; + RCC_ClkInitTypeDef RCC_ClkInitStruct; RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; RCC_OscInitStruct.HSEState = RCC_HSE_ON; @@ -38,42 +42,25 @@ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9; - - if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { - return false; - } - - RCC_ClkInitTypeDef RCC_ClkInitStruct; - + HAL_RCC_OscConfig(&RCC_OscInitStruct); RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK - |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; + |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; - if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) { - return false; - } - + HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2); RCC_PeriphCLKInitTypeDef PeriphClkInit; - PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC|RCC_PERIPHCLK_USB; PeriphClkInit.AdcClockSelection = RCC_ADCPCLK2_DIV6; - PeriphClkInit.UsbClockSelection = RCC_USBPLLCLK_DIV1_5; - if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) { - return false; - } - return true; + PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLL_DIV1_5; + HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit); } bool confSysClock(void) { + tim_init = tim_it_counter; HAL_RCC_DeInit(); - if (!HSE_SystemClock_Config()) { - return false; - } + HSE_SystemClock_Config(); SystemCoreClockUpdate(); return true; } - - -