4cv4

Dependencies:   mbed

Committer:
arelicayetano
Date:
Wed Nov 20 00:31:15 2019 +0000
Revision:
0:d515a22efe9d
4cv4

Who changed what in which revision?

UserRevisionLine numberNew contents of line
arelicayetano 0:d515a22efe9d 1 /*
arelicayetano 0:d515a22efe9d 2 ******************************************************************************
arelicayetano 0:d515a22efe9d 3 * @file SysClockConf.c
arelicayetano 0:d515a22efe9d 4 * @version
arelicayetano 0:d515a22efe9d 5 * @date 05-July-2016
arelicayetano 0:d515a22efe9d 6 * @brief System Clock configuration for STM32F103C8T6
arelicayetano 0:d515a22efe9d 7 *****************************************************************************
arelicayetano 0:d515a22efe9d 8 *
arelicayetano 0:d515a22efe9d 9 * All rights reserved.
arelicayetano 0:d515a22efe9d 10
arelicayetano 0:d515a22efe9d 11 This program is free software: you can redistribute it and/or modify
arelicayetano 0:d515a22efe9d 12 it under the terms of the GNU General Public License as published by
arelicayetano 0:d515a22efe9d 13 the Free Software Foundation, either version 3 of the License, or
arelicayetano 0:d515a22efe9d 14 (at your option) any later version.
arelicayetano 0:d515a22efe9d 15
arelicayetano 0:d515a22efe9d 16 This program is distributed in the hope that it will be useful,
arelicayetano 0:d515a22efe9d 17 but WITHOUT ANY WARRANTY; without even the implied warranty of
arelicayetano 0:d515a22efe9d 18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
arelicayetano 0:d515a22efe9d 19 GNU General Public License for more details.
arelicayetano 0:d515a22efe9d 20
arelicayetano 0:d515a22efe9d 21 You should have received a copy of the GNU General Public License
arelicayetano 0:d515a22efe9d 22 along with this program. If not, see <http://www.gnu.org/licenses/>.
arelicayetano 0:d515a22efe9d 23 */
arelicayetano 0:d515a22efe9d 24
arelicayetano 0:d515a22efe9d 25 #include "SysClockConf.h"
arelicayetano 0:d515a22efe9d 26 #include "mbed.h"
arelicayetano 0:d515a22efe9d 27
arelicayetano 0:d515a22efe9d 28 void HSE_SystemClock_Config(void) {
arelicayetano 0:d515a22efe9d 29 RCC_OscInitTypeDef RCC_OscInitStruct;
arelicayetano 0:d515a22efe9d 30 RCC_ClkInitTypeDef RCC_ClkInitStruct;
arelicayetano 0:d515a22efe9d 31 RCC_PeriphCLKInitTypeDef PeriphClkInit;
arelicayetano 0:d515a22efe9d 32
arelicayetano 0:d515a22efe9d 33 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
arelicayetano 0:d515a22efe9d 34 RCC_OscInitStruct.HSEState = RCC_HSE_ON;
arelicayetano 0:d515a22efe9d 35 RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
arelicayetano 0:d515a22efe9d 36 RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
arelicayetano 0:d515a22efe9d 37 RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
arelicayetano 0:d515a22efe9d 38 RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9;
arelicayetano 0:d515a22efe9d 39 HAL_RCC_OscConfig(&RCC_OscInitStruct);
arelicayetano 0:d515a22efe9d 40 RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
arelicayetano 0:d515a22efe9d 41 RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
arelicayetano 0:d515a22efe9d 42 RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
arelicayetano 0:d515a22efe9d 43 RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
arelicayetano 0:d515a22efe9d 44 RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
arelicayetano 0:d515a22efe9d 45 HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2);
arelicayetano 0:d515a22efe9d 46 PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC|RCC_PERIPHCLK_USB;
arelicayetano 0:d515a22efe9d 47 PeriphClkInit.AdcClockSelection = RCC_ADCPCLK2_DIV6;
arelicayetano 0:d515a22efe9d 48 PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLL_DIV1_5;
arelicayetano 0:d515a22efe9d 49 HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit);
arelicayetano 0:d515a22efe9d 50 }
arelicayetano 0:d515a22efe9d 51
arelicayetano 0:d515a22efe9d 52 void confSysClock(void) {
arelicayetano 0:d515a22efe9d 53 HAL_RCC_DeInit();
arelicayetano 0:d515a22efe9d 54 HSE_SystemClock_Config();
arelicayetano 0:d515a22efe9d 55 SystemCoreClockUpdate();
arelicayetano 0:d515a22efe9d 56 }