瀏覽代碼

Clean up SPI and ST7920 defines (#19956)

Scott Lahteine 4 年之前
父節點
當前提交
22bf2b49c6
No account linked to committer's email address

+ 1
- 5
Marlin/src/HAL/STM32F1/spi_pins.h 查看文件

49
 #undef SDSS
49
 #undef SDSS
50
 #define SDSS       SS_PIN
50
 #define SDSS       SS_PIN
51
 
51
 
52
-#if ENABLED(ENABLE_SPI3)
53
-  #define SPI_DEVICE 3
54
-#elif ENABLED(ENABLE_SPI2)
55
-  #define SPI_DEVICE 2
56
-#else
52
+#ifndef SPI_DEVICE
57
   #define SPI_DEVICE 1
53
   #define SPI_DEVICE 1
58
 #endif
54
 #endif

+ 32
- 0
Marlin/src/lcd/dogm/ultralcd_st7920_u8glib_rrd_AVR.cpp 查看文件

33
 
33
 
34
 #include "ultralcd_st7920_u8glib_rrd_AVR.h"
34
 #include "ultralcd_st7920_u8glib_rrd_AVR.h"
35
 
35
 
36
+#if F_CPU >= 20000000
37
+  #define CPU_ST7920_DELAY_1 DELAY_NS(0)
38
+  #define CPU_ST7920_DELAY_2 DELAY_NS(0)
39
+  #define CPU_ST7920_DELAY_3 DELAY_NS(50)
40
+#elif MB(3DRAG, K8200, K8400)
41
+  #define CPU_ST7920_DELAY_1 DELAY_NS(0)
42
+  #define CPU_ST7920_DELAY_2 DELAY_NS(188)
43
+  #define CPU_ST7920_DELAY_3 DELAY_NS(0)
44
+#elif MB(MINIRAMBO, EINSY_RAMBO, EINSY_RETRO, SILVER_GATE)
45
+  #define CPU_ST7920_DELAY_1 DELAY_NS(0)
46
+  #define CPU_ST7920_DELAY_2 DELAY_NS(250)
47
+  #define CPU_ST7920_DELAY_3 DELAY_NS(0)
48
+#elif MB(RAMBO)
49
+  #define CPU_ST7920_DELAY_1 DELAY_NS(0)
50
+  #define CPU_ST7920_DELAY_2 DELAY_NS(0)
51
+  #define CPU_ST7920_DELAY_3 DELAY_NS(0)
52
+#elif MB(BQ_ZUM_MEGA_3D)
53
+  #define CPU_ST7920_DELAY_1 DELAY_NS(0)
54
+  #define CPU_ST7920_DELAY_2 DELAY_NS(0)
55
+  #define CPU_ST7920_DELAY_3 DELAY_NS(189)
56
+#elif defined(ARDUINO_ARCH_STM32)
57
+  #define CPU_ST7920_DELAY_1 DELAY_NS(300)
58
+  #define CPU_ST7920_DELAY_2 DELAY_NS(40)
59
+  #define CPU_ST7920_DELAY_3 DELAY_NS(340)
60
+#elif F_CPU == 16000000
61
+  #define CPU_ST7920_DELAY_1 DELAY_NS(0)
62
+  #define CPU_ST7920_DELAY_2 DELAY_NS(0)
63
+  #define CPU_ST7920_DELAY_3 DELAY_NS(63)
64
+#else
65
+  #error "No valid condition for delays in 'ultralcd_st7920_u8glib_rrd_AVR.h'"
66
+#endif
67
+
36
 #ifndef ST7920_DELAY_1
68
 #ifndef ST7920_DELAY_1
37
   #ifdef BOARD_ST7920_DELAY_1
69
   #ifdef BOARD_ST7920_DELAY_1
38
     #define ST7920_DELAY_1 BOARD_ST7920_DELAY_1
70
     #define ST7920_DELAY_1 BOARD_ST7920_DELAY_1

+ 2
- 39
Marlin/src/lcd/dogm/ultralcd_st7920_u8glib_rrd_AVR.h 查看文件

37
 
37
 
38
 #include <U8glib.h>
38
 #include <U8glib.h>
39
 
39
 
40
-// If you want you can define your own set of delays in Configuration.h
41
-//#define ST7920_DELAY_1 DELAY_NS(0)
42
-//#define ST7920_DELAY_2 DELAY_NS(0)
43
-//#define ST7920_DELAY_3 DELAY_NS(0)
44
-
45
-#if F_CPU >= 20000000
46
-  #define CPU_ST7920_DELAY_1 DELAY_NS(0)
47
-  #define CPU_ST7920_DELAY_2 DELAY_NS(0)
48
-  #define CPU_ST7920_DELAY_3 DELAY_NS(50)
49
-#elif MB(3DRAG, K8200, K8400)
50
-  #define CPU_ST7920_DELAY_1 DELAY_NS(0)
51
-  #define CPU_ST7920_DELAY_2 DELAY_NS(188)
52
-  #define CPU_ST7920_DELAY_3 DELAY_NS(0)
53
-#elif MB(MINIRAMBO, EINSY_RAMBO, EINSY_RETRO, SILVER_GATE)
54
-  #define CPU_ST7920_DELAY_1 DELAY_NS(0)
55
-  #define CPU_ST7920_DELAY_2 DELAY_NS(250)
56
-  #define CPU_ST7920_DELAY_3 DELAY_NS(0)
57
-#elif MB(RAMBO)
58
-  #define CPU_ST7920_DELAY_1 DELAY_NS(0)
59
-  #define CPU_ST7920_DELAY_2 DELAY_NS(0)
60
-  #define CPU_ST7920_DELAY_3 DELAY_NS(0)
61
-#elif MB(BQ_ZUM_MEGA_3D)
62
-  #define CPU_ST7920_DELAY_1 DELAY_NS(0)
63
-  #define CPU_ST7920_DELAY_2 DELAY_NS(0)
64
-  #define CPU_ST7920_DELAY_3 DELAY_NS(189)
65
-#elif defined(ARDUINO_ARCH_STM32)
66
-  #define CPU_ST7920_DELAY_1 DELAY_NS(300)
67
-  #define CPU_ST7920_DELAY_2 DELAY_NS(40)
68
-  #define CPU_ST7920_DELAY_3 DELAY_NS(340)
69
-#elif F_CPU == 16000000
70
-  #define CPU_ST7920_DELAY_1 DELAY_NS(0)
71
-  #define CPU_ST7920_DELAY_2 DELAY_NS(0)
72
-  #define CPU_ST7920_DELAY_3 DELAY_NS(63)
73
-#else
74
-  #error "No valid condition for delays in 'ultralcd_st7920_u8glib_rrd_AVR.h'"
75
-#endif
76
-
77
 void ST7920_SWSPI_SND_8BIT(uint8_t val);
40
 void ST7920_SWSPI_SND_8BIT(uint8_t val);
78
 
41
 
79
 #if DOGM_SPI_DELAY_US > 0
42
 #if DOGM_SPI_DELAY_US > 0
82
   #define U8G_DELAY() DELAY_US(10)
45
   #define U8G_DELAY() DELAY_US(10)
83
 #endif
46
 #endif
84
 
47
 
85
-#define ST7920_CS()              { WRITE(ST7920_CS_PIN,1); U8G_DELAY(); }
86
-#define ST7920_NCS()             { WRITE(ST7920_CS_PIN,0); }
48
+#define ST7920_CS()              { WRITE(ST7920_CS_PIN, HIGH); U8G_DELAY(); }
49
+#define ST7920_NCS()             { WRITE(ST7920_CS_PIN, LOW); }
87
 #define ST7920_SET_CMD()         { ST7920_SWSPI_SND_8BIT(0xF8); U8G_DELAY(); }
50
 #define ST7920_SET_CMD()         { ST7920_SWSPI_SND_8BIT(0xF8); U8G_DELAY(); }
88
 #define ST7920_SET_DAT()         { ST7920_SWSPI_SND_8BIT(0xFA); U8G_DELAY(); }
51
 #define ST7920_SET_DAT()         { ST7920_SWSPI_SND_8BIT(0xFA); U8G_DELAY(); }
89
 #define ST7920_WRITE_BYTE(a)     { ST7920_SWSPI_SND_8BIT((uint8_t)((a)&0xF0u)); ST7920_SWSPI_SND_8BIT((uint8_t)((a)<<4U)); U8G_DELAY(); }
52
 #define ST7920_WRITE_BYTE(a)     { ST7920_SWSPI_SND_8BIT((uint8_t)((a)&0xF0u)); ST7920_SWSPI_SND_8BIT((uint8_t)((a)<<4U)); U8G_DELAY(); }

+ 3
- 0
Marlin/src/pins/pins_postprocess.h 查看文件

871
   #undef ST7920_DELAY_1
871
   #undef ST7920_DELAY_1
872
   #undef ST7920_DELAY_2
872
   #undef ST7920_DELAY_2
873
   #undef ST7920_DELAY_3
873
   #undef ST7920_DELAY_3
874
+  #undef BOARD_ST7920_DELAY_1
875
+  #undef BOARD_ST7920_DELAY_2
876
+  #undef BOARD_ST7920_DELAY_3
874
 #endif
877
 #endif
875
 
878
 
876
 #undef HAS_FREE_AUX2_PINS
879
 #undef HAS_FREE_AUX2_PINS

+ 1
- 2
Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_V1_1.h 查看文件

210
 #endif
210
 #endif
211
 
211
 
212
 #if SD_CONNECTION_IS(LCD)
212
 #if SD_CONNECTION_IS(LCD)
213
-  #define ENABLE_SPI3
213
+  #define SPI_DEVICE                           3
214
   #define SD_DETECT_PIN                     PB9
214
   #define SD_DETECT_PIN                     PB9
215
   #define SCK_PIN                           PB3
215
   #define SCK_PIN                           PB3
216
   #define MISO_PIN                          PB4
216
   #define MISO_PIN                          PB4
217
   #define MOSI_PIN                          PB5
217
   #define MOSI_PIN                          PB5
218
   #define SS_PIN                            PA15
218
   #define SS_PIN                            PA15
219
 #elif SD_CONNECTION_IS(ONBOARD)
219
 #elif SD_CONNECTION_IS(ONBOARD)
220
-  #define ENABLE_SPI1
221
   #define SD_DETECT_PIN                     PA3
220
   #define SD_DETECT_PIN                     PA3
222
   #define SCK_PIN                           PA5
221
   #define SCK_PIN                           PA5
223
   #define MISO_PIN                          PA6
222
   #define MISO_PIN                          PA6

+ 0
- 1
Marlin/src/pins/stm32f1/pins_CCROBOT_MEEB_3DP.h 查看文件

165
 // SD-NAND
165
 // SD-NAND
166
 //
166
 //
167
 #if SD_CONNECTION_IS(ONBOARD)
167
 #if SD_CONNECTION_IS(ONBOARD)
168
-  #define ENABLE_SPI1
169
   #define SD_DETECT_PIN                     -1
168
   #define SD_DETECT_PIN                     -1
170
   #define SCK_PIN                           PA5
169
   #define SCK_PIN                           PA5
171
   #define MISO_PIN                          PA6
170
   #define MISO_PIN                          PA6

+ 1
- 1
Marlin/src/pins/stm32f1/pins_CHITU3D_V5.h 查看文件

185
 
185
 
186
 // SPI1(PA7)=LCD & SPI3(PB5)=STUFF, are not available
186
 // SPI1(PA7)=LCD & SPI3(PB5)=STUFF, are not available
187
 // Needs to use SPI2
187
 // Needs to use SPI2
188
-#define ENABLE_SPI2
188
+#define SPI_DEVICE                             2
189
 #define SCK_PIN                             PB13
189
 #define SCK_PIN                             PB13
190
 #define MISO_PIN                            PB14
190
 #define MISO_PIN                            PB14
191
 #define MOSI_PIN                            PB15
191
 #define MOSI_PIN                            PB15

+ 1
- 1
Marlin/src/pins/stm32f1/pins_CHITU3D_V6.h 查看文件

200
 
200
 
201
 // SPI1(PA7)=LCD & SPI3(PB5)=STUFF, are not available
201
 // SPI1(PA7)=LCD & SPI3(PB5)=STUFF, are not available
202
 // so SPI2 is required.
202
 // so SPI2 is required.
203
-#define ENABLE_SPI2
203
+#define SPI_DEVICE                             2
204
 #define SCK_PIN                             PB13
204
 #define SCK_PIN                             PB13
205
 #define MISO_PIN                            PB14
205
 #define MISO_PIN                            PB14
206
 #define MOSI_PIN                            PB15
206
 #define MOSI_PIN                            PB15

+ 1
- 1
Marlin/src/pins/stm32f1/pins_FLSUN_HISPEED.h 查看文件

56
 // SPI
56
 // SPI
57
 // Note: FLSun Hispeed (clone MKS_Robin_miniV2) board is using SPI2 interface.
57
 // Note: FLSun Hispeed (clone MKS_Robin_miniV2) board is using SPI2 interface.
58
 //
58
 //
59
-#define ENABLE_SPI2
59
+#define SPI_DEVICE                             2
60
 
60
 
61
 // SPI Flash
61
 // SPI Flash
62
 #define HAS_SPI_FLASH                          1
62
 #define HAS_SPI_FLASH                          1

+ 1
- 1
Marlin/src/pins/stm32f1/pins_FLY_MINI.h 查看文件

132
 //
132
 //
133
 // LCD / Controller
133
 // LCD / Controller
134
 //
134
 //
135
-#define ENABLE_SPI2
135
+#define SPI_DEVICE                             2
136
 #define SS_PIN                              PB12
136
 #define SS_PIN                              PB12
137
 #define SCK_PIN                             PB13
137
 #define SCK_PIN                             PB13
138
 #define MISO_PIN                            PB14
138
 #define MISO_PIN                            PB14

+ 1
- 1
Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h 查看文件

166
 #endif
166
 #endif
167
 
167
 
168
 // SPI1(PA7) & SPI3(PB5) not available
168
 // SPI1(PA7) & SPI3(PB5) not available
169
-#define ENABLE_SPI2
169
+#define SPI_DEVICE                             2
170
 
170
 
171
 #if ENABLED(SDIO_SUPPORT)
171
 #if ENABLED(SDIO_SUPPORT)
172
   #define SCK_PIN                           PB13  // SPI2
172
   #define SCK_PIN                           PB13  // SPI2

+ 1
- 2
Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h 查看文件

55
 //
55
 //
56
 // Note: MKS Robin board is using SPI2 interface.
56
 // Note: MKS Robin board is using SPI2 interface.
57
 //
57
 //
58
-//#define SPI_MODULE                           2
59
-#define ENABLE_SPI2
58
+#define SPI_DEVICE                             2
60
 
59
 
61
 //
60
 //
62
 // Limit Switches
61
 // Limit Switches

+ 1
- 1
Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3_common.h 查看文件

167
 //
167
 //
168
 // SD Card
168
 // SD Card
169
 //
169
 //
170
-#define ENABLE_SPI2
170
+#define SPI_DEVICE                             2
171
 #define SD_DETECT_PIN                       PC10
171
 #define SD_DETECT_PIN                       PC10
172
 #define SCK_PIN                             PB13
172
 #define SCK_PIN                             PB13
173
 #define MISO_PIN                            PB14
173
 #define MISO_PIN                            PB14

+ 5
- 2
Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE.h 查看文件

34
 
34
 
35
 //#define DISABLE_DEBUG
35
 //#define DISABLE_DEBUG
36
 #define DISABLE_JTAG
36
 #define DISABLE_JTAG
37
-#define ENABLE_SPI2
38
 
37
 
39
 //
38
 //
40
 // Limit Switches
39
 // Limit Switches
135
 //
134
 //
136
 // SD Card
135
 // SD Card
137
 //
136
 //
138
-#define ENABLE_SPI2
139
 #define SD_DETECT_PIN                       PC10
137
 #define SD_DETECT_PIN                       PC10
138
+
139
+//
140
+// SPI
141
+//
142
+#define SPI_DEVICE                             2
140
 #define SCK_PIN                             PB13
143
 #define SCK_PIN                             PB13
141
 #define MISO_PIN                            P1B4
144
 #define MISO_PIN                            P1B4
142
 #define MOSI_PIN                            P1B5
145
 #define MOSI_PIN                            P1B5

+ 12
- 15
Marlin/src/pins/stm32f1/pins_MKS_ROBIN_LITE3.h 查看文件

38
 
38
 
39
 //#define DISABLE_DEBUG
39
 //#define DISABLE_DEBUG
40
 #define DISABLE_JTAG
40
 #define DISABLE_JTAG
41
-#define ENABLE_SPI2
42
 
41
 
43
 //
42
 //
44
 // Servos
43
 // Servos
87
 //
86
 //
88
 // Temperature Sensors
87
 // Temperature Sensors
89
 //
88
 //
90
-#define TEMP_BED_PIN                        PA1   //TB
91
-#define TEMP_0_PIN                          PA0   //TH1
92
-#define TEMP_1_PIN                          PA2   //TH2
89
+#define TEMP_BED_PIN                        PA1   // TB
90
+#define TEMP_0_PIN                          PA0   // TH1
91
+#define TEMP_1_PIN                          PA2   // TH2
93
 
92
 
94
 #define FIL_RUNOUT_PIN                      PB10  // MT_DET
93
 #define FIL_RUNOUT_PIN                      PB10  // MT_DET
95
 
94
 
132
 
131
 
133
   #endif // !MKS_MINI_12864
132
   #endif // !MKS_MINI_12864
134
 
133
 
134
+  #define BOARD_ST7920_DELAY_1     DELAY_NS(125)
135
+  #define BOARD_ST7920_DELAY_2     DELAY_NS(125)
136
+  #define BOARD_ST7920_DELAY_3     DELAY_NS(125)
137
+
135
 #endif // HAS_WIRED_LCD
138
 #endif // HAS_WIRED_LCD
136
 
139
 
137
 //
140
 //
138
 // SD Card
141
 // SD Card
139
 //
142
 //
140
-#define ENABLE_SPI2
141
 #define SD_DETECT_PIN                       PC10
143
 #define SD_DETECT_PIN                       PC10
144
+
145
+//
146
+// SPI
147
+//
148
+#define SPI_DEVICE                             2
142
 #define SCK_PIN                             PB13
149
 #define SCK_PIN                             PB13
143
 #define MISO_PIN                            PB14
150
 #define MISO_PIN                            PB14
144
 #define MOSI_PIN                            PB15
151
 #define MOSI_PIN                            PB15
145
 #define SS_PIN                              PA15
152
 #define SS_PIN                              PA15
146
-
147
-#ifndef BOARD_ST7920_DELAY_1
148
-  #define BOARD_ST7920_DELAY_1     DELAY_NS(125)
149
-#endif
150
-#ifndef BOARD_ST7920_DELAY_2
151
-  #define BOARD_ST7920_DELAY_2     DELAY_NS(125)
152
-#endif
153
-#ifndef BOARD_ST7920_DELAY_3
154
-  #define BOARD_ST7920_DELAY_3     DELAY_NS(125)
155
-#endif

+ 1
- 1
Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h 查看文件

48
   #define MARLIN_EEPROM_SIZE    EEPROM_PAGE_SIZE  // 2KB
48
   #define MARLIN_EEPROM_SIZE    EEPROM_PAGE_SIZE  // 2KB
49
 #endif
49
 #endif
50
 
50
 
51
-#define ENABLE_SPI2
51
+#define SPI_DEVICE                             2
52
 
52
 
53
 //
53
 //
54
 // Limit Switches
54
 // Limit Switches

+ 1
- 1
Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h 查看文件

48
   #define MARLIN_EEPROM_SIZE    EEPROM_PAGE_SIZE  // 2KB
48
   #define MARLIN_EEPROM_SIZE    EEPROM_PAGE_SIZE  // 2KB
49
 #endif
49
 #endif
50
 
50
 
51
-#define ENABLE_SPI2
51
+#define SPI_DEVICE                             2
52
 
52
 
53
 //
53
 //
54
 // Limit Switches
54
 // Limit Switches

+ 1
- 2
Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h 查看文件

55
 //
55
 //
56
 // Note: MKS Robin board is using SPI2 interface.
56
 // Note: MKS Robin board is using SPI2 interface.
57
 //
57
 //
58
-//#define SPI_MODULE                           2
59
-#define ENABLE_SPI2
58
+#define SPI_DEVICE                             2
60
 
59
 
61
 //
60
 //
62
 // Limit Switches
61
 // Limit Switches

+ 1
- 3
Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h 查看文件

41
 //
41
 //
42
 // Note: MKS Robin board is using SPI2 interface.
42
 // Note: MKS Robin board is using SPI2 interface.
43
 //
43
 //
44
-//#define SPI_MODULE                           2
45
-#define ENABLE_SPI2
44
+#define SPI_DEVICE                             2
46
 
45
 
47
 //
46
 //
48
 // Servos
47
 // Servos
191
 #endif
190
 #endif
192
 
191
 
193
 #if SD_CONNECTION_IS(LCD)
192
 #if SD_CONNECTION_IS(LCD)
194
-  #define ENABLE_SPI2
195
   #define SD_DETECT_PIN                     PG3
193
   #define SD_DETECT_PIN                     PG3
196
   #define SCK_PIN                           PB13
194
   #define SCK_PIN                           PB13
197
   #define MISO_PIN                          PB14
195
   #define MISO_PIN                          PB14

+ 1
- 1
Marlin/src/pins/stm32f1/pins_TRIGORILLA_PRO.h 查看文件

173
 #endif
173
 #endif
174
 
174
 
175
 // SPI1(PA7) & SPI3(PB5) not available
175
 // SPI1(PA7) & SPI3(PB5) not available
176
-#define ENABLE_SPI2
176
+#define SPI_DEVICE                             2
177
 
177
 
178
 #if ENABLED(SDIO_SUPPORT)
178
 #if ENABLED(SDIO_SUPPORT)
179
   #define SCK_PIN                           PB13  // SPI2 ok
179
   #define SCK_PIN                           PB13  // SPI2 ok

+ 0
- 2
Marlin/src/pins/stm32f4/pins_RUMBA32_MKS.h 查看文件

46
   #define FLASH_EEPROM_LEVELING
46
   #define FLASH_EEPROM_LEVELING
47
 #endif
47
 #endif
48
 
48
 
49
-#define ENABLE_SPI1
50
-
51
 #include "pins_RUMBA32_common.h"
49
 #include "pins_RUMBA32_common.h"
52
 
50
 
53
 #if HAS_TMC_UART
51
 #if HAS_TMC_UART

Loading…
取消
儲存