|  | 
|  | 1 | +/* | 
|  | 2 | + ******************************************************************************* | 
|  | 3 | + * Copyright (c) 2020, 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_DATABOARD) | 
|  | 14 | +#include "pins_arduino.h" | 
|  | 15 | + | 
|  | 16 | +// Digital PinName array | 
|  | 17 | +const PinName digitalPin[] = { | 
|  | 18 | +  PA_0,   // D0/A0 | 
|  | 19 | +  PA_1,   // D1/A1 | 
|  | 20 | +  PA_2,   // D2/A2 | 
|  | 21 | +  PA_3,   // D3/A3 | 
|  | 22 | +  PA_4,   // D4/A4 | 
|  | 23 | +  PA_5,   // D5/A5 | 
|  | 24 | +  PA_6,   // D6/A6 | 
|  | 25 | +  PA_7,   // D7/A7 | 
|  | 26 | +  PA_8,   // D8 | 
|  | 27 | +  PA_9,   // D9 | 
|  | 28 | +  PA_10,  // D10 | 
|  | 29 | +  PA_11,  // D11 | 
|  | 30 | +  PA_12,  // D12 | 
|  | 31 | +  PA_13,  // D13 | 
|  | 32 | +  PA_14,  // D14 | 
|  | 33 | +  PA_15,  // D15 | 
|  | 34 | +  PB_0,   // D16/A8 | 
|  | 35 | +  PB_1,   // D17/A9 | 
|  | 36 | +  PB_2,   // D18 | 
|  | 37 | +  PB_3,   // D19 | 
|  | 38 | +  PB_4,   // D20 | 
|  | 39 | +  PB_5,   // D21 | 
|  | 40 | +  PB_6,   // D22 | 
|  | 41 | +  PB_7,   // D23 | 
|  | 42 | +  PB_8,   // D24 | 
|  | 43 | +  PB_9,   // D25 | 
|  | 44 | +  PB_10,  // D26 | 
|  | 45 | +  PB_11,  // D27 | 
|  | 46 | +  PB_12,  // D28 | 
|  | 47 | +  PB_13,  // D29 | 
|  | 48 | +  PB_14,  // D30 | 
|  | 49 | +  PB_15,  // D31 | 
|  | 50 | +  PC_13,  // D32 | 
|  | 51 | +  PC_14,  // D33 | 
|  | 52 | +  PC_15,  // D34 | 
|  | 53 | +  PD_0,   // D35 | 
|  | 54 | +  PD_1    // D36 | 
|  | 55 | +}; | 
|  | 56 | + | 
|  | 57 | +// Analog (Ax) pin number array | 
|  | 58 | +const uint32_t analogInputPin[] = { | 
|  | 59 | +  0,  // A0,  PA0 | 
|  | 60 | +  1,  // A1,  PA1 | 
|  | 61 | +  2,  // A2,  PA2 | 
|  | 62 | +  3,  // A3,  PA3 | 
|  | 63 | +  4,  // A4,  PA4 | 
|  | 64 | +  5,  // A5,  PA5 | 
|  | 65 | +  6,  // A6,  PA6 | 
|  | 66 | +  7,  // A7,  PA7 | 
|  | 67 | +  16, // A8,  PB0 | 
|  | 68 | +  17  // A9,  PB1 | 
|  | 69 | +}; | 
|  | 70 | + | 
|  | 71 | + | 
|  | 72 | +// ---------------------------------------------------------------------------- | 
|  | 73 | + | 
|  | 74 | +#ifdef __cplusplus | 
|  | 75 | +extern "C" { | 
|  | 76 | +#endif | 
|  | 77 | + | 
|  | 78 | +/** | 
|  | 79 | +  * @brief  System Clock Configuration | 
|  | 80 | +  *         The system Clock is configured as follow : | 
|  | 81 | +  *            System Clock source            = PLL (HSE) | 
|  | 82 | +  *            SYSCLK(Hz)                     = 72000000 | 
|  | 83 | +  *            HCLK(Hz)                       = 72000000 | 
|  | 84 | +  *            AHB Prescaler                  = 1 | 
|  | 85 | +  *            APB1 Prescaler                 = 2 | 
|  | 86 | +  *            APB2 Prescaler                 = 1 | 
|  | 87 | +  *            PLL_Source                     = HSE | 
|  | 88 | +  *            PLL_Mul                        = 9 | 
|  | 89 | +  *            Flash Latency(WS)              = 2 | 
|  | 90 | +  *            ADC Prescaler                  = 6 | 
|  | 91 | +  *            USB Prescaler                  = 1.5 | 
|  | 92 | +  * @param  None | 
|  | 93 | +  * @retval None | 
|  | 94 | +  */ | 
|  | 95 | +WEAK void SystemClock_Config(void) | 
|  | 96 | +{ | 
|  | 97 | +  RCC_OscInitTypeDef RCC_OscInitStruct = {}; | 
|  | 98 | +  RCC_ClkInitTypeDef RCC_ClkInitStruct = {}; | 
|  | 99 | +  RCC_PeriphCLKInitTypeDef PeriphClkInit = {}; | 
|  | 100 | + | 
|  | 101 | +  /* Initializes the CPU, AHB and APB busses clocks */ | 
|  | 102 | +  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; | 
|  | 103 | +  RCC_OscInitStruct.HSEState = RCC_HSE_ON; | 
|  | 104 | +  RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV2; | 
|  | 105 | +  RCC_OscInitStruct.HSIState = RCC_HSI_ON; | 
|  | 106 | +  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; | 
|  | 107 | +  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; | 
|  | 108 | +  RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9; | 
|  | 109 | +  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { | 
|  | 110 | +    Error_Handler(); | 
|  | 111 | +  } | 
|  | 112 | + | 
|  | 113 | +  /* Initializes the CPU, AHB and APB busses clocks */ | 
|  | 114 | +  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | 
|  | 115 | +                                | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2; | 
|  | 116 | +  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; | 
|  | 117 | +  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; | 
|  | 118 | +  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; | 
|  | 119 | +  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; | 
|  | 120 | + | 
|  | 121 | +  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) { | 
|  | 122 | +    Error_Handler(); | 
|  | 123 | +  } | 
|  | 124 | + | 
|  | 125 | +  PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC | RCC_PERIPHCLK_USB; | 
|  | 126 | +  PeriphClkInit.AdcClockSelection = RCC_ADCPCLK2_DIV6; | 
|  | 127 | +  PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLL_DIV1_5; | 
|  | 128 | +  if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) { | 
|  | 129 | +    Error_Handler(); | 
|  | 130 | +  } | 
|  | 131 | +} | 
|  | 132 | + | 
|  | 133 | +#ifdef __cplusplus | 
|  | 134 | +} | 
|  | 135 | +#endif | 
|  | 136 | + | 
|  | 137 | + | 
|  | 138 | + | 
|  | 139 | +#endif /* ARDUINO_DATABOARD */ | 
0 commit comments