2 *******************************************************************************
3 * Copyright (c) 2018, STMicroelectronics
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
9 * 1. Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 * 3. Neither the name of STMicroelectronics nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *******************************************************************************
30 #include "pins_arduino.h"
37 const PinName digitalPin
[] = {
38 /* USB connector on the top, MCU side */
56 PB_12
, //D16 - LED Blackpill
58 PC_13
, //D17 - LED Bluepill
82 // ----------------------------------------------------------------------------
89 * @brief System Clock Configuration
90 * The system Clock is configured as follow :
91 * System Clock source = PLL (HSE)
92 * SYSCLK(Hz) = 72000000
99 * Flash Latency(WS) = 2
101 * USB Prescaler = 1.5
105 WEAK
void SystemClock_Config(void)
107 RCC_OscInitTypeDef RCC_OscInitStruct
;
108 RCC_ClkInitTypeDef RCC_ClkInitStruct
;
109 RCC_PeriphCLKInitTypeDef PeriphClkInit
;
111 /* Initializes the CPU, AHB and APB busses clocks */
112 RCC_OscInitStruct
.OscillatorType
= RCC_OSCILLATORTYPE_HSE
;
113 RCC_OscInitStruct
.HSEState
= RCC_HSE_ON
;
114 RCC_OscInitStruct
.HSEPredivValue
= RCC_HSE_PREDIV_DIV2
;
115 RCC_OscInitStruct
.HSIState
= RCC_HSI_ON
;
116 RCC_OscInitStruct
.PLL
.PLLState
= RCC_PLL_ON
;
117 RCC_OscInitStruct
.PLL
.PLLSource
= RCC_PLLSOURCE_HSE
;
118 RCC_OscInitStruct
.PLL
.PLLMUL
= RCC_PLL_MUL9
;
119 if (HAL_RCC_OscConfig(&RCC_OscInitStruct
) != HAL_OK
) {
123 /* Initializes the CPU, AHB and APB busses clocks */
124 RCC_ClkInitStruct
.ClockType
= RCC_CLOCKTYPE_HCLK
| RCC_CLOCKTYPE_SYSCLK
125 | RCC_CLOCKTYPE_PCLK1
| RCC_CLOCKTYPE_PCLK2
;
126 RCC_ClkInitStruct
.SYSCLKSource
= RCC_SYSCLKSOURCE_PLLCLK
;
127 RCC_ClkInitStruct
.AHBCLKDivider
= RCC_SYSCLK_DIV1
;
128 RCC_ClkInitStruct
.APB1CLKDivider
= RCC_HCLK_DIV2
;
129 RCC_ClkInitStruct
.APB2CLKDivider
= RCC_HCLK_DIV1
;
131 if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct
, FLASH_LATENCY_2
) != HAL_OK
) {
135 PeriphClkInit
.PeriphClockSelection
= RCC_PERIPHCLK_ADC
| RCC_PERIPHCLK_USB
;
136 PeriphClkInit
.AdcClockSelection
= RCC_ADCPCLK2_DIV6
;
137 PeriphClkInit
.UsbClockSelection
= RCC_USBCLKSOURCE_PLL_DIV1_5
;
138 if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit
) != HAL_OK
) {