variant.cpp 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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. // Pin number
  20. const PinName digitalPin[] = {
  21. PA_0, //D0
  22. PA_1, //D1
  23. PA_2, //D2
  24. PA_3, //D3
  25. PA_4, //D4
  26. PA_5, //D5
  27. PA_6, //D6
  28. PA_7, //D7
  29. PA_8, //D8
  30. PA_9, //D9
  31. PA_10, //D10
  32. PA_11, //D11
  33. PA_12, //D12
  34. PA_13, //D13
  35. PA_14, //D14
  36. PA_15, //D15
  37. PB_0, //D16
  38. PB_1, //D17
  39. PB_2, //D18
  40. PB_3, //D19
  41. PB_4, //D20
  42. PB_5, //D21
  43. PB_6, //D22
  44. PB_7, //D23
  45. PB_8, //D24
  46. PB_9, //D25
  47. PB_10, //D26
  48. PB_12, //D27
  49. PB_13, //D28
  50. PB_14, //D29
  51. PB_15, //D30
  52. PC_0, //D31
  53. PC_1, //D32
  54. PC_2, //D33
  55. PC_3, //D34
  56. PC_4, //D35
  57. PC_5, //D36
  58. PC_6, //D37
  59. PC_7, //D38
  60. PC_8, //D39
  61. PC_9, //D40
  62. PC_10, //D41
  63. PC_11, //D42
  64. PC_12, //D43
  65. PC_13, //D44
  66. PC_14, //D45
  67. PC_15, //D46
  68. PD_2, //D47
  69. PH_0, //D48
  70. PH_1, //D49
  71. //Duplicated ADC Pins
  72. PA_0, //D50/A0
  73. PA_1, //D51/A1
  74. PA_2, //D52/A2
  75. PA_3, //D53/A3
  76. PA_4, //D54/A4
  77. PA_5, //D55/A5
  78. PA_6, //D56/A6
  79. PA_7, //D57/A7
  80. PB_0, //D58/A8
  81. PB_1, //D59/A9
  82. PC_0, //D60/A10
  83. PC_1, //D61/A11
  84. PC_2, //D62/A12
  85. PC_3, //D63/A13
  86. PC_4, //D64/A14
  87. PC_5 //D65/A15
  88. };
  89. #ifdef __cplusplus
  90. }
  91. #endif
  92. // ----------------------------------------------------------------------------
  93. #ifdef __cplusplus
  94. extern "C" {
  95. #endif
  96. /**
  97. * @brief System Clock Configuration
  98. * The system Clock is configured as follow :
  99. * System Clock source = PLL (HSE)
  100. * SYSCLK(Hz) = 84000000
  101. * HCLK(Hz) = 84000000
  102. * AHB Prescaler = 1
  103. * APB1 Prescaler = 2
  104. * APB2 Prescaler = 1
  105. * HSE Frequency(Hz) = 8000000
  106. * PLL_M = 8
  107. * PLL_N = 336
  108. * PLL_P = 4
  109. * PLL_Q = 7
  110. * VDD(V) = 3.3
  111. * Main regulator output voltage = Scale2 mode
  112. * Flash Latency(WS) = 2
  113. * @param None
  114. * @retval None
  115. */
  116. WEAK void SystemClock_Config(void)
  117. {
  118. RCC_ClkInitTypeDef RCC_ClkInitStruct;
  119. RCC_OscInitTypeDef RCC_OscInitStruct;
  120. /* Enable Power Control clock */
  121. __HAL_RCC_PWR_CLK_ENABLE();
  122. /* The voltage scaling allows optimizing the power consumption when the device is
  123. clocked below the maximum system frequency, to update the voltage scaling value
  124. regarding system frequency refer to product datasheet. */
  125. __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE2);
  126. /* Enable HSI Oscillator and activate PLL with HSI as source */
  127. RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
  128. RCC_OscInitStruct.HSEState = RCC_HSE_ON;
  129. RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  130. RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
  131. RCC_OscInitStruct.PLL.PLLM = 8;
  132. RCC_OscInitStruct.PLL.PLLN = 336;
  133. RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4;
  134. RCC_OscInitStruct.PLL.PLLQ = 7;
  135. if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
  136. /* Initialization Error */
  137. while (1);
  138. }
  139. /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2
  140. clocks dividers */
  141. RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
  142. RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
  143. RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  144. RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
  145. RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
  146. if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) {
  147. /* Initialization Error */
  148. while (1);
  149. }
  150. }
  151. #ifdef __cplusplus
  152. }
  153. #endif
  154. void flashFirmware(const int16_t) {
  155. *((unsigned long *)0x2000FFF0) = 0xDEADBEEF; // End of RAM
  156. NVIC_SystemReset();
  157. }