|
| 1 | +/* |
| 2 | + ******************************************************************************* |
| 3 | + * Copyright (c) 2011-2021, 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_F439ZI) |
| 14 | +#include "pins_arduino.h" |
| 15 | + |
| 16 | +// Pin number |
| 17 | +// Match Table 17. NUCLEO-F439ZI pin assignments |
| 18 | +// from UM1974 STM32 Nucleo-144 board |
| 19 | +const PinName digitalPin[] = { |
| 20 | + PG_9, //D0 |
| 21 | + PG_14, //D1 |
| 22 | + PF_15, //D2 |
| 23 | + PE_13, //D3 |
| 24 | + PF_14, //D4 |
| 25 | + PE_11, //D5 |
| 26 | + PE_9, //D6 |
| 27 | + PF_13, //D7 |
| 28 | + PF_12, //D8 |
| 29 | + PD_15, //D9 |
| 30 | + PD_14, //D10 |
| 31 | + PA_7, //D11/A10 |
| 32 | + PA_6, //D12/A11 |
| 33 | + PA_5, //D13/A12 |
| 34 | + PB_9, //D14 |
| 35 | + PB_8, //D15 |
| 36 | + PC_6, //D16 |
| 37 | + PB_15, //D17 |
| 38 | + PB_13, //D18 |
| 39 | + PB_12, //D19 |
| 40 | + PA_15, //D20 |
| 41 | + PC_7, //D21 |
| 42 | + PB_5, //D22 |
| 43 | + PB_3, //D23 |
| 44 | + PA_4, //D24/A13 |
| 45 | + PB_4, //D25 |
| 46 | + PB_6, //D26 |
| 47 | + PB_2, //D27 |
| 48 | + PD_13, //D28 |
| 49 | + PD_12, //D29 |
| 50 | + PD_11, //D30 |
| 51 | + PE_2, //D31 |
| 52 | + PA_0, //D32/A14 |
| 53 | + PB_0, //D33/A18 - LED_GREEN |
| 54 | + PE_0, //D34 |
| 55 | + PB_11, //D35 |
| 56 | + PB_10, //D36 |
| 57 | + PE_15, //D37 |
| 58 | + PE_14, //D38 |
| 59 | + PE_12, //D39 |
| 60 | + PE_10, //D40 |
| 61 | + PE_7, //D41 |
| 62 | + PE_8, //D42 |
| 63 | + PC_8, //D43 |
| 64 | + PC_9, //D44 |
| 65 | + PC_10, //D45 |
| 66 | + PC_11, //D46 |
| 67 | + PC_12, //D47 |
| 68 | + PD_2, //D48 |
| 69 | + PG_2, //D49 |
| 70 | + PG_3, //D50 |
| 71 | + PD_7, //D51 |
| 72 | + PD_6, //D52 |
| 73 | + PD_5, //D53 |
| 74 | + PD_4, //D54 |
| 75 | + PD_3, //D55 |
| 76 | + PE_2, //D56 |
| 77 | + PE_4, //D57 |
| 78 | + PE_5, //D58 |
| 79 | + PE_6, //D59 |
| 80 | + PE_3, //D60 |
| 81 | + PF_8, //D61/A15 |
| 82 | + PF_7, //D62/A16 |
| 83 | + PF_9, //D63/A17 |
| 84 | + PG_1, //D64 |
| 85 | + PG_0, //D65 |
| 86 | + PD_1, //D66 |
| 87 | + PD_0, //D67 |
| 88 | + PF_0, //D68 |
| 89 | + PF_1, //D69 |
| 90 | + PF_2, //D70 |
| 91 | + PA_7, //D71 |
| 92 | + NC, //D72 |
| 93 | + PB_7, //D73 - LED_BLUE |
| 94 | + PB_14, //D74 - LED_RED |
| 95 | + PC_13, //D75 - USER_BTN |
| 96 | + PD_9, //D76 - Serial Rx |
| 97 | + PD_8, //D77 - Serial Tx |
| 98 | + PA_3, //D78/A0 |
| 99 | + PC_0, //D79/A1 |
| 100 | + PC_3, //D80/A2 |
| 101 | + PF_3, //D81/A3 |
| 102 | + PF_5, //D82/A4 |
| 103 | + PF_10, //D83/A5 |
| 104 | + PB_1, //D84/A6 |
| 105 | + PC_2, //D85/A7 |
| 106 | + PF_4, //D86/A8 |
| 107 | + PF_6, //D87/A9 |
| 108 | + PA_1, //D88/A19 |
| 109 | + PA_2, //D89/A20 |
| 110 | + PA_8, //D90 |
| 111 | + PA_9, //D91 |
| 112 | + PA_10, //D92 |
| 113 | + PA_11, //D93 |
| 114 | + PA_12, //D94 |
| 115 | + PA_13, //D95 |
| 116 | + PA_14, //D96 |
| 117 | + PC_1, //D97/A21 |
| 118 | + PC_4, //D98/A22 |
| 119 | + PC_5, //D99/A23 |
| 120 | + PC_14, //D100 |
| 121 | + PC_15, //D101 |
| 122 | + PD_10, //D102 |
| 123 | + PE_1, //D103 |
| 124 | + PF_11, //D104 |
| 125 | + PG_4, //D105 |
| 126 | + PG_5, //D106 |
| 127 | + PG_6, //D107 |
| 128 | + PG_7, //D108 |
| 129 | + PG_8, //D109 |
| 130 | + PG_10, //D110 |
| 131 | + PG_11, //D111 |
| 132 | + PG_12, //D112 |
| 133 | + PG_13, //D113 |
| 134 | + PG_15, //D114 |
| 135 | + PH_0, //D115 |
| 136 | + PH_1 //D116 |
| 137 | +}; |
| 138 | + |
| 139 | +// Analog (Ax) pin number array |
| 140 | +const uint32_t analogInputPin[] = { |
| 141 | + 78, //A0 |
| 142 | + 79, //A1 |
| 143 | + 80, //A2 |
| 144 | + 81, //A3 |
| 145 | + 82, //A4 |
| 146 | + 83, //A5 |
| 147 | + 84, //A6 |
| 148 | + 85, //A7 |
| 149 | + 86, //A8 |
| 150 | + 87, //A9 |
| 151 | + 11, //A10 |
| 152 | + 12, //A11 |
| 153 | + 13, //A12 |
| 154 | + 24, //A13 |
| 155 | + 32, //A14 |
| 156 | + 61, //A15 |
| 157 | + 62, //A16 |
| 158 | + 63, //A17 |
| 159 | + 33, //A18 |
| 160 | + 88, //A19 |
| 161 | + 89, //A20 |
| 162 | + 97, //A21 |
| 163 | + 98, //A22 |
| 164 | + 99 //A23 |
| 165 | +}; |
| 166 | + |
| 167 | +// ---------------------------------------------------------------------------- |
| 168 | + |
| 169 | +#ifdef __cplusplus |
| 170 | +extern "C" { |
| 171 | +#endif |
| 172 | + |
| 173 | +/** |
| 174 | + * @brief System Clock Configuration |
| 175 | + * The system Clock is configured as follow : |
| 176 | + * System Clock source = PLL (HSE) |
| 177 | + * SYSCLK(Hz) = 168000000 |
| 178 | + * HCLK(Hz) = 168000000 |
| 179 | + * AHB Prescaler = 1 |
| 180 | + * APB1 Prescaler = 4 |
| 181 | + * APB2 Prescaler = 2 |
| 182 | + * HSE Frequency(Hz) = 8000000 |
| 183 | + * PLL_M = 8 |
| 184 | + * PLL_N = 336 |
| 185 | + * PLL_P = 2 |
| 186 | + * PLL_Q = 7 |
| 187 | + * VDD(V) = 3.3 |
| 188 | + * Main regulator output voltage = Scale1 mode |
| 189 | + * Flash Latency(WS) = 5 |
| 190 | + * @param None |
| 191 | + * @retval None |
| 192 | + */ |
| 193 | +WEAK void SystemClock_Config(void) |
| 194 | +{ |
| 195 | + RCC_ClkInitTypeDef RCC_ClkInitStruct = {}; |
| 196 | + RCC_OscInitTypeDef RCC_OscInitStruct = {}; |
| 197 | + |
| 198 | + /* Enable Power Control clock */ |
| 199 | + __HAL_RCC_PWR_CLK_ENABLE(); |
| 200 | + |
| 201 | + /* The voltage scaling allows optimizing the power consumption when the device is |
| 202 | + clocked below the maximum system frequency, to update the voltage scaling value |
| 203 | + regarding system frequency refer to product datasheet. */ |
| 204 | + __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); |
| 205 | + |
| 206 | + /* Enable HSE Oscillator and activate PLL with HSE as source */ |
| 207 | + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; |
| 208 | + RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS; |
| 209 | + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; |
| 210 | + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; |
| 211 | + RCC_OscInitStruct.PLL.PLLM = 8; |
| 212 | + RCC_OscInitStruct.PLL.PLLN = 336; |
| 213 | + RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; |
| 214 | + RCC_OscInitStruct.PLL.PLLQ = 7; |
| 215 | + HAL_RCC_OscConfig(&RCC_OscInitStruct); |
| 216 | + |
| 217 | + HAL_PWREx_EnableOverDrive(); |
| 218 | + |
| 219 | + /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 |
| 220 | + clocks dividers */ |
| 221 | + RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | |
| 222 | + RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); |
| 223 | + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; |
| 224 | + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; |
| 225 | + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; |
| 226 | + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; |
| 227 | + HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5); |
| 228 | + |
| 229 | + /* Ensure CCM RAM clock is enabled */ |
| 230 | + __HAL_RCC_CCMDATARAMEN_CLK_ENABLE(); |
| 231 | +} |
| 232 | + |
| 233 | +#ifdef __cplusplus |
| 234 | +} |
| 235 | +#endif |
| 236 | + |
| 237 | +#endif /* ARDUINO_NUCLEO_F439ZI */ |
0 commit comments