My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /******************************************************************************
  2. * The MIT License
  3. *
  4. * Copyright (c) 2012 LeafLabs, LLC.
  5. *
  6. * Permission is hereby granted, free of charge, to any person
  7. * obtaining a copy of this software and associated documentation
  8. * files (the "Software"), to deal in the Software without
  9. * restriction, including without limitation the rights to use, copy,
  10. * modify, merge, publish, distribute, sublicense, and/or sell copies
  11. * of the Software, and to permit persons to whom the Software is
  12. * furnished to do so, subject to the following conditions:
  13. *
  14. * The above copyright notice and this permission notice shall be
  15. * included in all copies or substantial portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  18. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  19. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  20. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  21. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  22. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  23. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  24. * SOFTWARE.
  25. *****************************************************************************/
  26. /**
  27. * @file wirish/stm32f1/boards_setup.cpp
  28. * @author Marti Bolivar <mbolivar@leaflabs.com>
  29. * @brief STM32F1 chip setup.
  30. *
  31. * This file controls how init() behaves on the STM32F1. Be very
  32. * careful when changing anything here. Many of these values depend
  33. * upon each other.
  34. */
  35. #include "boards_private.h"
  36. #include <libmaple/gpio.h>
  37. #include <libmaple/timer.h>
  38. #include <boards.h>
  39. #include <usb_serial.h>
  40. // Allow boards to provide a PLL multiplier. This is useful for
  41. // e.g. STM32F100 value line MCUs, which use slower multipliers.
  42. // (We're leaving the default to RCC_PLLMUL_9 for now, since that
  43. // works for F103 performance line MCUs, which is all that LeafLabs
  44. // currently officially supports).
  45. namespace wirish {
  46. namespace priv {
  47. static stm32f1_rcc_pll_data pll_data = {RCC_PLLMUL_6};
  48. #if !USE_HSI_CLOCK
  49. __weak rcc_pll_cfg w_board_pll_cfg = {RCC_PLLSRC_HSE, &pll_data};
  50. #else
  51. __weak rcc_pll_cfg w_board_pll_cfg = {RCC_PLLSRC_HSI_DIV_2, &pll_data};
  52. #endif
  53. __weak adc_prescaler w_adc_pre = ADC_PRE_PCLK2_DIV_6;
  54. __weak adc_smp_rate w_adc_smp = ADC_SMPR_55_5;
  55. __weak void board_reset_pll(void) {
  56. // TODO
  57. }
  58. __weak void board_setup_clock_prescalers(void) {
  59. rcc_set_prescaler(RCC_PRESCALER_AHB, RCC_AHB_SYSCLK_DIV_1);
  60. rcc_set_prescaler(RCC_PRESCALER_APB1, RCC_APB1_HCLK_DIV_2);
  61. rcc_set_prescaler(RCC_PRESCALER_APB2, RCC_APB2_HCLK_DIV_1);
  62. rcc_clk_disable(RCC_USB);
  63. #if F_CPU == 72000000
  64. rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1_5);
  65. #elif F_CPU == 48000000
  66. rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1);
  67. #endif
  68. }
  69. __weak void board_setup_gpio(void) {
  70. gpio_init_all();
  71. }
  72. __weak void board_setup_usb(void) {
  73. #ifdef SERIAL_USB
  74. #ifdef GENERIC_BOOTLOADER
  75. //Reset the USB interface on generic boards - developed by Victor PV
  76. gpio_set_mode(PIN_MAP[PA12].gpio_device, PIN_MAP[PA12].gpio_bit, GPIO_OUTPUT_PP);
  77. gpio_write_bit(PIN_MAP[PA12].gpio_device, PIN_MAP[PA12].gpio_bit,0);
  78. for(volatile unsigned int i=0;i<512;i++);// Only small delay seems to be needed, and USB pins will get configured in Serial.begin
  79. gpio_set_mode(PIN_MAP[PA12].gpio_device, PIN_MAP[PA12].gpio_bit, GPIO_INPUT_FLOATING);
  80. #endif
  81. Serial.begin();// Roger Clark. Changed SerialUSB to Serial for Arduino sketch compatibility
  82. #endif
  83. }
  84. __weak void series_init(void) {
  85. // Initialize AFIO here, too, so peripheral remaps and external
  86. // interrupts work out of the box.
  87. afio_init();
  88. }
  89. }
  90. }