Переглянути джерело

✨ ESP32 Panda_ZHU and Panda_M4 (#22644)

Mark 2 роки тому
джерело
коміт
4e9ae9449f
Аккаунт користувача з таким Email не знайдено

+ 3
- 1
Marlin/src/HAL/AVR/HAL_SPI.cpp Переглянути файл

@@ -34,7 +34,9 @@
34 34
 #include "../../inc/MarlinConfig.h"
35 35
 
36 36
 void spiBegin() {
37
-  OUT_WRITE(SD_SS_PIN, HIGH);
37
+  #if PIN_EXISTS(SD_SS)
38
+    OUT_WRITE(SD_SS_PIN, HIGH);
39
+  #endif
38 40
   SET_OUTPUT(SD_SCK_PIN);
39 41
   SET_INPUT(SD_MISO_PIN);
40 42
   SET_OUTPUT(SD_MOSI_PIN);

+ 26
- 2
Marlin/src/HAL/ESP32/HAL.cpp Переглянути файл

@@ -28,6 +28,10 @@
28 28
 #include <esp_adc_cal.h>
29 29
 #include <HardwareSerial.h>
30 30
 
31
+#if ENABLED(USE_ESP32_TASK_WDT)
32
+  #include <esp_task_wdt.h>
33
+#endif
34
+
31 35
 #if ENABLED(WIFISUPPORT)
32 36
   #include <ESPAsyncWebServer.h>
33 37
   #include "wifi.h"
@@ -90,8 +94,24 @@ volatile int numPWMUsed = 0,
90 94
 
91 95
 #endif
92 96
 
93
-void HAL_init_board() {
97
+#if ENABLED(USE_ESP32_EXIO)
98
+  HardwareSerial YSerial2(2);
99
+
100
+  void Write_EXIO(uint8_t IO, uint8_t v) {
101
+    if (ISRS_ENABLED()) {
102
+      DISABLE_ISRS();
103
+      YSerial2.write(0x80 | (((char)v) << 5) | (IO - 100));
104
+      ENABLE_ISRS();
105
+    }
106
+    else
107
+      YSerial2.write(0x80 | (((char)v) << 5) | (IO - 100));
108
+  }
109
+#endif
94 110
 
111
+void HAL_init_board() {
112
+  #if ENABLED(USE_ESP32_TASK_WDT)
113
+    esp_task_wdt_init(10, true);
114
+  #endif
95 115
   #if ENABLED(ESP3D_WIFISUPPORT)
96 116
     esp3dlib.init();
97 117
   #elif ENABLED(WIFISUPPORT)
@@ -127,7 +147,11 @@ void HAL_init_board() {
127 147
   // Initialize the i2s peripheral only if the I2S stepper stream is enabled.
128 148
   // The following initialization is performed after Serial1 and Serial2 are defined as
129 149
   // their native pins might conflict with the i2s stream even when they are remapped.
130
-  TERN_(I2S_STEPPER_STREAM, i2s_init());
150
+  #if ENABLED(USE_ESP32_EXIO)
151
+    YSerial2.begin(460800 * 3, SERIAL_8N1, 16, 17);
152
+  #elif ENABLED(I2S_STEPPER_STREAM)
153
+    i2s_init();
154
+  #endif
131 155
 }
132 156
 
133 157
 void HAL_idletask() {

+ 4
- 0
Marlin/src/HAL/ESP32/HAL.h Переглянути файл

@@ -142,6 +142,10 @@ void HAL_idletask();
142 142
 inline void HAL_init() {}
143 143
 void HAL_init_board();
144 144
 
145
+#if ENABLED(USE_ESP32_EXIO)
146
+  void Write_EXIO(uint8_t IO, uint8_t v);
147
+#endif
148
+
145 149
 //
146 150
 // Delay in cycles (used by DELAY_NS / DELAY_US)
147 151
 //

+ 2
- 4
Marlin/src/HAL/ESP32/HAL_SPI.cpp Переглянути файл

@@ -53,11 +53,9 @@ static SPISettings spiConfig;
53 53
 // ------------------------
54 54
 
55 55
 void spiBegin() {
56
-  #if !PIN_EXISTS(SD_SS)
57
-    #error "SD_SS_PIN not defined!"
56
+  #if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_SS)
57
+    OUT_WRITE(SD_SS_PIN, HIGH);
58 58
   #endif
59
-
60
-  OUT_WRITE(SD_SS_PIN, HIGH);
61 59
 }
62 60
 
63 61
 void spiInit(uint8_t spiRate) {

+ 6
- 0
Marlin/src/HAL/ESP32/esp32.csv Переглянути файл

@@ -0,0 +1,6 @@
1
+# Name,   Type, SubType, Offset,  Size, Flags
2
+nvs,      data, nvs,     0x9000,   0x5000,
3
+otadata,  data, ota,     0xe000,   0x2000,
4
+app0,     app,  ota_0,   0x10000,  0x180000,
5
+app1,     app,  ota_1,   0x190000, 0x180000,
6
+spiffs,   data, spiffs,  0x310000, 0xF0000,

+ 13
- 7
Marlin/src/HAL/ESP32/fastio.h Переглянути файл

@@ -40,13 +40,19 @@
40 40
 // Set pin as input with pullup mode
41 41
 #define _PULLUP(IO, v)          pinMode(IO, v ? INPUT_PULLUP : INPUT)
42 42
 
43
-// Read a pin wrapper
44
-#define READ(IO)                (IS_I2S_EXPANDER_PIN(IO) ? i2s_state(I2S_EXPANDER_PIN_INDEX(IO)) : digitalRead(IO))
45
-
46
-// Write to a pin wrapper
47
-#define WRITE(IO, v)            (IS_I2S_EXPANDER_PIN(IO) ? i2s_write(I2S_EXPANDER_PIN_INDEX(IO), v) : digitalWrite(IO, v))
48
-
49
-// Set pin as input wrapper
43
+#if ENABLED(USE_ESP32_EXIO)
44
+  // Read a pin wrapper
45
+  #define READ(IO)                digitalRead(IO)
46
+  // Write to a pin wrapper
47
+  #define WRITE(IO, v)            (IO >= 100 ? Write_EXIO(IO, v) : digitalWrite(IO, v))
48
+#else
49
+  // Read a pin wrapper
50
+  #define READ(IO)                (IS_I2S_EXPANDER_PIN(IO) ? i2s_state(I2S_EXPANDER_PIN_INDEX(IO)) : digitalRead(IO))
51
+  // Write to a pin wrapper
52
+  #define WRITE(IO, v)            (IS_I2S_EXPANDER_PIN(IO) ? i2s_write(I2S_EXPANDER_PIN_INDEX(IO), v) : digitalWrite(IO, v))
53
+#endif
54
+
55
+// Set pin as input wrapper (0x80 | (v << 5) | (IO - 100))
50 56
 #define SET_INPUT(IO)           _SET_INPUT(IO)
51 57
 
52 58
 // Set pin as input with pullup wrapper

+ 3
- 0
Marlin/src/HAL/ESP32/i2s.cpp Переглянути файл

@@ -23,6 +23,8 @@
23 23
 
24 24
 #include "../../inc/MarlinConfigPre.h"
25 25
 
26
+#if DISABLED(USE_ESP32_EXIO)
27
+
26 28
 #include "i2s.h"
27 29
 
28 30
 #include "../shared/Marduino.h"
@@ -340,4 +342,5 @@ void i2s_push_sample() {
340 342
   dma.current[dma.rw_pos++] = i2s_port_data;
341 343
 }
342 344
 
345
+#endif // !USE_ESP32_EXIO
343 346
 #endif // ARDUINO_ARCH_ESP32

+ 1
- 1
Marlin/src/HAL/ESP32/watchdog.h Переглянути файл

@@ -25,7 +25,7 @@
25 25
   extern "C" {
26 26
 #endif
27 27
 
28
-    esp_err_t esp_task_wdt_reset();
28
+  esp_err_t esp_task_wdt_reset();
29 29
 
30 30
 #ifdef __cplusplus
31 31
   }

+ 3
- 1
Marlin/src/HAL/STM32/HAL_SPI.cpp Переглянути файл

@@ -47,7 +47,9 @@ static SPISettings spiConfig;
47 47
   #include "../shared/Delay.h"
48 48
 
49 49
   void spiBegin(void) {
50
-    OUT_WRITE(SD_SS_PIN, HIGH);
50
+    #if PIN_EXISTS(SD_SS)
51
+      OUT_WRITE(SD_SS_PIN, HIGH);
52
+    #endif
51 53
     OUT_WRITE(SD_SCK_PIN, HIGH);
52 54
     SET_INPUT(SD_MISO_PIN);
53 55
     OUT_WRITE(SD_MOSI_PIN, HIGH);

+ 2
- 3
Marlin/src/HAL/TEENSY31_32/HAL_SPI.cpp Переглянути файл

@@ -36,10 +36,9 @@ static SPISettings spiConfig;
36 36
 
37 37
 // Initialize SPI bus
38 38
 void spiBegin() {
39
-  #if !PIN_EXISTS(SD_SS)
40
-    #error "SD_SS_PIN not defined!"
39
+  #if PIN_EXISTS(SD_SS)
40
+    OUT_WRITE(SD_SS_PIN, HIGH);
41 41
   #endif
42
-  OUT_WRITE(SD_SS_PIN, HIGH);
43 42
   SET_OUTPUT(SD_SCK_PIN);
44 43
   SET_INPUT(SD_MISO_PIN);
45 44
   SET_OUTPUT(SD_MOSI_PIN);

+ 2
- 3
Marlin/src/HAL/TEENSY35_36/HAL_SPI.cpp Переглянути файл

@@ -36,10 +36,9 @@
36 36
 static SPISettings spiConfig;
37 37
 
38 38
 void spiBegin() {
39
-  #if !PIN_EXISTS(SD_SS)
40
-    #error "SD_SS_PIN not defined!"
39
+  #if PIN_EXISTS(SD_SS)
40
+    OUT_WRITE(SD_SS_PIN, HIGH);
41 41
   #endif
42
-  OUT_WRITE(SD_SS_PIN, HIGH);
43 42
   SET_OUTPUT(SD_SCK_PIN);
44 43
   SET_INPUT(SD_MISO_PIN);
45 44
   SET_OUTPUT(SD_MOSI_PIN);

+ 2
- 5
Marlin/src/HAL/TEENSY40_41/HAL_SPI.cpp Переглянути файл

@@ -51,12 +51,9 @@ static SPISettings spiConfig;
51 51
 // ------------------------
52 52
 
53 53
 void spiBegin() {
54
-  #ifndef SD_SS_PIN
55
-    #error "SD_SS_PIN is not defined!"
54
+  #if PIN_EXISTS(SD_SS)
55
+    OUT_WRITE(SD_SS_PIN, HIGH);
56 56
   #endif
57
-
58
-  OUT_WRITE(SD_SS_PIN, HIGH);
59
-
60 57
   //SET_OUTPUT(SD_SCK_PIN);
61 58
   //SET_INPUT(SD_MISO_PIN);
62 59
   //SET_OUTPUT(SD_MOSI_PIN);

+ 2
- 0
Marlin/src/core/boards.h Переглянути файл

@@ -422,6 +422,8 @@
422 422
 #define BOARD_MRR_ESPE                6002  // MRR ESPE based on ESP32 (with I2S stepper stream)
423 423
 #define BOARD_E4D_BOX                 6003  // E4d@BOX
424 424
 #define BOARD_FYSETC_E4               6004  // FYSETC E4
425
+#define BOARD_PANDA_ZHU               6005  // Panda_ZHU
426
+#define BOARD_PANDA_M4                6006  // Panda_M4
425 427
 
426 428
 //
427 429
 // SAMD51 ARM Cortex M4

+ 1
- 0
Marlin/src/gcode/sd/M1001.cpp Переглянути файл

@@ -27,6 +27,7 @@
27 27
 #include "../gcode.h"
28 28
 #include "../../module/planner.h"
29 29
 #include "../../module/printcounter.h"
30
+#include "../../module/temperature.h"
30 31
 #include "../../sd/cardreader.h"
31 32
 
32 33
 #ifdef SD_FINISHED_RELEASECOMMAND

+ 2
- 2
Marlin/src/inc/SanityCheck.h Переглянути файл

@@ -597,9 +597,9 @@
597 597
   #error "SPINDLE_LASER_PWM (true) is now set with SPINDLE_LASER_USE_PWM (enabled)."
598 598
 #endif
599 599
 
600
-#if MOTHERBOARD == BOARD_DUE3DOM_MINI && PIN_EXISTS(TEMP_2) && DISABLED(TEMP_SENSOR_BOARD)
600
+#if MB(DUE3DOM_MINI) && PIN_EXISTS(TEMP_2) && DISABLED(TEMP_SENSOR_BOARD)
601 601
   #warning "Onboard temperature sensor for BOARD_DUE3DOM_MINI has moved from TEMP_SENSOR_2 (TEMP_2_PIN) to TEMP_SENSOR_BOARD (TEMP_BOARD_PIN)."
602
-#elif MOTHERBOARD == BOARD_BTT_SKR_E3_TURBO && PIN_EXISTS(TEMP_2) && DISABLED(TEMP_SENSOR_BOARD)
602
+#elif MB(BTT_SKR_E3_TURBO) && PIN_EXISTS(TEMP_2) && DISABLED(TEMP_SENSOR_BOARD)
603 603
   #warning "Onboard temperature sensor for BOARD_BTT_SKR_E3_TURBO has moved from TEMP_SENSOR_2 (TEMP_2_PIN) to TEMP_SENSOR_BOARD (TEMP_BOARD_PIN)."
604 604
 #endif
605 605
 

+ 38
- 0
Marlin/src/pins/esp32/pins_PANDA_M4.h Переглянути файл

@@ -0,0 +1,38 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2021 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 <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+/**
25
+ * Panda M4 pin assignments
26
+ */
27
+
28
+#define BOARD_INFO_NAME "Panda_M4"
29
+
30
+#include "pins_PANDA_common.h"
31
+
32
+//
33
+// Steppers
34
+//
35
+#define X_ENABLE_PIN                         115
36
+#define Y_ENABLE_PIN                         114
37
+#define Z_ENABLE_PIN                         113
38
+#define E0_ENABLE_PIN                        112

+ 61
- 0
Marlin/src/pins/esp32/pins_PANDA_ZHU.h Переглянути файл

@@ -0,0 +1,61 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2021 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 <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+/**
25
+ * Panda ZHU pin assignments
26
+ */
27
+
28
+#define BOARD_INFO_NAME "Panda_ZHU"
29
+
30
+#include "pins_PANDA_common.h"
31
+
32
+//
33
+// Steppers
34
+//
35
+#define X_ENABLE_PIN                         128  // Shared with all steppers
36
+#define Y_ENABLE_PIN                X_ENABLE_PIN
37
+#define Z_ENABLE_PIN                X_ENABLE_PIN
38
+#define E0_ENABLE_PIN               X_ENABLE_PIN
39
+
40
+//#define X_CS_PIN                             0
41
+//#define Y_CS_PIN                            13
42
+//#define Z_CS_PIN                             5  // SS_PIN
43
+//#define E0_CS_PIN                           21
44
+
45
+#define E1_STEP_PIN                          115
46
+#define E1_DIR_PIN                           114
47
+#define E1_ENABLE_PIN               X_ENABLE_PIN
48
+
49
+#define E2_STEP_PIN                          112
50
+#define E2_DIR_PIN                           113
51
+#define E2_ENABLE_PIN               X_ENABLE_PIN
52
+
53
+#define E3_STEP_PIN                          110
54
+#define E3_DIR_PIN                           111
55
+#define E3_ENABLE_PIN               X_ENABLE_PIN
56
+
57
+#define E4_STEP_PIN                          121
58
+#define E4_DIR_PIN                           122
59
+#define E4_ENABLE_PIN               X_ENABLE_PIN
60
+
61
+#define HEATER_1_PIN                         123

+ 98
- 0
Marlin/src/pins/esp32/pins_PANDA_common.h Переглянути файл

@@ -0,0 +1,98 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2021 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 <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+/**
25
+ * Panda common pin assignments
26
+ */
27
+
28
+#include "env_validate.h"
29
+
30
+#define DEFAULT_MACHINE_NAME BOARD_INFO_NAME
31
+
32
+//
33
+// Servos
34
+//
35
+#define SERVO0_PIN                             0
36
+
37
+//
38
+// Limit Switches
39
+//
40
+#define X_STOP_PIN                             4
41
+#define Y_STOP_PIN                            35
42
+#define Z_STOP_PIN                            21
43
+
44
+//
45
+// Steppers
46
+//
47
+#define X_STEP_PIN                           101
48
+#define X_DIR_PIN                            100
49
+
50
+#define Y_STEP_PIN                           103
51
+#define Y_DIR_PIN                            102
52
+
53
+#define Z_STEP_PIN                           105
54
+#define Z_DIR_PIN                            104
55
+
56
+#define E0_STEP_PIN                          107
57
+#define E0_DIR_PIN                           106
58
+
59
+//
60
+// Temperature Sensors
61
+//
62
+#define TEMP_0_PIN                            39  // Analog Input
63
+#define TEMP_BED_PIN                          36  // Analog Input
64
+
65
+//
66
+// Heaters / Fans
67
+//
68
+#define HEATER_0_PIN                         108
69
+#define HEATER_BED_PIN                       109
70
+#define FAN_PIN                              118  // FAN0
71
+#define FAN1_PIN                             119  // FAN1
72
+
73
+#ifndef E0_AUTO_FAN_PIN
74
+  #define E0_AUTO_FAN_PIN                    120  // FAN2
75
+#endif
76
+
77
+//
78
+// SD card
79
+//
80
+#if ENABLED(SDSUPPORT)
81
+  #define SD_MOSI_PIN                         23
82
+  #define SD_MISO_PIN                         19
83
+  #define SD_SCK_PIN                          18
84
+  #define SDSS                                 5
85
+  #define SD_DETECT_PIN                        2
86
+#endif
87
+
88
+#if HAS_WIRED_LCD
89
+  #define BEEPER_PIN                         129
90
+  #define BTN_ENC                             12
91
+
92
+  #define BTN_EN1                             33
93
+  #define BTN_EN2                             32
94
+
95
+  #define LCD_PINS_RS                         27
96
+  #define LCD_PINS_ENABLE                     26
97
+  #define LCD_PINS_D4                         14
98
+#endif

+ 4
- 0
Marlin/src/pins/pins.h Переглянути файл

@@ -681,6 +681,10 @@
681 681
   #include "esp32/pins_E4D.h"                   // ESP32                                  env:esp32
682 682
 #elif MB(FYSETC_E4)
683 683
   #include "esp32/pins_FYSETC_E4.h"             // ESP32                                  env:FYSETC_E4
684
+#elif MB(PANDA_ZHU)
685
+  #include "esp32/pins_PANDA_ZHU.h"             // ESP32                                  env:PANDA
686
+#elif MB(PANDA_M4)
687
+  #include "esp32/pins_PANDA_M4.h"              // ESP32                                  env:PANDA
684 688
 
685 689
 //
686 690
 // Adafruit Grand Central M4 (SAMD51 ARM Cortex-M4)

+ 10
- 0
ini/esp32.ini Переглянути файл

@@ -27,3 +27,13 @@ monitor_speed = 250000
27 27
 platform               = espressif32@2.1.0
28 28
 extends                = env:esp32
29 29
 board_build.partitions = default_16MB.csv
30
+
31
+[env:PANDA]
32
+platform      = espressif32@2.1.0
33
+extends       = env:esp32
34
+build_flags   = ${env:esp32.build_flags} -DUSE_ESP32_EXIO -DUSE_ESP32_TASK_WDT
35
+lib_deps      = ${common.lib_deps}
36
+  SoftwareSerialEsp32
37
+board_build.partitions = Marlin/src/HAL/ESP32/esp32.csv
38
+upload_speed  = 115200
39
+monitor_speed = 115200

+ 3
- 3
ini/stm32f1-maple.ini Переглянути файл

@@ -65,8 +65,7 @@ build_flags       = ${common_stm32f1.build_flags}
65 65
 extra_scripts     = ${common_stm32f1.extra_scripts}
66 66
   pre:buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py
67 67
   buildroot/share/PlatformIO/scripts/STM32F103RC_MEEB_3DP.py
68
-lib_deps          = ${common.lib_deps}
69
-  SoftwareSerialM
68
+lib_deps          = ${common_stm32f1.lib_deps}
70 69
   USBComposite for STM32F1@0.91
71 70
 custom_marlin.NEOPIXEL_LED = Adafruit NeoPixel=https://github.com/ccccmagicboy/Adafruit_NeoPixel#meeb_3dp_use
72 71
 debug_tool        = stlink
@@ -377,7 +376,8 @@ extra_scripts             = ${common.extra_scripts}
377 376
   buildroot/share/PlatformIO/scripts/offset_and_rename.py
378 377
 build_flags               = ${common_stm32f1.build_flags}
379 378
   -D__STM32F1__=1 -DDEBUG_LEVEL=0 -DSS_TIMER=4 -DSERIAL_USB
380
-lib_deps                  = USBComposite for STM32F1@0.91
379
+lib_deps                  = ${common_stm32f1.lib_deps}
380
+  USBComposite for STM32F1@0.91
381 381
 lib_ignore                = Adafruit NeoPixel, SPI, SailfishLCD, SailfishRGB_LED, SlowSoftI2CMaster, TMCStepper
382 382
 
383 383
 [env:STM32F103RC_ZM3E2_USB_maple]

Завантаження…
Відмінити
Зберегти