variant.cpp 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /*
  2. Copyright (c) 2011 Arduino. All right reserved.
  3. This library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. This library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. See the GNU Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with this library; if not, write to the Free Software
  13. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  14. */
  15. #include "pins_arduino.h"
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. // Digital PinName array
  20. const PinName digitalPin[] = {
  21. PA_0, // Digital pin 0
  22. PA_1, // Digital pin 1
  23. PA_2, // Digital pin 2
  24. PA_3, // Digital pin 3
  25. PA_4, // Digital pin 4
  26. PA_5, // Digital pin 5
  27. PA_6, // Digital pin 6
  28. PA_7, // Digital pin 7
  29. PA_8, // Digital pin 8
  30. PA_9, // Digital pin 9
  31. PA_10, // Digital pin 10
  32. PA_11, // Digital pin 11
  33. PA_12, // Digital pin 12
  34. PA_13, // Digital pin 13
  35. PA_14, // Digital pin 14
  36. PA_15, // Digital pin 15
  37. PB_0, // Digital pin 16
  38. PB_1, // Digital pin 17
  39. PB_2, // Digital pin 18
  40. PB_3, // Digital pin 19
  41. PB_4, // Digital pin 20
  42. PB_5, // Digital pin 21
  43. PB_6, // Digital pin 22
  44. PB_7, // Digital pin 23
  45. PB_8, // Digital pin 24
  46. PB_9, // Digital pin 25
  47. PB_10, // Digital pin 26
  48. PB_11, // Digital pin 27
  49. PB_12, // Digital pin 28
  50. PB_13, // Digital pin 29
  51. PB_14, // Digital pin 30
  52. PB_15, // Digital pin 31
  53. PC_0, // Digital pin 32
  54. PC_1, // Digital pin 33
  55. PC_2, // Digital pin 34
  56. PC_3, // Digital pin 35
  57. PC_4, // Digital pin 36
  58. PC_5, // Digital pin 37
  59. PC_6, // Digital pin 38
  60. PC_7, // Digital pin 39
  61. PC_8, // Digital pin 40
  62. PC_9, // Digital pin 41
  63. PC_10, // Digital pin 42
  64. PC_11, // Digital pin 43
  65. PC_12, // Digital pin 44
  66. PC_13, // Digital pin 45
  67. PC_14, // Digital pin 46
  68. PC_15, // Digital pin 47
  69. PD_2, // Digital pin 48
  70. PH_0, // Digital pin 49, used by the external oscillator
  71. PH_1 // Digital pin 40, used by the external oscillator
  72. };
  73. // Analog (Ax) pin number array
  74. const uint32_t analogInputPin[] = {
  75. 0, // A0, PA0
  76. 1, // A1, PA1
  77. 2, // A2, PA2
  78. 3, // A3, PA3
  79. 4, // A4, PA4
  80. 5, // A5, PA5
  81. 6, // A6, PA6
  82. 7, // A7, PA7
  83. 16, // A8, PB0
  84. 17, // A9, PB1
  85. 32, // A10, PC0
  86. 33, // A11, PC1
  87. 34, // A12, PC2
  88. 35, // A13, PC3
  89. 36, // A14, PC4
  90. 37 // A15, PC5
  91. };
  92. #ifdef __cplusplus
  93. }
  94. #endif
  95. // ----------------------------------------------------------------------------
  96. #ifdef __cplusplus
  97. extern "C" {
  98. #endif
  99. /*
  100. * @brief Configures the System clock source, PLL Multiplier and Divider factors,
  101. * AHB/APBx prescalers and Flash settings
  102. * @note This function should be called only once the RCC clock configuration
  103. * is reset to the default reset state (done in SystemInit() function).
  104. * @param None
  105. * @retval None
  106. */
  107. /******************************************************************************/
  108. /* PLL (clocked by HSE) used as System clock source */
  109. /******************************************************************************/
  110. WEAK void SetSysClock_PLL_HSE(void) {
  111. RCC_OscInitTypeDef RCC_OscInitStruct;
  112. RCC_ClkInitTypeDef RCC_ClkInitStruct;
  113. /**Configure the main internal regulator output voltage
  114. */
  115. __HAL_RCC_PWR_CLK_ENABLE();
  116. __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
  117. /**Initializes the CPU, AHB and APB busses clocks
  118. */
  119. RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
  120. RCC_OscInitStruct.HSEState = RCC_HSE_ON;
  121. RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  122. RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
  123. RCC_OscInitStruct.PLL.PLLM = (HSE_VALUE / 1000000);
  124. RCC_OscInitStruct.PLL.PLLN = 336;
  125. RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
  126. RCC_OscInitStruct.PLL.PLLQ = 7;
  127. if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  128. _Error_Handler(__FILE__, __LINE__);
  129. /**Initializes the CPU, AHB and APB busses clocks
  130. */
  131. RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK
  132. | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
  133. RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
  134. RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  135. RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
  136. RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
  137. if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK)
  138. _Error_Handler(__FILE__, __LINE__);
  139. }
  140. WEAK void SystemClock_Config(void) {
  141. SetSysClock_PLL_HSE();
  142. /* Ensure CCM RAM clock is enabled */
  143. __HAL_RCC_CCMDATARAMEN_CLK_ENABLE();
  144. /* Output clock on MCO2 pin(PC9) for debugging purpose */
  145. //HAL_RCC_MCOConfig(RCC_MCO2, RCC_MCO2SOURCE_SYSCLK, RCC_MCODIV_4);
  146. }
  147. #ifdef __cplusplus
  148. }
  149. #endif