Browse Source

Chitu V5 with extra GPIO init (#18299)

Co-authored-by: Scott Lahteine <github@thinkyhead.com>
Victor 4 years ago
parent
commit
8358f3eadb
No account linked to committer's email address

+ 1
- 1
Marlin/src/pins/pins.h View File

@@ -541,7 +541,7 @@
541 541
 #elif MB(CCROBOT_MEEB_3DP)
542 542
   #include "stm32f1/pins_CCROBOT_MEEB_3DP.h"    // STM32F1                                env:STM32F103RC_meeb
543 543
 #elif MB(CHITU3D_V5)
544
-  #include "stm32f1/pins_CHITU3D_V5.h"          // STM32F1                                env:chitu_f103
544
+  #include "stm32f1/pins_CHITU3D_V5.h"          // STM32F1                                env:chitu_f103 env:chitu_v5_gpio_init
545 545
 #elif MB(CHITU3D_V6)
546 546
   #include "stm32f1/pins_CHITU3D_V6.h"          // STM32F1                                env:chitu_f103
547 547
 

+ 32
- 27
buildroot/share/PlatformIO/variants/CHITU_F103/wirish/boards_setup.cpp View File

@@ -49,17 +49,17 @@
49 49
 // currently officially supports).
50 50
 #ifndef BOARD_RCC_PLLMUL
51 51
   #if !USE_HSI_CLOCK
52
-  #if F_CPU==128000000
53
-    #define BOARD_RCC_PLLMUL RCC_PLLMUL_16
54
-  #elif F_CPU==72000000
55
-    #define BOARD_RCC_PLLMUL RCC_PLLMUL_9
56
-  #elif F_CPU==48000000
57
-    #define BOARD_RCC_PLLMUL RCC_PLLMUL_6
58
-  #elif F_CPU==16000000
59
-    #define BOARD_RCC_PLLMUL RCC_PLLMUL_2
60
-  #endif
52
+    #if F_CPU==128000000
53
+      #define BOARD_RCC_PLLMUL RCC_PLLMUL_16
54
+    #elif F_CPU==72000000
55
+      #define BOARD_RCC_PLLMUL RCC_PLLMUL_9
56
+    #elif F_CPU==48000000
57
+      #define BOARD_RCC_PLLMUL RCC_PLLMUL_6
58
+    #elif F_CPU==16000000
59
+      #define BOARD_RCC_PLLMUL RCC_PLLMUL_2
60
+    #endif
61 61
   #else
62
-  #define BOARD_RCC_PLLMUL RCC_PLLMUL_16
62
+    #define BOARD_RCC_PLLMUL RCC_PLLMUL_16
63 63
   #endif
64 64
 #endif
65 65
 
@@ -83,33 +83,39 @@ namespace wirish {
83 83
             rcc_set_prescaler(RCC_PRESCALER_AHB, RCC_AHB_SYSCLK_DIV_1);
84 84
             rcc_set_prescaler(RCC_PRESCALER_APB1, RCC_APB1_HCLK_DIV_2);
85 85
             rcc_set_prescaler(RCC_PRESCALER_APB2, RCC_APB2_HCLK_DIV_1);
86
-      rcc_clk_disable(RCC_USB);
87
-      #if F_CPU == 72000000
88
-      rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1_5);
89
-      #elif F_CPU == 48000000
90
-      rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1);
91
-      #endif
86
+            rcc_clk_disable(RCC_USB);
87
+#if F_CPU == 72000000
88
+            rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1_5);
89
+#elif F_CPU == 48000000
90
+            rcc_set_prescaler(RCC_PRESCALER_USB, RCC_USB_SYSCLK_DIV_1);
91
+#endif
92 92
         }
93 93
 
94 94
         __weak void board_setup_gpio(void) {
95
+            /**
96
+             * PA14 is a pull up pin. But, some V5 boards it start with LOW state! And just behave properly when the Z- PROBE is actived at least once.
97
+             * So, if the sensor isnt actived, the PA14 pin will be forever in LOW state, telling Marlin the probe IS ALWAYS ACTIVE, that isnt the case!
98
+             * Chitu original firmware seems to start with every pullup PIN with HIGH to workaround this.
99
+             * So we are doing the same here.
100
+             * This hack only works if applied *before* the GPIO Init, it's the reason I did it here.
101
+             */
102
+            #ifdef CHITU_V5_Z_MIN_BUGFIX
103
+              GPIOA->regs->BSRR = (1U << PA14);
104
+            #endif
95 105
             gpio_init_all();
96 106
         }
97 107
 
98 108
         __weak void board_setup_usb(void) {
99
-
100
-
101
-
102 109
 #ifdef SERIAL_USB
103 110
 #ifdef GENERIC_BOOTLOADER
104
-      //Reset the USB interface on generic boards - developed by Victor PV
105
-      gpio_set_mode(PIN_MAP[PA12].gpio_device, PIN_MAP[PA12].gpio_bit, GPIO_OUTPUT_PP);
106
-      gpio_write_bit(PIN_MAP[PA12].gpio_device, PIN_MAP[PA12].gpio_bit,0);
111
+          // Reset the USB interface on generic boards - developed by Victor PV
112
+          gpio_set_mode(PIN_MAP[PA12].gpio_device, PIN_MAP[PA12].gpio_bit, GPIO_OUTPUT_PP);
113
+          gpio_write_bit(PIN_MAP[PA12].gpio_device, PIN_MAP[PA12].gpio_bit,0);
107 114
 
108
-      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
109
-      gpio_set_mode(PIN_MAP[PA12].gpio_device, PIN_MAP[PA12].gpio_bit, GPIO_INPUT_FLOATING);
115
+          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
116
+          gpio_set_mode(PIN_MAP[PA12].gpio_device, PIN_MAP[PA12].gpio_bit, GPIO_INPUT_FLOATING);
110 117
 #endif
111
-
112
-      Serial.begin();// Roger Clark. Changed SerialUSB to Serial for Arduino sketch compatibility
118
+          Serial.begin(); // Roger Clark. Changed SerialUSB to Serial for Arduino sketch compatibility
113 119
 #endif
114 120
         }
115 121
 
@@ -118,6 +124,5 @@ namespace wirish {
118 124
             // interrupts work out of the box.
119 125
             afio_init();
120 126
         }
121
-
122 127
     }
123 128
 }

+ 9
- 0
platformio.ini View File

@@ -665,6 +665,15 @@ build_unflags = ${common_stm32f1.build_unflags}
665 665
   -DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG= -DERROR_LED_PORT=GPIOE -DERROR_LED_PIN=6
666 666
 
667 667
 #
668
+# Some Chitu V5 boards have a problem with GPIO init.
669
+# Use this target if G28 or G29 are always failing.
670
+#
671
+[env:chitu_v5_gpio_init]
672
+platform      = ${common_stm32f1.platform}
673
+extends       = env:chitu_f103
674
+build_flags   = ${env:chitu_f103.build_flags} -DCHITU_V5_Z_MIN_BUGFIX
675
+
676
+#
668 677
 # STM32F401VE
669 678
 # 'STEVAL-3DP001V1' STM32F401VE board - https://www.st.com/en/evaluation-tools/steval-3dp001v1.html
670 679
 #

Loading…
Cancel
Save