My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

variant.cpp 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /*
  2. *******************************************************************************
  3. * Copyright (c) 2017, STMicroelectronics
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions are met:
  8. *
  9. * 1. Redistributions of source code must retain the above copyright notice,
  10. * this list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright notice,
  12. * this list of conditions and the following disclaimer in the documentation
  13. * and/or other materials provided with the distribution.
  14. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  15. * may be used to endorse or promote products derived from this software
  16. * without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  19. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  20. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  21. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  22. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  23. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  24. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  25. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  26. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  27. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. *******************************************************************************
  29. */
  30. #include "variant.h"
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34. // Pin number
  35. // This array allows to wrap Arduino pin number(Dx or x)
  36. // to STM32 PinName (PX_n)
  37. const PinName digitalPin[] = {
  38. // Right Side
  39. //Int //Ext
  40. //3V3 //3V3
  41. //3V3 //3V3
  42. //BOOT0 //BOOT1
  43. //GND //GND
  44. //GND //GND
  45. PE_1, PE_0, // D0, D1
  46. PB_9, PB_8,
  47. PB_7, PB_6,
  48. PB_5, PB_3,
  49. PD_7, PD_6,
  50. PD_5, PD_4, // D10, D11
  51. PD_3, PD_2,
  52. PD_1, PD_0,
  53. PC_12, PC_11,
  54. PC_10, PA_15,
  55. PA_12, PA_11, // D20, D21 PA_11: USB_DM, PA_12: USB_DP
  56. PA_10, PA_9,
  57. PA_8, PC_9,
  58. PC_8, PC_7,
  59. PC_6, PD_15,
  60. PD_14, PD_13, // D30, D31
  61. PD_12, PD_11,
  62. PD_10, PD_9,
  63. PD_8, PB_15,
  64. // Left Side
  65. //Ext //Int
  66. //5V //5V
  67. //5V //5V
  68. //3V3 //3V3
  69. //3V3 //3V3
  70. //GND //GND
  71. PE_2, PE_3,
  72. PE_4, PE_5, // D40, D41 PE_4: BUT K0, PE_5: BUT K1
  73. PE_6, PC_13,
  74. PC_0, PC_1,
  75. PC_2, PC_3,
  76. //VREF- //VREF+
  77. PA_0, PA_1, // PA_0(WK_UP): BUT K_UP)
  78. PA_2, PA_3, // D50, D51
  79. PA_4, PA_5,
  80. /*PA_6, PA_7,*/ // PA_6, PA_7: Moved to allow contiguous analog pins
  81. PC_4, PC_5,
  82. PB_0, PB_1,
  83. PA_6, PA_7, // PA_6: LED D2, PA_7: LED D3 (active LOW)
  84. PE_7, PE_8, // D60, D61
  85. PE_9, PE_10,
  86. PE_11, PE_12,
  87. PE_13, PE_14,
  88. PE_15, PB_10,
  89. PB_11, PB_12, // D70, D71
  90. PB_13, PB_14,
  91. PB_4,
  92. };
  93. #ifdef __cplusplus
  94. }
  95. #endif
  96. // ----------------------------------------------------------------------------
  97. #ifdef __cplusplus
  98. extern "C" {
  99. #endif
  100. /**
  101. * @brief System Clock Configuration
  102. * @param None
  103. * @retval None
  104. */
  105. WEAK void SystemClock_Config(void)
  106. {
  107. RCC_OscInitTypeDef RCC_OscInitStruct;
  108. RCC_ClkInitTypeDef RCC_ClkInitStruct;
  109. /**Configure the main internal regulator output voltage
  110. */
  111. __HAL_RCC_PWR_CLK_ENABLE();
  112. __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
  113. /**Initializes the CPU, AHB and APB busses clocks
  114. */
  115. RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
  116. RCC_OscInitStruct.HSEState = RCC_HSE_ON;
  117. RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  118. RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
  119. RCC_OscInitStruct.PLL.PLLM = 8;
  120. RCC_OscInitStruct.PLL.PLLN = 336;
  121. RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
  122. RCC_OscInitStruct.PLL.PLLQ = 7;
  123. if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
  124. _Error_Handler(__FILE__, __LINE__);
  125. }
  126. /**Initializes the CPU, AHB and APB busses clocks
  127. */
  128. RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK
  129. | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
  130. RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
  131. RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  132. RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
  133. RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
  134. if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK) {
  135. _Error_Handler(__FILE__, __LINE__);
  136. }
  137. /**Configure the Systick interrupt time
  138. */
  139. HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq() / 1000);
  140. /**Configure the Systick
  141. */
  142. HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);
  143. /* SysTick_IRQn interrupt configuration */
  144. HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
  145. }
  146. #ifdef __cplusplus
  147. }
  148. #endif