variant.cpp 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. /*
  2. *******************************************************************************
  3. * Copyright (c) 2019, 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. #include "pins_arduino.h"
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. // Digital PinName array
  18. const PinName digitalPin[] = {
  19. PA_0, //D0
  20. PA_1, //D1
  21. PA_2, //D2
  22. PA_3, //D3
  23. PA_4, //D4
  24. PA_5, //D5
  25. PA_6, //D6
  26. PA_7, //D7
  27. PA_8, //D8
  28. PA_9, //D9
  29. PA_10, //D10
  30. PA_11, //D11
  31. PA_12, //D12
  32. PA_13, //D13
  33. PA_14, //D14
  34. PA_15, //D15
  35. PB_0, //D16
  36. PB_1, //D17
  37. PB_2, //D18
  38. PB_3, //D19
  39. PB_4, //D20
  40. PB_5, //D21
  41. PB_6, //D22
  42. PB_7, //D23
  43. PB_8, //D24
  44. PB_9, //D25
  45. PB_10, //D26
  46. PB_11, //D27
  47. PB_12, //D28
  48. PB_13, //D29
  49. PB_14, //D30
  50. PB_15, //D31
  51. PC_0, //D32
  52. PC_1, //D33
  53. PC_2, //D34
  54. PC_3, //D35
  55. PC_4, //D36
  56. PC_5, //D37
  57. PC_6, //D38
  58. PC_7, //D39
  59. PC_8, //D40
  60. PC_9, //D41
  61. PC_10, //D42
  62. PC_11, //D43
  63. PC_12, //D44
  64. PC_13, //D45
  65. PC_14, //D46
  66. PC_15, //D47
  67. PD_0, //D48
  68. PD_1, //D49
  69. PD_2, //D50
  70. PD_3, //D51
  71. PD_4, //D52
  72. PD_5, //D53
  73. PD_6, //D54
  74. PD_7, //D55
  75. PD_8, //D56
  76. PD_9, //D57
  77. PD_10, //D58
  78. PD_11, //D59
  79. PD_12, //D60
  80. PD_13, //D61
  81. PD_14, //D62
  82. PD_15, //D63
  83. PE_0, //D64
  84. PE_1, //D65
  85. PE_2, //D66
  86. PE_3, //D67
  87. PE_4, //D68
  88. PE_5, //D69
  89. PE_6, //D70
  90. PE_7, //D71
  91. PE_8, //D72
  92. PE_9, //D73
  93. PE_10, //D74
  94. PE_11, //D75
  95. PE_12, //D76
  96. PE_13, //D77
  97. PE_14, //D78
  98. PE_15, //D79
  99. PF_0, //D80
  100. PF_1, //D81
  101. PF_2, //D82
  102. PF_3, //D83
  103. PF_4, //D84
  104. PF_5, //D85
  105. PF_6, //D86
  106. PF_7, //D87
  107. PF_8, //D88
  108. PF_9, //D89
  109. PF_10, //D90
  110. PF_11, //D91
  111. PF_12, //D92
  112. PF_13, //D93
  113. PF_14, //D94
  114. PF_15, //D95
  115. PG_0, //D96
  116. PG_1, //D97
  117. PG_2, //D98
  118. PG_3, //D99
  119. PG_4, //D100
  120. PG_5, //D101
  121. PG_6, //D102
  122. PG_7, //D103
  123. PG_8, //D104
  124. PG_9, //D105
  125. PG_10, //D106
  126. PG_11, //D107
  127. PG_12, //D108
  128. PG_13, //D109
  129. PG_14, //D110
  130. PG_15 //D111
  131. };
  132. // Analog (Ax) pin number array
  133. const uint32_t analogInputPin[] = {
  134. 0, // A0, PA0
  135. 1, // A1, PA1
  136. 2, // A2, PA2
  137. 3, // A3, PA3
  138. 4, // A4, PA4
  139. 5, // A5, PA5
  140. 6, // A6, PA6
  141. 7, // A7, PA7
  142. 16, // A8, PB0
  143. 17, // A9, PB1
  144. 32, // A10, PC0
  145. 33, // A11, PC1
  146. 34, // A12, PC2
  147. 35, // A13, PC3
  148. 36, // A14, PC4
  149. 37, // A15, PC5
  150. 86, // A16, PF6
  151. 87, // A17, PF7
  152. 88, // A18, PF8
  153. 89, // A19, PF9
  154. 90 // A20, PF10
  155. };
  156. #ifdef __cplusplus
  157. }
  158. #endif
  159. // ----------------------------------------------------------------------------
  160. #ifdef __cplusplus
  161. extern "C" {
  162. #endif
  163. /**
  164. * @brief System Clock Configuration
  165. * @param None
  166. * @retval None
  167. */
  168. WEAK void SystemClock_Config(void)
  169. {
  170. RCC_OscInitTypeDef RCC_OscInitStruct = {};
  171. RCC_ClkInitTypeDef RCC_ClkInitStruct = {};
  172. RCC_PeriphCLKInitTypeDef PeriphClkInit = {};
  173. /* Initializes the CPU, AHB and APB busses clocks */
  174. RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
  175. RCC_OscInitStruct.HSEState = RCC_HSE_ON;
  176. RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
  177. RCC_OscInitStruct.HSIState = RCC_HSI_ON;
  178. RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  179. RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
  180. RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9;
  181. if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
  182. Error_Handler();
  183. }
  184. /* Initializes the CPU, AHB and APB busses clocks */
  185. RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK
  186. | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
  187. RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
  188. RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  189. RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
  190. RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
  191. if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) {
  192. Error_Handler();
  193. }
  194. PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC | RCC_PERIPHCLK_USB;
  195. PeriphClkInit.AdcClockSelection = RCC_ADCPCLK2_DIV6;
  196. PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLL_DIV1_5;
  197. if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) {
  198. Error_Handler();
  199. }
  200. }
  201. #ifdef __cplusplus
  202. }
  203. #endif