Curso_STM32 / Mbed 2 deprecated STM32F103C8T6_Servo_1

Dependencies:   mbed

Committer:
sergiomejia
Date:
Tue Jan 14 00:13:32 2020 +0000
Revision:
0:1f6440e0f93a
Programa que controla dos servo-motores con movimiento horizontal y vertical desde un Joystick

Who changed what in which revision?

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