Преглед изворни кода

Fysetc panel, RUMBA and ReARM pins, SPI mode 3 (#13900)

Bob Kuhn пре 5 година
родитељ
комит
c48e6be366

+ 2
- 2
Marlin/src/HAL/HAL_AVR/HAL_spi_AVR.cpp Прегледај датотеку

@@ -66,7 +66,7 @@ void spiBegin (void) {
66 66
 }
67 67
 
68 68
 
69
-#if DISABLED(SOFTWARE_SPI)
69
+#if DISABLED(SOFTWARE_SPI, FORCE_SOFT_SPI)
70 70
 
71 71
   //------------------------------------------------------------------------------
72 72
   // Hardware SPI
@@ -264,6 +264,6 @@ void spiBegin (void) {
264 264
       spiSend(buf[i]);
265 265
   }
266 266
 
267
-#endif // SOFTWARE_SPI
267
+#endif // SOFTWARE_SPI, FORCE_SOFT_SPI
268 268
 
269 269
 #endif // __AVR__

+ 195
- 0
Marlin/src/HAL/HAL_AVR/u8g_com_HAL_AVR_sw_spi.cpp Прегледај датотеку

@@ -0,0 +1,195 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+/**
24
+ * Based on u8g_com_st7920_hw_spi.c
25
+ *
26
+ * Universal 8bit Graphics Library
27
+ *
28
+ * Copyright (c) 2011, olikraus@gmail.com
29
+ * All rights reserved.
30
+ *
31
+ * Redistribution and use in source and binary forms, with or without modification,
32
+ * are permitted provided that the following conditions are met:
33
+ *
34
+ *  * Redistributions of source code must retain the above copyright notice, this list
35
+ *    of conditions and the following disclaimer.
36
+ *
37
+ *  * Redistributions in binary form must reproduce the above copyright notice, this
38
+ *    list of conditions and the following disclaimer in the documentation and/or other
39
+ *    materials provided with the distribution.
40
+ *
41
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
42
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
43
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
44
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
45
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
46
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
47
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
48
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
49
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
50
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
51
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
52
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
53
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54
+ */
55
+
56
+#if defined(ARDUINO) && !defined(ARDUINO_ARCH_STM32) && !defined(ARDUINO_ARCH_SAM)
57
+
58
+#include "../../inc/MarlinConfigPre.h"
59
+
60
+#if HAS_GRAPHICAL_LCD
61
+
62
+#include "../shared/Marduino.h"
63
+#include "../shared/Delay.h"
64
+
65
+#include <U8glib.h>
66
+
67
+uint8_t u8g_bitData, u8g_bitNotData;
68
+uint8_t u8g_bitClock, u8g_bitNotClock;
69
+volatile uint8_t *u8g_outData;
70
+volatile uint8_t *u8g_outClock;
71
+
72
+static void u8g_com_arduino_init_shift_out(uint8_t dataPin, uint8_t clockPin) {
73
+  u8g_outData = portOutputRegister(digitalPinToPort(dataPin));
74
+  u8g_outClock = portOutputRegister(digitalPinToPort(clockPin));
75
+  u8g_bitData = digitalPinToBitMask(dataPin);
76
+  u8g_bitClock = digitalPinToBitMask(clockPin);
77
+
78
+  u8g_bitNotClock = u8g_bitClock;
79
+  u8g_bitNotClock ^= 0xFF;
80
+
81
+  u8g_bitNotData = u8g_bitData;
82
+  u8g_bitNotData ^= 0xFF;
83
+}
84
+
85
+void U8G_spiSend_sw_AVR_mode_0(uint8_t val) {
86
+  uint8_t bitData = u8g_bitData;
87
+  uint8_t bitNotData = u8g_bitNotData;
88
+  uint8_t bitClock = u8g_bitClock;
89
+  uint8_t bitNotClock = u8g_bitNotClock;
90
+  volatile uint8_t *outData = u8g_outData;
91
+  volatile uint8_t *outClock = u8g_outClock;
92
+  U8G_ATOMIC_START();
93
+  for (uint8_t i = 0; i < 8; i++) {
94
+    if (val & 0x80)
95
+      *outData |= bitData;
96
+    else
97
+      *outData &= bitNotData;
98
+    *outClock |= bitClock;
99
+    val <<= 1;
100
+    *outClock &= bitNotClock;
101
+  }
102
+  U8G_ATOMIC_END();
103
+}
104
+
105
+void U8G_spiSend_sw_AVR_mode_3(uint8_t val) {
106
+  uint8_t bitData = u8g_bitData;
107
+  uint8_t bitNotData = u8g_bitNotData;
108
+  uint8_t bitClock = u8g_bitClock;
109
+  uint8_t bitNotClock = u8g_bitNotClock;
110
+  volatile uint8_t *outData = u8g_outData;
111
+  volatile uint8_t *outClock = u8g_outClock;
112
+  U8G_ATOMIC_START();
113
+  for (uint8_t i = 0; i < 8; i++) {
114
+    *outClock &= bitNotClock;
115
+    if (val & 0x80)
116
+      *outData |= bitData;
117
+    else
118
+      *outData &= bitNotData;
119
+    *outClock |= bitClock;
120
+    val <<= 1;
121
+  }
122
+  U8G_ATOMIC_END();
123
+}
124
+
125
+
126
+#if ENABLED(FYSETC_MINI_12864)
127
+  #define U8G_spiSend_sw_AVR U8G_spiSend_sw_AVR_mode_3
128
+#else
129
+  #define U8G_spiSend_sw_AVR U8G_spiSend_sw_AVR_mode_0
130
+#endif
131
+
132
+uint8_t u8g_com_HAL_AVR_sw_sp_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) {
133
+  switch (msg) {
134
+    case U8G_COM_MSG_INIT:
135
+      u8g_com_arduino_init_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK]);
136
+      u8g_com_arduino_assign_pin_output_high(u8g);
137
+      u8g_com_arduino_digital_write(u8g, U8G_PI_SCK, 0);
138
+      u8g_com_arduino_digital_write(u8g, U8G_PI_MOSI, 0);
139
+      break;
140
+
141
+    case U8G_COM_MSG_STOP:
142
+      break;
143
+
144
+    case U8G_COM_MSG_RESET:
145
+      if (U8G_PIN_NONE != u8g->pin_list[U8G_PI_RESET]) u8g_com_arduino_digital_write(u8g, U8G_PI_RESET, arg_val);
146
+      break;
147
+
148
+    case U8G_COM_MSG_CHIP_SELECT:
149
+      #if ENABLED(FYSETC_MINI_12864)           // LCD SPI is running mode 3 while SD card is running mode 0
150
+        if (arg_val) {                         //   SCK idle state needs to be set to the proper idle state before
151
+                                               //   the next chip select goes active
152
+          u8g_com_arduino_digital_write(u8g, U8G_PI_SCK, 1);  // Set SCK to mode 3 idle state before CS goes active
153
+          u8g_com_arduino_digital_write(u8g, U8G_PI_CS, LOW);
154
+        }
155
+        else {
156
+          u8g_com_arduino_digital_write(u8g, U8G_PI_CS, HIGH);
157
+          u8g_com_arduino_digital_write(u8g, U8G_PI_SCK, 0);  // Set SCK to mode 0 idle state after CS goes inactive
158
+        }
159
+      #else
160
+        u8g_com_arduino_digital_write(u8g, U8G_PI_CS, !arg_val);
161
+      #endif
162
+      break;
163
+
164
+    case U8G_COM_MSG_WRITE_BYTE:
165
+      U8G_spiSend_sw_AVR(arg_val);
166
+      break;
167
+
168
+    case U8G_COM_MSG_WRITE_SEQ: {
169
+        uint8_t *ptr = (uint8_t *)arg_ptr;
170
+        while (arg_val > 0) {
171
+          U8G_spiSend_sw_AVR(*ptr++);
172
+          arg_val--;
173
+        }
174
+      }
175
+      break;
176
+
177
+      case U8G_COM_MSG_WRITE_SEQ_P: {
178
+        uint8_t *ptr = (uint8_t *)arg_ptr;
179
+        while (arg_val > 0) {
180
+          U8G_spiSend_sw_AVR(u8g_pgm_read(ptr));
181
+          ptr++;
182
+          arg_val--;
183
+        }
184
+      }
185
+      break;
186
+
187
+    case U8G_COM_MSG_ADDRESS:                     /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
188
+      u8g_com_arduino_digital_write(u8g, U8G_PI_A0, arg_val);
189
+      break;
190
+  }
191
+  return 1;
192
+}
193
+
194
+#endif // HAS_GRAPHICAL_LCD
195
+#endif // ARDUINO_ARCH_SAM

+ 154
- 0
Marlin/src/HAL/HAL_DUE/u8g_com_HAL_DUE_sw_spi.cpp Прегледај датотеку

@@ -0,0 +1,154 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+/**
24
+ * Based on u8g_com_std_sw_spi.c
25
+ *
26
+ * Universal 8bit Graphics Library
27
+ *
28
+ * Copyright (c) 2015, olikraus@gmail.com
29
+ * All rights reserved.
30
+ *
31
+ * Redistribution and use in source and binary forms, with or without modification,
32
+ * are permitted provided that the following conditions are met:
33
+ *
34
+ *  * Redistributions of source code must retain the above copyright notice, this list
35
+ *    of conditions and the following disclaimer.
36
+ *
37
+ *  * Redistributions in binary form must reproduce the above copyright notice, this
38
+ *    list of conditions and the following disclaimer in the documentation and/or other
39
+ *    materials provided with the distribution.
40
+ *
41
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
42
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
43
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
44
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
45
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
46
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
47
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
48
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
49
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
50
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
51
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
52
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
53
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54
+ */
55
+
56
+#ifdef ARDUINO_ARCH_SAM
57
+
58
+#include "../../inc/MarlinConfigPre.h"
59
+
60
+#if HAS_GRAPHICAL_LCD && !ENABLED(U8GLIB_ST7920)
61
+
62
+#undef SPI_SPEED
63
+#define SPI_SPEED 2  // About 2 MHz
64
+
65
+#include "../shared/Marduino.h"
66
+#include "../shared/Delay.h"
67
+
68
+#include <U8glib.h>
69
+
70
+void u8g_SetPIOutput_DUE(u8g_t *u8g, uint8_t pin_index);
71
+void u8g_SetPILevel_DUE(u8g_t *u8g, uint8_t pin_index, uint8_t level);
72
+void U8G_spiSend_sw_DUE_mode_0(uint8_t val);
73
+void U8G_spiSend_sw_DUE_mode_3(uint8_t val);
74
+
75
+Pio *SCK_pPio, *MOSI_pPio;
76
+uint32_t SCK_dwMask, MOSI_dwMask;
77
+
78
+#if ENABLED(FYSETC_MINI_12864)
79
+  #define U8G_spiSend_sw_DUE U8G_spiSend_sw_DUE_mode_3
80
+#else
81
+  #define U8G_spiSend_sw_DUE U8G_spiSend_sw_DUE_mode_0
82
+#endif
83
+
84
+uint8_t u8g_com_HAL_DUE_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) {
85
+  switch (msg) {
86
+    case U8G_COM_MSG_INIT:
87
+      SCK_pPio = g_APinDescription[u8g->pin_list[U8G_PI_SCK]].pPort;
88
+      SCK_dwMask = g_APinDescription[u8g->pin_list[U8G_PI_SCK]].ulPin;
89
+      MOSI_pPio = g_APinDescription[u8g->pin_list[U8G_PI_MOSI]].pPort;
90
+      MOSI_dwMask = g_APinDescription[u8g->pin_list[U8G_PI_MOSI]].ulPin;
91
+      u8g_SetPIOutput_DUE(u8g, U8G_PI_SCK);
92
+      u8g_SetPIOutput_DUE(u8g, U8G_PI_MOSI);
93
+      u8g_SetPIOutput_DUE(u8g, U8G_PI_CS);
94
+      u8g_SetPIOutput_DUE(u8g, U8G_PI_A0);
95
+      if (U8G_PIN_NONE != u8g->pin_list[U8G_PI_RESET]) u8g_SetPIOutput_DUE(u8g, U8G_PI_RESET);
96
+      u8g_SetPILevel_DUE(u8g, U8G_PI_SCK, 0);
97
+      u8g_SetPILevel_DUE(u8g, U8G_PI_MOSI, 0);
98
+      break;
99
+
100
+    case U8G_COM_MSG_STOP:
101
+      break;
102
+
103
+    case U8G_COM_MSG_RESET:
104
+      if (U8G_PIN_NONE != u8g->pin_list[U8G_PI_RESET]) u8g_SetPILevel_DUE(u8g, U8G_PI_RESET, arg_val);
105
+      break;
106
+
107
+    case U8G_COM_MSG_CHIP_SELECT:
108
+      #if ENABLED(FYSETC_MINI_12864)           // LCD SPI is running mode 3 while SD card is running mode 0
109
+        if (arg_val) {                        //   SCK idle state needs to be set to the proper idle state before
110
+                                               //   the next chip select goes active
111
+          u8g_SetPILevel_DUE(u8g, U8G_PI_SCK, 1);  //set SCK to mode 3 idle state before CS goes active
112
+          u8g_SetPILevel_DUE(u8g, U8G_PI_CS, LOW);
113
+        }
114
+        else {
115
+          u8g_SetPILevel_DUE(u8g, U8G_PI_CS, HIGH);
116
+          u8g_SetPILevel_DUE(u8g, U8G_PI_SCK, 0); //set SCK to mode 0 idle state after CS goes inactive
117
+        }
118
+      #else
119
+        u8g_SetPILevel_DUE(u8g, U8G_PI_CS, !arg_val);
120
+      #endif
121
+      break;
122
+
123
+    case U8G_COM_MSG_WRITE_BYTE:
124
+      U8G_spiSend_sw_DUE(arg_val);
125
+      break;
126
+
127
+    case U8G_COM_MSG_WRITE_SEQ: {
128
+        uint8_t *ptr = (uint8_t *)arg_ptr;
129
+        while (arg_val > 0) {
130
+          U8G_spiSend_sw_DUE(*ptr++);
131
+          arg_val--;
132
+        }
133
+      }
134
+      break;
135
+
136
+      case U8G_COM_MSG_WRITE_SEQ_P: {
137
+        uint8_t *ptr = (uint8_t *)arg_ptr;
138
+        while (arg_val > 0) {
139
+          U8G_spiSend_sw_DUE(u8g_pgm_read(ptr));
140
+          ptr++;
141
+          arg_val--;
142
+        }
143
+      }
144
+      break;
145
+
146
+    case U8G_COM_MSG_ADDRESS:                     /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
147
+      u8g_SetPILevel_DUE(u8g, U8G_PI_A0, arg_val);
148
+      break;
149
+  }
150
+  return 1;
151
+}
152
+
153
+#endif // HAS_GRAPHICAL_LCD
154
+#endif // ARDUINO_ARCH_SAM

+ 114
- 0
Marlin/src/HAL/HAL_DUE/u8g_com_HAL_DUE_sw_spi_shared.cpp Прегледај датотеку

@@ -0,0 +1,114 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+/**
24
+ * Based on u8g_com_st7920_hw_spi.c
25
+ *
26
+ * Universal 8bit Graphics Library
27
+ *
28
+ * Copyright (c) 2011, olikraus@gmail.com
29
+ * All rights reserved.
30
+ *
31
+ * Redistribution and use in source and binary forms, with or without modification,
32
+ * are permitted provided that the following conditions are met:
33
+ *
34
+ *  * Redistributions of source code must retain the above copyright notice, this list
35
+ *    of conditions and the following disclaimer.
36
+ *
37
+ *  * Redistributions in binary form must reproduce the above copyright notice, this
38
+ *    list of conditions and the following disclaimer in the documentation and/or other
39
+ *    materials provided with the distribution.
40
+ *
41
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
42
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
43
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
44
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
45
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
46
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
47
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
48
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
49
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
50
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
51
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
52
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
53
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54
+ */
55
+
56
+#ifdef ARDUINO_ARCH_SAM
57
+
58
+#include "../../inc/MarlinConfigPre.h"
59
+
60
+//C:\Users\bobku\Documents\GitHub\Marlin-Bob-2\Marlin\src\inc\MarlinConfigPre.h
61
+//C:\Users\bobku\Documents\GitHub\Marlin-Bob-2\Marlin\src\HAL\HAL_DUE\u8g_com_HAL_DUE_sw_spi_shared.cpp
62
+
63
+#if HAS_GRAPHICAL_LCD
64
+
65
+#include "../shared/Marduino.h"
66
+#include "../shared/Delay.h"
67
+
68
+#include <U8glib.h>
69
+
70
+void u8g_SetPIOutput_DUE(u8g_t *u8g, uint8_t pin_index) {
71
+  PIO_Configure(g_APinDescription[u8g->pin_list[pin_index]].pPort, PIO_OUTPUT_1,
72
+    g_APinDescription[u8g->pin_list[pin_index]].ulPin, g_APinDescription[u8g->pin_list[pin_index]].ulPinConfiguration);  // OUTPUT
73
+}
74
+
75
+void u8g_SetPILevel_DUE(u8g_t *u8g, uint8_t pin_index, uint8_t level) {
76
+  volatile Pio* port = g_APinDescription[u8g->pin_list[pin_index]].pPort;
77
+  uint32_t mask = g_APinDescription[u8g->pin_list[pin_index]].ulPin;
78
+  if (level) port->PIO_SODR = mask; else port->PIO_CODR = mask;
79
+}
80
+
81
+extern Pio *SCK_pPio, *MOSI_pPio;
82
+extern uint32_t SCK_dwMask, MOSI_dwMask;
83
+
84
+void U8G_spiSend_sw_DUE_mode_0(uint8_t val) { // 800KHz
85
+  for (uint8_t i = 0; i < 8; i++) {
86
+    if (val & 0x80)
87
+      MOSI_pPio->PIO_SODR = MOSI_dwMask;
88
+    else
89
+      MOSI_pPio->PIO_CODR = MOSI_dwMask;
90
+    DELAY_NS(48);
91
+    SCK_pPio->PIO_SODR = SCK_dwMask;
92
+    DELAY_NS(905); // 762 dead, 810 garbage, 858/0 900kHz, 905/1 825k, 953/1 800k, 1000/2 725KHz
93
+    val <<= 1;
94
+    SCK_pPio->PIO_CODR = SCK_dwMask;
95
+  }
96
+}
97
+
98
+
99
+void U8G_spiSend_sw_DUE_mode_3(uint8_t val) { // 800KHz
100
+  for (uint8_t i = 0; i < 8; i++) {
101
+    SCK_pPio->PIO_CODR = SCK_dwMask;
102
+    DELAY_NS(48);
103
+    if (val & 0x80)
104
+      MOSI_pPio->PIO_SODR = MOSI_dwMask;
105
+    else
106
+      MOSI_pPio->PIO_CODR = MOSI_dwMask;
107
+    SCK_pPio->PIO_SODR = SCK_dwMask;
108
+    DELAY_NS(905); // 762 dead, 810 garbage, 858/0 900kHz, 905/1 825k, 953/1 800k, 1000/2 725KHz
109
+    val <<= 1;
110
+  }
111
+}
112
+
113
+#endif // HAS_GRAPHICAL_LCD
114
+#endif // ARDUINO_ARCH_SAM

+ 13
- 2
Marlin/src/HAL/HAL_LPC1768/u8g/u8g_com_HAL_LPC1768_sw_spi.cpp Прегледај датотеку

@@ -158,7 +158,19 @@ uint8_t u8g_com_HAL_LPC1768_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val,
158 158
       break;
159 159
 
160 160
     case U8G_COM_MSG_CHIP_SELECT:
161
-      u8g_SetPILevel(u8g, U8G_PI_CS, !arg_val);
161
+      #if ENABLED(FYSETC_MINI_12864)           // LCD SPI is running mode 3 while SD card is running mode 0
162
+        if (arg_val) {                         //   SCK idle state needs to be set to the proper idle state before
163
+                                               //   the next chip select goes active
164
+          u8g_SetPILevel(u8g, U8G_PI_SCK, 1);  // Set SCK to mode 3 idle state before CS goes active
165
+          u8g_SetPILevel(u8g, U8G_PI_CS, LOW);
166
+        }
167
+        else {
168
+          u8g_SetPILevel(u8g, U8G_PI_CS, HIGH);
169
+          u8g_SetPILevel(u8g, U8G_PI_SCK, 0);  // Set SCK to mode 0 idle state after CS goes inactive
170
+        }
171
+      #else
172
+        u8g_SetPILevel(u8g, U8G_PI_CS, !arg_val);
173
+      #endif
162 174
       break;
163 175
 
164 176
     case U8G_COM_MSG_WRITE_BYTE:
@@ -192,5 +204,4 @@ uint8_t u8g_com_HAL_LPC1768_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val,
192 204
 }
193 205
 
194 206
 #endif // HAS_GRAPHICAL_LCD
195
-
196 207
 #endif // TARGET_LPC1768

+ 6
- 2
Marlin/src/lcd/dogm/HAL_LCD_com_defines.h Прегледај датотеку

@@ -24,16 +24,20 @@
24 24
 
25 25
 #ifndef U8G_HAL_LINKS
26 26
 
27
-  uint8_t u8g_com_arduino_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
28
-  #define U8G_COM_HAL_SW_SPI_FN  u8g_com_arduino_sw_spi_fn
29 27
 
30 28
   #ifdef __SAM3X8E__
29
+    uint8_t u8g_com_HAL_DUE_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
30
+    #define U8G_COM_HAL_SW_SPI_FN  u8g_com_HAL_DUE_sw_spi_fn
31
+
31 32
     uint8_t u8g_com_HAL_DUE_shared_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
32 33
     #define U8G_COM_HAL_HW_SPI_FN u8g_com_HAL_DUE_shared_hw_spi_fn
33 34
 
34 35
     uint8_t u8g_com_HAL_DUE_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
35 36
     #define U8G_COM_ST7920_HAL_SW_SPI u8g_com_HAL_DUE_ST7920_sw_spi_fn
36 37
   #else
38
+    uint8_t u8g_com_HAL_AVR_sw_sp_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
39
+    #define U8G_COM_HAL_SW_SPI_FN  u8g_com_HAL_AVR_sw_sp_fn
40
+
37 41
     uint8_t u8g_com_arduino_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
38 42
     #define U8G_COM_HAL_HW_SPI_FN u8g_com_arduino_hw_spi_fn
39 43
 

+ 3
- 1
Marlin/src/pins/pins_BIGTREE_SKR_V1.3.h Прегледај датотеку

@@ -207,8 +207,10 @@
207 207
 
208 208
       #define LCD_BACKLIGHT_PIN -1
209 209
 
210
+      //#define FORCE_SOFT_SPI    // Use this if default of hardware SPI causes display problems
211
+                                  //   results in LCD soft SPI mode 3, SD soft SPI mode 0
212
+
210 213
       #define LCD_RESET_PIN P1_20   // Must be high or open for LCD to operate normally.
211
-                                    // Seems to work best if left open.
212 214
 
213 215
       #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0)
214 216
         #ifndef RGB_LED_R_PIN

+ 3
- 0
Marlin/src/pins/pins_MKS_SBASE.h Прегледај датотеку

@@ -259,6 +259,9 @@
259 259
     #define DOGLCD_SCK     P2_11           // J8-5  (SCK on Fysetc schematic)
260 260
     #define DOGLCD_MOSI    P4_28           // J8-6  (MOSI on Fysetc schematic)
261 261
 
262
+    //#define FORCE_SOFT_SPI    // Use this if default of hardware SPI causes display problems
263
+                                //   results in LCD soft SPI mode 3, SD soft SPI mode 0
264
+
262 265
     #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0)
263 266
       #ifndef RGB_LED_R_PIN
264 267
         #define RGB_LED_R_PIN P2_12        // J8-4  (LCD_D6 on Fysetc schematic)

+ 5
- 1
Marlin/src/pins/pins_RAMPS.h Прегледај датотеку

@@ -538,8 +538,12 @@
538 538
 
539 539
       #define SD_DETECT_PIN     49
540 540
 
541
+
542
+
543
+      //#define FORCE_SOFT_SPI    // Use this if default of hardware SPI causes display problems
544
+                                  //   results in LCD soft SPI mode 3, SD soft SPI mode 0
545
+
541 546
       #define LCD_RESET_PIN     23   // Must be high or open for LCD to operate normally.
542
-                                     // Seems to work best if left open.
543 547
 
544 548
       #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0)
545 549
         #ifndef RGB_LED_R_PIN

+ 4
- 2
Marlin/src/pins/pins_RAMPS_FD_V1.h Прегледај датотеку

@@ -155,11 +155,13 @@
155 155
   #if ENABLED(FYSETC_MINI_12864)
156 156
     #define DOGLCD_CS      LCD_PINS_ENABLE
157 157
     #define DOGLCD_A0      LCD_PINS_RS
158
+    #define DOGLCD_SCK     76
159
+    #define DOGLCD_MOSI    75
158 160
 
159
-    //#define FORCE_SOFT_SPI    // Use this if default of hardware SPI causes problems
161
+    //#define FORCE_SOFT_SPI    // Use this if default of hardware SPI causes display problems
162
+                                //   results in LCD soft SPI mode 3, SD soft SPI mode 0
160 163
 
161 164
     #define LCD_RESET_PIN  23   // Must be high or open for LCD to operate normally.
162
-                                // Seems to work best if left open.
163 165
 
164 166
     #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0)
165 167
       #ifndef RGB_LED_R_PIN

+ 21
- 2
Marlin/src/pins/pins_RAMPS_RE_ARM.h Прегледај датотеку

@@ -347,9 +347,28 @@
347 347
     #if ENABLED(FYSETC_MINI_12864)
348 348
       #define DOGLCD_SCK   P0_15
349 349
       #define DOGLCD_MOSI  P0_18
350
-      #define DOGLCD_CS    P1_09  // use Ethernet connector for EXP1 cable signals
350
+
351
+      // EXP1 on LCD adapter is not usable - using Ethernet connector instead
352
+      #define DOGLCD_CS    P1_09
351 353
       #define DOGLCD_A0    P1_14
352
-      #define FORCE_SOFT_SPI      // required on a Re-ARM system
354
+      //#define FORCE_SOFT_SPI    // Use this if default of hardware SPI causes display problems
355
+                                  //   results in LCD soft SPI mode 3, SD soft SPI mode 0
356
+
357
+      #define LCD_RESET_PIN  P0_16   // Must be high or open for LCD to operate normally.
358
+
359
+      #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0)
360
+        #ifndef RGB_LED_R_PIN
361
+          #define RGB_LED_R_PIN P1_00
362
+        #endif
363
+        #ifndef RGB_LED_G_PIN
364
+          #define RGB_LED_G_PIN P1_01
365
+        #endif
366
+        #ifndef RGB_LED_B_PIN
367
+          #define RGB_LED_B_PIN P1_08
368
+        #endif
369
+      #elif ENABLED(FYSETC_MINI_12864_2_1)
370
+        #define NEOPIXEL_PIN    P1_00
371
+      #endif
353 372
     #else
354 373
       #define DOGLCD_CS    P0_26   // (63) J5-3 & AUX-2
355 374
       #define DOGLCD_A0    P2_06   // (59) J3-8 & AUX-2

+ 25
- 0
Marlin/src/pins/pins_RUMBA.h Прегледај датотеку

@@ -175,6 +175,31 @@
175 175
   #define DOGLCD_MOSI      42
176 176
   #define DOGLCD_SCK       18
177 177
   #define DOGLCD_A0        LCD_PINS_DC
178
+#elif ENABLED(FYSETC_MINI_12864)
179
+  #define DOGLCD_CS        42
180
+  #define DOGLCD_A0        19
181
+  #define DOGLCD_MOSI      51
182
+  #define DOGLCD_SCK       52
183
+
184
+  //#define FORCE_SOFT_SPI    // Use this if default of hardware SPI causes display problems
185
+                              //   results in LCD soft SPI mode 3, SD soft SPI mode 0
186
+
187
+  #define LCD_RESET_PIN  18   // Must be high or open for LCD to operate normally.
188
+
189
+  #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0)
190
+    #ifndef RGB_LED_R_PIN
191
+      #define RGB_LED_R_PIN 41
192
+    #endif
193
+    #ifndef RGB_LED_G_PIN
194
+      #define RGB_LED_G_PIN 38
195
+    #endif
196
+    #ifndef RGB_LED_B_PIN
197
+      #define RGB_LED_B_PIN 40
198
+    #endif
199
+  #elif ENABLED(FYSETC_MINI_12864_2_1)
200
+    #define NEOPIXEL_PIN   25
201
+  #endif
202
+
178 203
 #else
179 204
   #define LCD_PINS_RS      19
180 205
   #define LCD_PINS_ENABLE  42

+ 2
- 2
Marlin/src/pins/pins_RURAMPS4D_11.h Прегледај датотеку

@@ -233,10 +233,10 @@
233 233
     #define DOGLCD_CS       64
234 234
     #define DOGLCD_A0       63
235 235
 
236
-    //#define FORCE_SOFT_SPI     // Use this if default of hardware SPI causes problems
236
+    //#define FORCE_SOFT_SPI    // Use this if default of hardware SPI causes display problems
237
+                                //   results in LCD soft SPI mode 3, SD soft SPI mode 0
237 238
 
238 239
     #define LCD_RESET_PIN   48   // Must be high or open for LCD to operate normally.
239
-                                 // Seems to work best if left open.
240 240
 
241 241
     #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0)
242 242
       #ifndef RGB_LED_R_PIN

+ 2
- 2
Marlin/src/pins/pins_RURAMPS4D_13.h Прегледај датотеку

@@ -219,10 +219,10 @@
219 219
     #define DOGLCD_CS       64
220 220
     #define DOGLCD_A0       63
221 221
 
222
-    //#define FORCE_SOFT_SPI     // Use this if default of hardware SPI causes problems
222
+    //#define FORCE_SOFT_SPI    // Use this if default of hardware SPI causes display problems
223
+                                //   results in LCD soft SPI mode 3, SD soft SPI mode 0
223 224
 
224 225
     #define LCD_RESET_PIN   48   // Must be high or open for LCD to operate normally.
225
-                                 // Seems to work best if left open.
226 226
 
227 227
     #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0)
228 228
       #ifndef RGB_LED_R_PIN

Loading…
Откажи
Сачувај