|
| 1 | +/* |
| 2 | + ******************************************************************************* |
| 3 | + * Copyright (c) 2022, STMicroelectronics |
| 4 | + * All rights reserved. |
| 5 | + * |
| 6 | + * This software component is licensed by ST under BSD 3-Clause license, |
| 7 | + * the "License"; You may not use this file except in compliance with the |
| 8 | + * License. You may obtain a copy of the License at: |
| 9 | + * opensource.org/licenses/BSD-3-Clause |
| 10 | + * |
| 11 | + ******************************************************************************* |
| 12 | + */ |
| 13 | +#if defined(ARDUINO_NUCLEO_H7A3ZI_Q) |
| 14 | +#include "pins_arduino.h" |
| 15 | + |
| 16 | +// Pin number |
| 17 | +const PinName digitalPin[] = { |
| 18 | + PB_7, |
| 19 | + PB_6, |
| 20 | + PG_14, |
| 21 | + PE_13, |
| 22 | + PE_14, |
| 23 | + PE_11, |
| 24 | + PA_8, |
| 25 | + PG_12, |
| 26 | + PG_9, |
| 27 | + PD_15, |
| 28 | + PD_14, |
| 29 | + PA_7, |
| 30 | + PA_6, |
| 31 | + PA_5, |
| 32 | + PB_9, |
| 33 | + PB_8, |
| 34 | + PC_6, |
| 35 | + PB_15, |
| 36 | + PB_13, |
| 37 | + PB_12, |
| 38 | + PA_15, |
| 39 | + PC_7, |
| 40 | + PB_5, |
| 41 | + PB_3, |
| 42 | + PA_4, |
| 43 | + PB_4, |
| 44 | + PG_6, |
| 45 | + PB_2, |
| 46 | + PD_13, |
| 47 | + PD_12, |
| 48 | + PD_11, |
| 49 | + PE_2, |
| 50 | + PA_0, |
| 51 | + PB_0, |
| 52 | + PE_0, |
| 53 | + PB_11, |
| 54 | + PB_10, |
| 55 | + PE_15, |
| 56 | + PE_6, |
| 57 | + PE_12, |
| 58 | + PE_10, |
| 59 | + PE_7, |
| 60 | + PE_8, |
| 61 | + PC_8, |
| 62 | + PC_9, |
| 63 | + PC_10, |
| 64 | + PC_11, |
| 65 | + PC_12, |
| 66 | + PD_2, |
| 67 | + PG_10, |
| 68 | + PG_8, |
| 69 | + PD_7, |
| 70 | + PD_6, |
| 71 | + PD_5, |
| 72 | + PD_4, |
| 73 | + PD_3, |
| 74 | + PE_2, |
| 75 | + PE_4, |
| 76 | + PE_5, |
| 77 | + PE_6, |
| 78 | + PE_3, |
| 79 | + PF_8, |
| 80 | + PF_7, |
| 81 | + PF_9, |
| 82 | + PD_10, |
| 83 | + PB_14, |
| 84 | + PD_1, |
| 85 | + PD_0, |
| 86 | + PF_15, |
| 87 | + PF_14, |
| 88 | + PB_5, |
| 89 | + PE_9, |
| 90 | + PB_2, |
| 91 | + PA_3, |
| 92 | + PC_0, |
| 93 | + PC_3_C, |
| 94 | + PB_1, |
| 95 | + PC_2_C, |
| 96 | + PF_11, |
| 97 | + PC_1, |
| 98 | + PC_5, |
| 99 | + PA_2, |
| 100 | + PA_1, |
| 101 | + PA_9, |
| 102 | + PA_10, |
| 103 | + PA_11, |
| 104 | + PA_12, |
| 105 | + PA_13, |
| 106 | + PA_14, |
| 107 | + PC_4, |
| 108 | + PC_13, |
| 109 | + PC_14, |
| 110 | + PC_15, |
| 111 | + PD_8, |
| 112 | + PD_9, |
| 113 | + PE_1, |
| 114 | + PF_6, |
| 115 | + PF_10, |
| 116 | + PG_7, |
| 117 | + PG_11, |
| 118 | + PG_13, |
| 119 | + PH_0, |
| 120 | + PH_1 |
| 121 | +}; |
| 122 | + |
| 123 | +// Analog (Ax) pin number array |
| 124 | +const uint32_t analogInputPin[] = { |
| 125 | + 73, // A0 |
| 126 | + 74, // A1 |
| 127 | + 75, // A2 |
| 128 | + 76, // A3 |
| 129 | + 77, // A4 |
| 130 | + 78, // A5 |
| 131 | + 79, // A6 |
| 132 | + 80, // A7 |
| 133 | + 81, // A8 |
| 134 | + 82, // A9 |
| 135 | + 89, // A10 |
| 136 | + 11, // A11 |
| 137 | + 12, // A12 |
| 138 | + 13, // A13 |
| 139 | + 24, // A14 |
| 140 | + 32, // A15 |
| 141 | + 33, // A16 |
| 142 | + 69 // A17 |
| 143 | +}; |
| 144 | + |
| 145 | +// ---------------------------------------------------------------------------- |
| 146 | + |
| 147 | +#ifdef __cplusplus |
| 148 | +extern "C" { |
| 149 | +#endif |
| 150 | + |
| 151 | +/** |
| 152 | + * @brief System Clock Configuration |
| 153 | + * @param None |
| 154 | + * @retval None |
| 155 | + */ |
| 156 | +WEAK void SystemClock_Config(void) |
| 157 | +{ |
| 158 | + RCC_OscInitTypeDef RCC_OscInitStruct = {}; |
| 159 | + RCC_ClkInitTypeDef RCC_ClkInitStruct = {}; |
| 160 | + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {}; |
| 161 | + |
| 162 | + /*AXI clock gating */ |
| 163 | + RCC->CKGAENR = 0xFFFFFFFF; |
| 164 | + |
| 165 | + /** Supply configuration update enable |
| 166 | + */ |
| 167 | + HAL_PWREx_ConfigSupply(PWR_DIRECT_SMPS_SUPPLY); |
| 168 | + |
| 169 | + /** Configure the main internal regulator output voltage |
| 170 | + */ |
| 171 | + __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE0); |
| 172 | + |
| 173 | + while (!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {} |
| 174 | + |
| 175 | + /** Initializes the RCC Oscillators according to the specified parameters |
| 176 | + * in the RCC_OscInitTypeDef structure. |
| 177 | + */ |
| 178 | + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48 | RCC_OSCILLATORTYPE_HSE; |
| 179 | + RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS; |
| 180 | + RCC_OscInitStruct.HSI48State = RCC_HSI48_ON; |
| 181 | + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; |
| 182 | + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; |
| 183 | + RCC_OscInitStruct.PLL.PLLM = 1; |
| 184 | + RCC_OscInitStruct.PLL.PLLN = 70; |
| 185 | + RCC_OscInitStruct.PLL.PLLP = 2; |
| 186 | + RCC_OscInitStruct.PLL.PLLQ = 4; |
| 187 | + RCC_OscInitStruct.PLL.PLLR = 2; |
| 188 | + RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_3; |
| 189 | + RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE; |
| 190 | + RCC_OscInitStruct.PLL.PLLFRACN = 0; |
| 191 | + if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { |
| 192 | + Error_Handler(); |
| 193 | + } |
| 194 | + |
| 195 | + /** Initializes the CPU, AHB and APB buses clocks |
| 196 | + */ |
| 197 | + RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK |
| 198 | + | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2 |
| 199 | + | RCC_CLOCKTYPE_D3PCLK1 | RCC_CLOCKTYPE_D1PCLK1; |
| 200 | + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; |
| 201 | + RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1; |
| 202 | + RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV1; |
| 203 | + RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV2; |
| 204 | + RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2; |
| 205 | + RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2; |
| 206 | + RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV2; |
| 207 | + |
| 208 | + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_6) != HAL_OK) { |
| 209 | + Error_Handler(); |
| 210 | + } |
| 211 | + |
| 212 | + /** Initializes the peripherals clock |
| 213 | + */ |
| 214 | + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LPUART1 | RCC_PERIPHCLK_USB; |
| 215 | + PeriphClkInitStruct.PLL3.PLL3M = 1; |
| 216 | + PeriphClkInitStruct.PLL3.PLL3N = 24; |
| 217 | + PeriphClkInitStruct.PLL3.PLL3P = 2; |
| 218 | + PeriphClkInitStruct.PLL3.PLL3Q = 6; |
| 219 | + PeriphClkInitStruct.PLL3.PLL3R = 2; |
| 220 | + PeriphClkInitStruct.PLL3.PLL3RGE = RCC_PLL3VCIRANGE_3; |
| 221 | + PeriphClkInitStruct.PLL3.PLL3VCOSEL = RCC_PLL3VCOWIDE; |
| 222 | + PeriphClkInitStruct.PLL3.PLL3FRACN = 0; |
| 223 | + PeriphClkInitStruct.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_PLL3; |
| 224 | + PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_HSI48; |
| 225 | + |
| 226 | + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) { |
| 227 | + Error_Handler(); |
| 228 | + } |
| 229 | + |
| 230 | +} |
| 231 | + |
| 232 | +#ifdef __cplusplus |
| 233 | +} |
| 234 | +#endif |
| 235 | +#endif /* ARDUINO_H7A3ZI_Q */ |
0 commit comments