Browse Source

Support FYSETC_MINI_12864 on Re-ARM, RAMPS_FD, MKS SBASE (#13717)

Bob Kuhn 6 years ago
parent
commit
9b578ca343

+ 67
- 1
Marlin/src/HAL/HAL_LPC1768/u8g/u8g_com_HAL_LPC1768_sw_spi.cpp View File

@@ -65,10 +65,76 @@
65 65
 #undef SPI_SPEED
66 66
 #define SPI_SPEED 2  // About 2 MHz
67 67
 
68
+#include <algorithm>
69
+#include <LPC17xx.h>
70
+#include <gpio.h>
71
+
72
+#include <Arduino.h>
73
+
74
+uint8_t swSpiTransfer_mode_0(uint8_t b, const uint8_t spi_speed, const pin_t sck_pin, const pin_t miso_pin, const pin_t mosi_pin ) {
75
+
76
+  for (uint8_t i = 0; i < 8; i++) {
77
+    if (spi_speed == 0) {
78
+      gpio_set(mosi_pin, !!(b & 0x80));
79
+      gpio_set(sck_pin, HIGH);
80
+      b <<= 1;
81
+      if (miso_pin >= 0 && gpio_get(miso_pin)) b |= 1;
82
+      gpio_set(sck_pin, LOW);
83
+    }
84
+    else {
85
+      const uint8_t state = (b & 0x80) ? HIGH : LOW;
86
+      for (uint8_t j = 0; j < spi_speed; j++)
87
+        gpio_set(mosi_pin, state);
88
+
89
+      for (uint8_t j = 0; j < spi_speed + (miso_pin >= 0 ? 0 : 1); j++)
90
+        gpio_set(sck_pin, HIGH);
91
+
92
+      b <<= 1;
93
+      if (miso_pin >= 0 && gpio_get(miso_pin)) b |= 1;
94
+
95
+      for (uint8_t j = 0; j < spi_speed; j++)
96
+        gpio_set(sck_pin, LOW);
97
+    }
98
+  }
99
+
100
+  return b;
101
+}
102
+
103
+uint8_t swSpiTransfer_mode_3(uint8_t b, const uint8_t spi_speed, const pin_t sck_pin, const pin_t miso_pin, const pin_t mosi_pin ) {
104
+
105
+  for (uint8_t i = 0; i < 8; i++) {
106
+    const uint8_t state = (b & 0x80) ? HIGH : LOW;
107
+    if (spi_speed == 0) {
108
+      gpio_set(sck_pin, LOW);
109
+      gpio_set(mosi_pin, state);
110
+      gpio_set(mosi_pin, state);  // need some setup time
111
+      gpio_set(sck_pin, HIGH);
112
+    }
113
+    else {
114
+      for (uint8_t j = 0; j < spi_speed + (miso_pin >= 0 ? 0 : 1); j++)
115
+        gpio_set(sck_pin, LOW);
116
+
117
+      for (uint8_t j = 0; j < spi_speed; j++)
118
+        gpio_set(mosi_pin, state);
119
+
120
+      for (uint8_t j = 0; j < spi_speed; j++)
121
+        gpio_set(sck_pin, HIGH);
122
+    }
123
+    b <<= 1;
124
+    if (miso_pin >= 0 && gpio_get(miso_pin)) b |= 1;
125
+  }
126
+
127
+  return b;
128
+}
129
+
68 130
 static uint8_t SPI_speed = 0;
69 131
 
70 132
 static void u8g_sw_spi_HAL_LPC1768_shift_out(uint8_t dataPin, uint8_t clockPin, uint8_t val) {
71
-  swSpiTransfer(val, SPI_speed, clockPin, -1, dataPin);
133
+  #if ENABLED(FYSETC_MINI_12864)
134
+    swSpiTransfer_mode_3(val, SPI_speed, clockPin, -1, dataPin);
135
+  #else
136
+    swSpiTransfer_mode_0(val, SPI_speed, clockPin, -1, dataPin);
137
+  #endif
72 138
 }
73 139
 
74 140
 uint8_t u8g_com_HAL_LPC1768_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) {

+ 2
- 0
Marlin/src/inc/Conditionals_LCD.h View File

@@ -143,6 +143,8 @@
143 143
 
144 144
   #define DOGLCD
145 145
   #define ULTIPANEL
146
+  #define LCD_CONTRAST_MIN 0
147
+  #define LCD_CONTRAST_MAX 255
146 148
   #define DEFAULT_LCD_CONTRAST 255
147 149
   #define LED_COLORS_REDUCE_GREEN
148 150
 

+ 5
- 1
Marlin/src/lcd/dogm/ultralcd_DOGM.h View File

@@ -112,7 +112,11 @@
112 112
   //#define U8G_CLASS U8GLIB_MINI12864
113 113
   //#define U8G_PARAM DOGLCD_CS, DOGLCD_A0                            // 8 stripes
114 114
   #define U8G_CLASS U8GLIB_MINI12864_2X
115
-  #define U8G_PARAM DOGLCD_CS, DOGLCD_A0                              // 4 stripes
115
+  #if EITHER(FYSETC_MINI_12864, TARGET_LPC1768)
116
+    #define U8G_PARAM DOGLCD_SCK, DOGLCD_MOSI, DOGLCD_CS, DOGLCD_A0   // 4 stripes SW-SPI
117
+  #else
118
+    #define U8G_PARAM DOGLCD_CS, DOGLCD_A0                            // 4 stripes HW-SPI
119
+  #endif
116 120
 #elif ENABLED(U8GLIB_SH1106_EINSTART)
117 121
   // Connected via motherboard header
118 122
   #define U8G_CLASS U8GLIB_SH1106_128X64

+ 35
- 0
Marlin/src/pins/pins_MKS_SBASE.h View File

@@ -253,6 +253,41 @@
253 253
     #define DOGLCD_SCK     SCK_PIN
254 254
     #define DOGLCD_MOSI    MOSI_PIN
255 255
   #endif
256
+
257
+  #if ENABLED(FYSETC_MINI_12864)
258
+    /**
259
+     * The Fysetc display can NOT use the SCK and MOSI pins on EXP2, so a
260
+     * special cable is needed to go between EXP2 on the FYSETC and the
261
+     * controller board's EXP2 and J8. It also means that a software SPI
262
+     * is needed to drive those pins.
263
+     *
264
+     * The Fysetc requires mode 3 SPI interface.
265
+     *
266
+     * Pins 6, 7 & 8 on EXP2 are no connects. That means a second special
267
+     * cable will be needed if the RGB LEDs are to be active.
268
+     */
269
+    #define DOGLCD_CS      LCD_PINS_ENABLE // EXP1.3  (LCD_EN on Fysetc schematic)
270
+    #define DOGLCD_A0      LCD_PINS_RS     // EXP1.4  (LCD_A0 on Fysetc schematic)
271
+    #define DOGLCD_SCK     P2_11           // J8-5  (SCK on Fysetc schematic)
272
+    #define DOGLCD_MOSI    P4_28           // J8-6  (MOSI on Fysetc schematic)
273
+
274
+    #define RGB_LED
275
+    //#define RGBW_LED
276
+    #if EITHER(RGB_LED, RGBW_LED)
277
+      #define RGB_LED_R_PIN P2_12          // J8-4  (LCD_D6 on Fysetc schematic)
278
+      #define RGB_LED_G_PIN P1_23          // J8-3  (LCD_D5 on Fysetc schematic)
279
+      #define RGB_LED_B_PIN P1_22          // J8-2  (LCD_D7 on Fysetc schematic)
280
+      //#define RGB_LED_W_PIN -1
281
+    #endif
282
+
283
+  #elif ENABLED(MINIPANEL)
284
+    // GLCD features
285
+    // Uncomment screen orientation
286
+    //#define LCD_SCREEN_ROT_90
287
+    //#define LCD_SCREEN_ROT_180
288
+    //#define LCD_SCREEN_ROT_270
289
+  #endif
290
+
256 291
 #endif
257 292
 
258 293
 /**

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

@@ -156,7 +156,10 @@
156 156
     #define LCD_PINS_D7    29
157 157
   #endif
158 158
 
159
-  #if ENABLED(MINIPANEL)
159
+  #if ENABLED(FYSETC_MINI_12864)
160
+    #define DOGLCD_CS      LCD_PINS_ENABLE
161
+    #define DOGLCD_A0      LCD_PINS_RS
162
+  #elif ENABLED(MINIPANEL)
160 163
     #define DOGLCD_CS      25
161 164
     #define DOGLCD_A0      27
162 165
   #endif

+ 27
- 20
Marlin/src/pins/pins_RAMPS_RE_ARM.h View File

@@ -269,11 +269,21 @@
269 269
 
270 270
 #elif ENABLED(ULTRA_LCD)
271 271
 
272
-  #define BEEPER_PIN       P1_30   // (37) not 5V tolerant
272
+  //#define SCK_PIN        P0_15   // (52)  system defined J3-9 & AUX-3
273
+  //#define MISO_PIN       P0_17   // (50)  system defined J3-10 & AUX-3
274
+  //#define MOSI_PIN       P0_18   // (51)  system defined J3-10 & AUX-3
275
+  //#define SS_PIN         P1_23   // (53)  system defined J3-5 & AUX-3 (Sometimes called SDSS)
276
+
277
+  #if ENABLED(FYSETC_MINI_12864)
278
+    #define BEEPER_PIN     P1_01
279
+    #define BTN_ENC        P1_04
280
+  #else
281
+    #define BEEPER_PIN     P1_30   // (37) not 5V tolerant
282
+    #define BTN_ENC        P2_11   // (35) J3-3 & AUX-4
283
+  #endif
273 284
 
274 285
   #define BTN_EN1          P3_26   // (31) J3-2 & AUX-4
275 286
   #define BTN_EN2          P3_25   // (33) J3-4 & AUX-4
276
-  #define BTN_ENC          P2_11   // (35) J3-3 & AUX-4
277 287
 
278 288
   #define SD_DETECT_PIN    P1_31   // (49) J3-1 & AUX-3 (NOT 5V tolerant)
279 289
   #define KILL_PIN         P1_22   // (41) J5-4 & AUX-4
@@ -296,13 +306,6 @@
296 306
   #if ANY(VIKI2, miniVIKI)
297 307
     // #define LCD_SCREEN_ROT_180
298 308
 
299
-    #define BTN_EN1        P3_26   // (31) J3-2 & AUX-4
300
-    #define BTN_EN2        P3_25   // (33) J3-4 & AUX-4
301
-    #define BTN_ENC        P2_11   // (35) J3-3 & AUX-4
302
-
303
-    #define SD_DETECT_PIN  P1_31   // (49) J3-1 & AUX-3 (NOT 5V tolerant)
304
-    #define KILL_PIN       P1_22   // (41) J5-4 & AUX-4
305
-
306 309
     #define DOGLCD_CS      P0_16   // (16)
307 310
     #define DOGLCD_A0      P2_06   // (59) J3-8 & AUX-2
308 311
     #define DOGLCD_SCK     SCK_PIN
@@ -311,8 +314,17 @@
311 314
     #define STAT_LED_BLUE_PIN P0_26 //(63)  may change if cable changes
312 315
     #define STAT_LED_RED_PIN P1_21 // ( 6)  may change if cable changes
313 316
   #else
314
-    #define DOGLCD_CS      P0_26   // (63) J5-3 & AUX-2
315
-    #define DOGLCD_A0      P2_06   // (59) J3-8 & AUX-2
317
+
318
+    #if ENABLED(FYSETC_MINI_12864)
319
+      #define DOGLCD_SCK   P0_15
320
+      #define DOGLCD_MOSI  P0_18
321
+      #define DOGLCD_CS    P1_09  // use Ethernet connector for EXP1 cable signals
322
+      #define DOGLCD_A0    P1_14
323
+    #else
324
+      #define DOGLCD_CS    P0_26   // (63) J5-3 & AUX-2
325
+      #define DOGLCD_A0    P2_06   // (59) J3-8 & AUX-2
326
+    #endif
327
+
316 328
     #define LCD_BACKLIGHT_PIN P0_16 //(16) J3-7 & AUX-4 - only used on DOGLCD controllers
317 329
     #define LCD_PINS_ENABLE P0_18  // (51) (MOSI) J3-10 & AUX-3
318 330
     #define LCD_PINS_D4    P0_15   // (52) (SCK)  J3-9 & AUX-3
@@ -323,11 +335,6 @@
323 335
     #endif
324 336
   #endif
325 337
 
326
-  //#define MISO_PIN         P0_17   // (50)  system defined J3-10 & AUX-3
327
-  //#define MOSI_PIN         P0_18   // (51)  system defined J3-10 & AUX-3
328
-  //#define SCK_PIN          P0_15   // (52)  system defined J3-9 & AUX-3
329
-  //#define SS_PIN           P1_23   // (53)  system defined J3-5 & AUX-3 (Sometimes called SDSS)
330
-
331 338
   #if ENABLED(MINIPANEL)
332 339
     // GLCD features
333 340
     // Uncomment screen orientation
@@ -362,10 +369,10 @@
362 369
 
363 370
 #if ENABLED(LPC_SD_LCD)
364 371
 
365
-  #define SCK_PIN          P0_15
366
-  #define MISO_PIN         P0_17
367
-  #define MOSI_PIN         P0_18
368
-  #define SS_PIN           P1_23   // Chip select for SD card used by Marlin
372
+  #define SCK_PIN          P0_15   // (52)  system defined J3-9 & AUX-3
373
+  #define MISO_PIN         P0_17   // (50)  system defined J3-10 & AUX-3
374
+  #define MOSI_PIN         P0_18   // (51)  system defined J3-10 & AUX-3
375
+  #define SS_PIN           P1_23   // (53)  system defined J3-5 & AUX-3 (Sometimes called SDSS) - CS used by Marlin
369 376
   #define ONBOARD_SD_CS    P0_06   // Chip select for "System" SD card
370 377
 
371 378
 #elif ENABLED(LPC_SD_ONBOARD)

Loading…
Cancel
Save