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