|
| 1 | +/* |
| 2 | + ******************************************************************************* |
| 3 | + * Copyright (c) 2020-2026, 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_H533RE) |
| 14 | +#include "pins_arduino.h" |
| 15 | + |
| 16 | +// Digital PinName array |
| 17 | +const PinName digitalPin[] = { |
| 18 | + PB_15, //D0 |
| 19 | + PB_14, //D1 |
| 20 | + PC_8, //D2 |
| 21 | + PB_3, //D3 |
| 22 | + PB_5, //D4 |
| 23 | + PB_4, //D5 |
| 24 | + PB_10, //D6 |
| 25 | + PA_8, //D7 |
| 26 | + PC_7, //D8 |
| 27 | + PC_6, //D9 |
| 28 | + PC_9, //D10 |
| 29 | + PA_7, //D11/A10 |
| 30 | + PA_6, //D12A11 |
| 31 | + PA_5, //D13/A12 |
| 32 | + PB_7, //D14 |
| 33 | + PB_6, //D15 |
| 34 | + PC_10, //D16 |
| 35 | + PC_12, //D17 |
| 36 | + PA_13, //D18 |
| 37 | + PA_14, //D19 |
| 38 | + PA_15, //D20 |
| 39 | + PC_13, //D21 |
| 40 | + PC_14, //D22 |
| 41 | + PC_15, //D23 |
| 42 | + PH_0, //D24 |
| 43 | + PH_1, //D25 |
| 44 | + PC_2, //D26/A6 |
| 45 | + PC_3, //D27/A7 |
| 46 | + PC_11, //D28 |
| 47 | + PD_2, //D29 |
| 48 | + PA_0, //D30/A0 |
| 49 | + PA_1, //D31/A1 |
| 50 | + PB_1, //D32/A2 |
| 51 | + PB_0, //D33/A3 |
| 52 | + PC_1, //D34/A4 |
| 53 | + PC_0, //D35/A5 |
| 54 | + PA_9, //D36 |
| 55 | + PA_10, //D37 |
| 56 | + PC_5, //D38/A8 |
| 57 | + PA_12, //D39 |
| 58 | + PA_11, //D40 |
| 59 | + PB_12, //D41 |
| 60 | + PB_2, //D42 |
| 61 | + PB_15, //D43 |
| 62 | + PB_14, //D44 |
| 63 | + PB_13, //D45 |
| 64 | + PC_4, //D46/A9 |
| 65 | + PB_8, //D47 |
| 66 | + PA_2, //D48/A13 |
| 67 | + PA_3, //D49/A14 |
| 68 | + PA_4 //D50/A15 |
| 69 | +}; |
| 70 | + |
| 71 | +// Analog (Ax) pin number array |
| 72 | +const pin_size_t analogInputPin[] = { |
| 73 | + 30, // A0, PA0 |
| 74 | + 31, // A1, PA1 |
| 75 | + 32, // A2, PB1 |
| 76 | + 33, // A3, PB0 |
| 77 | + 34, // A4, PC1 |
| 78 | + 35, // A5, PC0 |
| 79 | + 26, // A6, PC2 |
| 80 | + 27, // A7, PC3 |
| 81 | + 38, // A8, PC5 |
| 82 | + 46, // A9, PC4 |
| 83 | + 11, // A10, PA7 |
| 84 | + 12, // A11, PA6 |
| 85 | + 13, // A12, PA5 |
| 86 | + 48, // A13, PA2 |
| 87 | + 49, // A14, PA3 |
| 88 | + 50 // A15, PA4 |
| 89 | +}; |
| 90 | + |
| 91 | +#ifdef __cplusplus |
| 92 | +extern "C" { |
| 93 | +#endif |
| 94 | + |
| 95 | +/** |
| 96 | + * @brief System Clock Configuration |
| 97 | + * @param None |
| 98 | + * @retval None |
| 99 | + */ |
| 100 | +WEAK void SystemClock_Config(void) |
| 101 | +{ |
| 102 | + RCC_OscInitTypeDef RCC_OscInitStruct = {}; |
| 103 | + RCC_ClkInitTypeDef RCC_ClkInitStruct = {}; |
| 104 | + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {}; |
| 105 | + RCC_CRSInitTypeDef RCC_CRSInitStruct = {}; |
| 106 | + |
| 107 | + /* Configure the main internal regulator output voltage */ |
| 108 | + __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE0); |
| 109 | + |
| 110 | + while (!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {} |
| 111 | + |
| 112 | + /** Configure LSE Drive Capability |
| 113 | + * Warning : Only applied when the LSE is disabled. |
| 114 | + */ |
| 115 | + HAL_PWR_EnableBkUpAccess(); |
| 116 | + __HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_LOW); |
| 117 | + |
| 118 | + /** Initializes the RCC Oscillators according to the specified parameters |
| 119 | + * in the RCC_OscInitTypeDef structure. |
| 120 | + */ |
| 121 | + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48 | RCC_OSCILLATORTYPE_HSI |
| 122 | + | RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_LSE; |
| 123 | + RCC_OscInitStruct.HSEState = RCC_HSE_ON; |
| 124 | + RCC_OscInitStruct.LSEState = RCC_LSE_ON; |
| 125 | + RCC_OscInitStruct.HSIState = RCC_HSI_ON; |
| 126 | + RCC_OscInitStruct.HSIDiv = RCC_HSI_DIV2; |
| 127 | + RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; |
| 128 | + RCC_OscInitStruct.HSI48State = RCC_HSI48_ON; |
| 129 | + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; |
| 130 | + RCC_OscInitStruct.PLL.PLLSource = RCC_PLL1_SOURCE_HSE; |
| 131 | + RCC_OscInitStruct.PLL.PLLM = 6; |
| 132 | + RCC_OscInitStruct.PLL.PLLN = 125; |
| 133 | + RCC_OscInitStruct.PLL.PLLP = 2; |
| 134 | + RCC_OscInitStruct.PLL.PLLQ = 4; |
| 135 | + RCC_OscInitStruct.PLL.PLLR = 2; |
| 136 | + RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1_VCIRANGE_2; |
| 137 | + RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1_VCORANGE_WIDE; |
| 138 | + RCC_OscInitStruct.PLL.PLLFRACN = 0; |
| 139 | + if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { |
| 140 | + Error_Handler(); |
| 141 | + } |
| 142 | + |
| 143 | + /* Initializes the CPU, AHB and APB buses clocks */ |
| 144 | + RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK |
| 145 | + | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2 |
| 146 | + | RCC_CLOCKTYPE_PCLK3; |
| 147 | + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; |
| 148 | + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; |
| 149 | + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; |
| 150 | + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; |
| 151 | + RCC_ClkInitStruct.APB3CLKDivider = RCC_HCLK_DIV1; |
| 152 | + |
| 153 | + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK) { |
| 154 | + Error_Handler(); |
| 155 | + } |
| 156 | + /* Initializes the peripherals clock */ |
| 157 | + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_ADCDAC | RCC_PERIPHCLK_DAC |
| 158 | + | RCC_PERIPHCLK_LPUART1 | RCC_PERIPHCLK_SDMMC1 |
| 159 | + | RCC_PERIPHCLK_SPI1 | RCC_PERIPHCLK_SPI2 |
| 160 | + | RCC_PERIPHCLK_SPI3 | RCC_PERIPHCLK_SPI4 |
| 161 | + | RCC_PERIPHCLK_USB;; |
| 162 | + PeriphClkInitStruct.DacLowPowerClockSelection = RCC_DACLPCLKSOURCE_LSE; |
| 163 | + PeriphClkInitStruct.AdcDacClockSelection = RCC_ADCDACCLKSOURCE_HCLK; |
| 164 | + PeriphClkInitStruct.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_HSI; |
| 165 | + PeriphClkInitStruct.Sdmmc1ClockSelection = RCC_SDMMC1CLKSOURCE_PLL1Q; |
| 166 | + PeriphClkInitStruct.Spi1ClockSelection = RCC_SPI1CLKSOURCE_PLL1Q; |
| 167 | + PeriphClkInitStruct.Spi2ClockSelection = RCC_SPI2CLKSOURCE_PLL1Q; |
| 168 | + PeriphClkInitStruct.Spi3ClockSelection = RCC_SPI3CLKSOURCE_PLL1Q; |
| 169 | + PeriphClkInitStruct.PLL2.PLL2Source = RCC_PLL2_SOURCE_HSE; |
| 170 | + PeriphClkInitStruct.PLL2.PLL2M = 6; |
| 171 | + PeriphClkInitStruct.PLL2.PLL2N = 125; |
| 172 | + PeriphClkInitStruct.PLL2.PLL2P = 2; |
| 173 | + PeriphClkInitStruct.PLL2.PLL2Q = 4; |
| 174 | + PeriphClkInitStruct.PLL2.PLL2R = 2; |
| 175 | + PeriphClkInitStruct.PLL2.PLL2RGE = RCC_PLL2_VCIRANGE_2; |
| 176 | + PeriphClkInitStruct.PLL2.PLL2VCOSEL = RCC_PLL2_VCORANGE_WIDE; |
| 177 | + PeriphClkInitStruct.PLL2.PLL2FRACN = 0.0; |
| 178 | + PeriphClkInitStruct.PLL2.PLL2ClockOut = RCC_PLL2_DIVQ; |
| 179 | + PeriphClkInitStruct.Spi4ClockSelection = RCC_SPI4CLKSOURCE_PLL2Q; |
| 180 | + PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_HSI48; |
| 181 | + |
| 182 | + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) { |
| 183 | + Error_Handler(); |
| 184 | + } |
| 185 | + |
| 186 | + |
| 187 | + /* Enable the CRS APB clock */ |
| 188 | + __HAL_RCC_CRS_CLK_ENABLE(); |
| 189 | + |
| 190 | + /* Configures CRS */ |
| 191 | + RCC_CRSInitStruct.Prescaler = RCC_CRS_SYNC_DIV1; |
| 192 | + RCC_CRSInitStruct.Source = RCC_CRS_SYNC_SOURCE_LSE; |
| 193 | + RCC_CRSInitStruct.Polarity = RCC_CRS_SYNC_POLARITY_RISING; |
| 194 | + RCC_CRSInitStruct.ReloadValue = __HAL_RCC_CRS_RELOADVALUE_CALCULATE(48000000, 32768); |
| 195 | + RCC_CRSInitStruct.ErrorLimitValue = 34; |
| 196 | + RCC_CRSInitStruct.HSI48CalibrationValue = 32; |
| 197 | + |
| 198 | + HAL_RCCEx_CRSConfig(&RCC_CRSInitStruct); |
| 199 | + |
| 200 | + /* Configure the programming delay */ |
| 201 | + __HAL_FLASH_SET_PROGRAM_DELAY(FLASH_PROGRAMMING_DELAY_2); |
| 202 | +} |
| 203 | + |
| 204 | +#ifdef __cplusplus |
| 205 | +} |
| 206 | +#endif |
| 207 | +#endif /* ARDUINO_NUCLEO_H533RE */ |
0 commit comments