|
| 1 | +/* |
| 2 | + ******************************************************************************* |
| 3 | + * Copyright (c) 2019, STMicroelectronics |
| 4 | + * All rights reserved. |
| 5 | + * |
| 6 | + * Redistribution and use in source and binary forms, with or without |
| 7 | + * modification, are permitted provided that the following conditions are met: |
| 8 | + * |
| 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. |
| 17 | + * |
| 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 | + ******************************************************************************* |
| 29 | + */ |
| 30 | + |
| 31 | +#if defined(ARDUINO_AGAFIA_SG0) |
| 32 | +#include "pins_arduino.h" |
| 33 | + |
| 34 | +#ifdef __cplusplus |
| 35 | +extern "C" { |
| 36 | +#endif |
| 37 | + |
| 38 | +// Pin number |
| 39 | +const PinName digitalPin[] = { |
| 40 | + PA_10, // D0 |
| 41 | + PA_9, // D1 |
| 42 | + PA_12, // D2 |
| 43 | + PC_6, // D3 - SPI_CLK |
| 44 | + PB_15, // D4 |
| 45 | + PB_14, // D5 |
| 46 | + PA_8, // D6 |
| 47 | + PB_13, // D7 |
| 48 | + PC_7, // D8 |
| 49 | + PB_3, // D9 |
| 50 | + PB_0, // D10 - SPI_CS |
| 51 | + PA_7, // D11 - SPI_MOSI |
| 52 | + PA_6, // D12 - PI_MISO |
| 53 | + PA_5, // D13 - SPI_CLK |
| 54 | + PB_9, // D14 |
| 55 | + PB_8, // D15 |
| 56 | + |
| 57 | + PA_3, // D16 |
| 58 | + PA_2, // D17 |
| 59 | + PA_0, // D18 |
| 60 | + PA_1, // D19 |
| 61 | + |
| 62 | + PA_11, // D20 |
| 63 | + PA_15, // D21 |
| 64 | + PD_0, // D22 |
| 65 | + PD_1, // D23 |
| 66 | + PD_2, // D24 |
| 67 | + PD_3, // D25 |
| 68 | + PD_4, // D26 |
| 69 | + PB_4, // D27 |
| 70 | + PB_5, // D28 |
| 71 | + PB_6, // D29 |
| 72 | + PB_7, // D30 |
| 73 | + |
| 74 | + PA_14, // D31 |
| 75 | + PA_13, // D32 |
| 76 | + |
| 77 | + PF_0, // D33 |
| 78 | + PF_1, // D34 |
| 79 | + PC_13, // D35 |
| 80 | + |
| 81 | + PA_4, // D36/A0 - DAC1 |
| 82 | + PB_12, // D37/A1 |
| 83 | + PB_11, // D38/A2 |
| 84 | + PB_10, // D39/A3 |
| 85 | + PB_2, // D40/A4 |
| 86 | + PB_1 // D41/A5 |
| 87 | +}; |
| 88 | + |
| 89 | +// Analog (Ax) pin number array |
| 90 | +const uint32_t analogInputPin[] = { |
| 91 | + 36, // A0, PA4 |
| 92 | + 37, // A1, PB12 |
| 93 | + 38, // A2, PB11 |
| 94 | + 39, // A3, PB10 |
| 95 | + 40, // A4, PB2 |
| 96 | + 41, // A5, PB1 |
| 97 | +}; |
| 98 | + |
| 99 | + |
| 100 | +#ifdef __cplusplus |
| 101 | +} |
| 102 | +#endif |
| 103 | + |
| 104 | +// ---------------------------------------------------------------------------- |
| 105 | + |
| 106 | +#ifdef __cplusplus |
| 107 | +extern "C" { |
| 108 | +#endif |
| 109 | + |
| 110 | +/** |
| 111 | + * @brief System Clock Configuration |
| 112 | + * The system Clock is configured as follows : |
| 113 | + * System Clock source = PLL (HSI) |
| 114 | + * SYSCLK(Hz) = 64000000 |
| 115 | + * HCLK(Hz) = 64000000 |
| 116 | + * AHB Prescaler = 1 |
| 117 | + * APB1 Prescaler = 1 |
| 118 | + * MSI Frequency(Hz) = 16000000 |
| 119 | + * PLL_M = 1 |
| 120 | + * PLL_N = 8 |
| 121 | + * PLL_R = 2 |
| 122 | + * PLL_P = 2 |
| 123 | + * PLL_Q = 2 |
| 124 | + * Flash Latency(WS) = 2 |
| 125 | + * @param None |
| 126 | + * @retval None |
| 127 | + */ |
| 128 | +WEAK void SystemClock_Config(void) |
| 129 | +{ |
| 130 | + RCC_OscInitTypeDef RCC_OscInitStruct = {}; |
| 131 | + RCC_ClkInitTypeDef RCC_ClkInitStruct = {}; |
| 132 | + |
| 133 | + /* Configure the main internal regulator output voltage */ |
| 134 | + HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1); |
| 135 | + /* Initializes the CPU, AHB and APB busses clocks */ |
| 136 | + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI; |
| 137 | + RCC_OscInitStruct.HSIState = RCC_HSI_ON; |
| 138 | + RCC_OscInitStruct.HSIDiv = RCC_HSI_DIV1; |
| 139 | + RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; |
| 140 | + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; |
| 141 | + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; |
| 142 | + RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV1; |
| 143 | + RCC_OscInitStruct.PLL.PLLN = 8; |
| 144 | + RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; |
| 145 | + RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2; |
| 146 | + RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2; |
| 147 | + if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { |
| 148 | + Error_Handler(); |
| 149 | + } |
| 150 | + /* Initializes the CPU, AHB and APB busses clocks */ |
| 151 | + RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK |
| 152 | + | RCC_CLOCKTYPE_PCLK1; |
| 153 | + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; |
| 154 | + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; |
| 155 | + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; |
| 156 | + |
| 157 | + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) { |
| 158 | + Error_Handler(); |
| 159 | + } |
| 160 | +} |
| 161 | +#ifdef __cplusplus |
| 162 | +} |
| 163 | +#endif |
| 164 | +#endif /* ARDUINO_AGAFIA_SG0 */ |
0 commit comments