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
[] = {
40 PB_7
, //D2 - UART1_RX or I2C1_SDC
41 PB_6
, //D3 - UART1_TX or I2C1_SCL
48 PA_10
, //D10 - SDA MPU-9150
49 PA_9
, //D11 - SCL MPU-9150
55 PC_13
, //D17 - LED on Bluepill Board
68 PB_10
, //D30 - UART3_TX
69 PB_11
, //D31 - UART3_RX
75 // If analog pins are not contiguous in the digitalPin array:
76 // Add the analogInputPin array without defining NUM_ANALOG_FIRST
77 // Analog (Ax) pin number array
78 // where x is the index to retrieve the digital pin number
79 const uint32_t analogInputPin
[] = {
83 23, // Not sure about this one beecasue NUM is 9 in the header, and this is RCX
96 // ----------------------------------------------------------------------------
102 WEAK
void SystemClock_Config(void)
105 RCC_OscInitTypeDef RCC_OscInitStruct
;
106 RCC_ClkInitTypeDef RCC_ClkInitStruct
;
107 // RCC_PeriphCLKInitTypeDef PeriphClkInit;
109 /**Initializes the CPU, AHB and APB busses clocks
111 RCC_OscInitStruct
.OscillatorType
= RCC_OSCILLATORTYPE_HSE
;
112 RCC_OscInitStruct
.HSEState
= RCC_HSE_ON
;
113 RCC_OscInitStruct
.HSEPredivValue
= RCC_HSE_PREDIV_DIV4
;
114 RCC_OscInitStruct
.HSIState
= RCC_HSI_ON
;
115 RCC_OscInitStruct
.HSICalibrationValue
= 16;
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
) {
120 _Error_Handler(__FILE__
, __LINE__
);
123 /**Initializes the CPU, AHB and APB busses clocks
125 RCC_ClkInitStruct
.ClockType
= RCC_CLOCKTYPE_HCLK
| RCC_CLOCKTYPE_SYSCLK
126 | RCC_CLOCKTYPE_PCLK1
| RCC_CLOCKTYPE_PCLK2
;
127 RCC_ClkInitStruct
.SYSCLKSource
= RCC_SYSCLKSOURCE_PLLCLK
;
128 RCC_ClkInitStruct
.AHBCLKDivider
= RCC_SYSCLK_DIV1
;
129 RCC_ClkInitStruct
.APB1CLKDivider
= RCC_HCLK_DIV2
;
130 RCC_ClkInitStruct
.APB2CLKDivider
= RCC_HCLK_DIV1
;
132 if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct
, FLASH_LATENCY_2
) != HAL_OK
) {
133 _Error_Handler(__FILE__
, __LINE__
);
136 // PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_USART3
137 // | RCC_PERIPHCLK_I2C1;
138 // PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK2;
139 // PeriphClkInit.Usart3ClockSelection = RCC_USART3CLKSOURCE_PCLK1;
140 // PeriphClkInit.I2c1ClockSelection = RCC_I2C1CLKSOURCE_HSI;
141 // if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) {
142 // _Error_Handler(__FILE__, __LINE__);