Igal Salazar / Mbed 2 deprecated Bluepill_Reloj_copy

Dependencies:   mbed

Committer:
igalsalazars
Date:
Fri Mar 11 00:13:29 2022 +0000
Revision:
0:53bf87d68a12
reloj fechador con lcd ;

Who changed what in which revision?

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