Explorar el Código

Merge commit '8bd6b60a01' into look_at_201

Scott Lahteine hace 4 años
padre
commit
be642610ae
Se han modificado 100 ficheros con 1952 adiciones y 1384 borrados
  1. 3
    1
      .github/FUNDING.yml
  2. 103
    0
      .github/workflows/test-builds.yml
  3. 45
    19
      Marlin/Configuration.h
  4. 302
    72
      Marlin/Configuration_adv.h
  5. 22
    9
      Marlin/src/HAL/HAL_AVR/HAL.h
  6. 28
    1
      Marlin/src/HAL/HAL_AVR/MarlinSerial.cpp
  7. 20
    0
      Marlin/src/HAL/HAL_AVR/MarlinSerial.h
  8. 16
    0
      Marlin/src/HAL/HAL_AVR/endstop_interrupts.h
  9. 15
    4
      Marlin/src/HAL/HAL_AVR/fastio.h
  10. 4
    0
      Marlin/src/HAL/HAL_AVR/inc/SanityCheck.h
  11. 3
    5
      Marlin/src/HAL/HAL_AVR/pinsDebug.h
  12. 1
    1
      Marlin/src/HAL/HAL_AVR/watchdog.cpp
  13. 2
    2
      Marlin/src/HAL/HAL_DUE/HAL.cpp
  14. 25
    5
      Marlin/src/HAL/HAL_DUE/HAL.h
  15. 1
    1
      Marlin/src/HAL/HAL_DUE/HAL_SPI.cpp
  16. 1
    1
      Marlin/src/HAL/HAL_DUE/MarlinSerial.cpp
  17. 1
    1
      Marlin/src/HAL/HAL_DUE/dogm/u8g_com_HAL_DUE_shared_hw_spi.cpp
  18. 6
    0
      Marlin/src/HAL/HAL_DUE/endstop_interrupts.h
  19. 4
    0
      Marlin/src/HAL/HAL_DUE/inc/SanityCheck.h
  20. 1
    1
      Marlin/src/HAL/HAL_DUE/usb/uotghs_device_due.c
  21. 1
    1
      Marlin/src/HAL/HAL_DUE/watchdog.cpp
  22. 24
    13
      Marlin/src/HAL/HAL_ESP32/HAL.cpp
  23. 56
    5
      Marlin/src/HAL/HAL_ESP32/HAL.h
  24. 1
    1
      Marlin/src/HAL/HAL_ESP32/Servo.cpp
  25. 6
    0
      Marlin/src/HAL/HAL_ESP32/endstop_interrupts.h
  26. 1
    1
      Marlin/src/HAL/HAL_ESP32/i2s.cpp
  27. 8
    0
      Marlin/src/HAL/HAL_ESP32/inc/SanityCheck.h
  28. 2
    3
      Marlin/src/HAL/HAL_ESP32/ota.cpp
  29. 2
    2
      Marlin/src/HAL/HAL_ESP32/spiffs.cpp
  30. 1
    1
      Marlin/src/HAL/HAL_ESP32/timers.h
  31. 4
    5
      Marlin/src/HAL/HAL_ESP32/web.cpp
  32. 1
    1
      Marlin/src/HAL/HAL_LINUX/HAL.cpp
  33. 7
    7
      Marlin/src/HAL/HAL_LINUX/HAL.h
  34. 4
    0
      Marlin/src/HAL/HAL_LINUX/inc/SanityCheck.h
  35. 28
    11
      Marlin/src/HAL/HAL_LPC1768/HAL.h
  36. 13
    1
      Marlin/src/HAL/HAL_LPC1768/endstop_interrupts.h
  37. 4
    0
      Marlin/src/HAL/HAL_LPC1768/inc/SanityCheck.h
  38. 6
    40
      Marlin/src/HAL/HAL_LPC1768/include/digipot_mcp4451_I2C_routines.c
  39. 5
    15
      Marlin/src/HAL/HAL_LPC1768/include/digipot_mcp4451_I2C_routines.h
  40. 70
    0
      Marlin/src/HAL/HAL_LPC1768/include/i2c_util.c
  41. 56
    0
      Marlin/src/HAL/HAL_LPC1768/include/i2c_util.h
  42. 9
    62
      Marlin/src/HAL/HAL_LPC1768/u8g/LCD_I2C_routines.cpp
  43. 2
    2
      Marlin/src/HAL/HAL_LPC1768/u8g/LCD_I2C_routines.h
  44. 2
    2
      Marlin/src/HAL/HAL_LPC1768/u8g/LCD_delay.h
  45. 0
    2
      Marlin/src/HAL/HAL_LPC1768/u8g/u8g_com_HAL_LPC1768_ssd_hw_i2c.cpp
  46. 0
    254
      Marlin/src/HAL/HAL_LPC1768/u8g/u8g_com_HAL_LPC1768_ssd_sw_i2c.cpp under construction
  47. 12
    12
      Marlin/src/HAL/HAL_LPC1768/upload_extra_script.py
  48. 0
    1
      Marlin/src/HAL/HAL_LPC1768/watchdog.cpp
  49. 61
    11
      Marlin/src/HAL/HAL_SAMD51/HAL.cpp
  50. 32
    13
      Marlin/src/HAL/HAL_SAMD51/HAL.h
  51. 34
    11
      Marlin/src/HAL/HAL_SAMD51/endstop_interrupts.h
  52. 4
    0
      Marlin/src/HAL/HAL_SAMD51/inc/SanityCheck.h
  53. 23
    13
      Marlin/src/HAL/HAL_STM32/HAL.cpp
  54. 38
    16
      Marlin/src/HAL/HAL_STM32/HAL.h
  55. 173
    101
      Marlin/src/HAL/HAL_STM32/HAL_SPI.cpp
  56. 6
    0
      Marlin/src/HAL/HAL_STM32/endstop_interrupts.h
  57. 30
    7
      Marlin/src/HAL/HAL_STM32/timers.h
  58. 18
    0
      Marlin/src/HAL/HAL_STM32F1/HAL.cpp
  59. 37
    14
      Marlin/src/HAL/HAL_STM32F1/HAL.h
  60. 13
    2
      Marlin/src/HAL/HAL_STM32F1/dogm/u8g_com_stm32duino_fsmc.cpp
  61. 6
    0
      Marlin/src/HAL/HAL_STM32F1/endstop_interrupts.h
  62. 1
    1
      Marlin/src/HAL/HAL_STM32F1/inc/SanityCheck.h
  63. 37
    16
      Marlin/src/HAL/HAL_STM32_F4_F7/HAL.h
  64. 1
    1
      Marlin/src/HAL/HAL_STM32_F4_F7/STM32F7/TMC2660.cpp
  65. 6
    0
      Marlin/src/HAL/HAL_STM32_F4_F7/endstop_interrupts.h
  66. 4
    0
      Marlin/src/HAL/HAL_STM32_F4_F7/inc/SanityCheck.h
  67. 4
    0
      Marlin/src/HAL/HAL_TEENSY31_32/inc/SanityCheck.h
  68. 1
    1
      Marlin/src/HAL/HAL_TEENSY35_36/HAL.cpp
  69. 6
    0
      Marlin/src/HAL/HAL_TEENSY35_36/endstop_interrupts.h
  70. 4
    0
      Marlin/src/HAL/HAL_TEENSY35_36/inc/SanityCheck.h
  71. 1
    15
      Marlin/src/HAL/shared/Delay.h
  72. 44
    33
      Marlin/src/HAL/shared/HAL_spi_L6470.cpp
  73. 7
    0
      Marlin/src/HAL/shared/MarlinSerial.h
  74. 1
    1
      Marlin/src/HAL/shared/backtrace/backtrace.cpp
  75. 1
    1
      Marlin/src/HAL/shared/backtrace/unwinder.h
  76. 0
    381
      Marlin/src/Marlin.h
  77. 21
    12
      Marlin/src/MarlinCore.cpp
  78. 124
    0
      Marlin/src/MarlinCore.h
  79. 37
    28
      Marlin/src/core/boards.h
  80. 74
    42
      Marlin/src/core/drivers.h
  81. 13
    0
      Marlin/src/core/language.h
  82. 4
    6
      Marlin/src/core/serial.cpp
  83. 16
    1
      Marlin/src/core/serial.h
  84. 1
    5
      Marlin/src/core/types.h
  85. 39
    31
      Marlin/src/core/utility.cpp
  86. 10
    6
      Marlin/src/feature/Max7219_Debug_LEDs.cpp
  87. 1
    1
      Marlin/src/feature/babystep.cpp
  88. 8
    5
      Marlin/src/feature/bedlevel/bedlevel.cpp
  89. 1
    1
      Marlin/src/feature/bedlevel/ubl/ubl.cpp
  90. 8
    7
      Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp
  91. 1
    1
      Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp
  92. 5
    3
      Marlin/src/feature/caselight.cpp
  93. 21
    18
      Marlin/src/feature/controllerfan.cpp
  94. 1
    1
      Marlin/src/feature/dac/dac_dac084s085.cpp
  95. 1
    1
      Marlin/src/feature/dac/dac_mcp4728.cpp
  96. 18
    0
      Marlin/src/feature/dac/dac_mcp4728.h
  97. 1
    1
      Marlin/src/feature/dac/stepper_dac.cpp
  98. 5
    5
      Marlin/src/feature/digipot/digipot_mcp4451.cpp
  99. 21
    6
      Marlin/src/feature/joystick.cpp
  100. 0
    0
      Marlin/src/feature/pause.cpp

+ 3
- 1
.github/FUNDING.yml Ver fichero

@@ -1 +1,3 @@
1
-custom: http://www.thinkyhead.com/donate-to-marlin
1
+github: [thinkyhead]
2
+patreon: thinkyhead
3
+custom: ["http://www.thinkyhead.com/donate-to-marlin"]

+ 103
- 0
.github/workflows/test-builds.yml Ver fichero

@@ -0,0 +1,103 @@
1
+#
2
+# test-builds.yml
3
+# Do test builds to catch compile errors
4
+#
5
+
6
+name: CI
7
+
8
+on:
9
+  pull_request:
10
+    branches:
11
+    - bugfix-2.0.x
12
+    - dev-2.1.x
13
+    paths-ignore:
14
+    - config/**
15
+    - data/**
16
+    - docs/**
17
+    - '**/*.md'
18
+
19
+jobs:
20
+  test_builds:
21
+
22
+    runs-on: ubuntu-latest
23
+
24
+    strategy:
25
+      matrix:
26
+        test-platform:
27
+        # Base Environments
28
+
29
+        - DUE
30
+        - esp32
31
+        - linux_native
32
+        - megaatmega2560
33
+        - teensy31
34
+        - teensy35
35
+
36
+        # Extended AVR Environments
37
+
38
+        - FYSETC_F6_13
39
+        - megaatmega1280
40
+        - rambo
41
+        - sanguino_atmega1284p
42
+        - sanguino_atmega644p
43
+
44
+        # Extended STM32 Environments
45
+
46
+        - STM32F103RC_bigtree
47
+        - STM32F103RC_bigtree_USB
48
+        - STM32F103RE_bigtree
49
+        - STM32F103RE_bigtree_USB
50
+        - STM32F103RC_fysetc
51
+        - jgaurora_a5s_a1
52
+        - STM32F103VE_longer
53
+        - STM32F407VE_black
54
+        - BIGTREE_SKR_PRO
55
+        - mks_robin
56
+        - ARMED
57
+        - FYSETC_S6
58
+
59
+        # Put lengthy tests last
60
+
61
+        - LPC1768
62
+        - LPC1769
63
+
64
+        # STM32 with non-STM framework. both broken for now. they should use HAL_STM32 which is working.
65
+
66
+        #- STM32F4
67
+        #- STM32F7
68
+
69
+        # Non-working environment tests
70
+
71
+        #- BIGTREE_BTT002
72
+        #- at90usb1286_cdc
73
+        #- at90usb1286_dfu
74
+        #- STM32F103CB_malyan
75
+        #- mks_robin_lite
76
+        #- mks_robin_mini
77
+        #- mks_robin_nano
78
+        #- SAMD51_grandcentral_m4
79
+
80
+    steps:
81
+
82
+    - name: Select Python 3.7
83
+      uses: actions/setup-python@v1
84
+      with:
85
+        python-version: '3.7' # Version range or exact version of a Python version to use, using semvers version range syntax.
86
+        architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
87
+
88
+    - name: Install PlatformIO
89
+      run: |
90
+        pip install -U https://github.com/platformio/platformio-core/archive/master.zip
91
+        platformio update
92
+
93
+    - name: Check out the PR
94
+      uses: actions/checkout@v2
95
+
96
+    - name: Run ${{ matrix.test-platform }} Tests
97
+      run: |
98
+        # Inline tests script
99
+        [[ "$GITHUB_REPOSITORY" == "MarlinFirmware/Marlin" ]] || exit 0
100
+        chmod +x buildroot/bin/*
101
+        chmod +x buildroot/share/tests/*
102
+        export PATH=./buildroot/bin/:./buildroot/share/tests/:${PATH}
103
+        run_tests . ${{ matrix.test-platform }}

+ 45
- 19
Marlin/Configuration.h Ver fichero

@@ -143,7 +143,7 @@
143 143
 // @section extruder
144 144
 
145 145
 // This defines the number of extruders
146
-// :[1, 2, 3, 4, 5, 6]
146
+// :[1, 2, 3, 4, 5, 6, 7, 8]
147 147
 #define EXTRUDERS 1
148 148
 
149 149
 // Generally expected filament diameter (1.75, 2.85, 3.0, ...). Used for Volumetric, Filament Width Sensor, etc.
@@ -360,7 +360,8 @@
360 360
  *    -1 : thermocouple with AD595
361 361
  *     0 : not used
362 362
  *     1 : 100k thermistor - best choice for EPCOS 100k (4.7k pullup)
363
- *   331 : (3.3V scaled thermistor 1 table)
363
+ *   331 : (3.3V scaled thermistor 1 table for MEGA)
364
+ *   332 : (3.3V scaled thermistor 1 table for DUE)
364 365
  *     2 : 200k thermistor - ATC Semitec 204GT-2 (4.7k pullup)
365 366
  *     3 : Mendel-parts thermistor (4.7k pullup)
366 367
  *     4 : 10k thermistor !! do not use it for a hotend. It gives bad resolution at high temp. !!
@@ -411,7 +412,10 @@
411 412
 #define TEMP_SENSOR_3 0
412 413
 #define TEMP_SENSOR_4 0
413 414
 #define TEMP_SENSOR_5 0
415
+#define TEMP_SENSOR_6 0
416
+#define TEMP_SENSOR_7 0
414 417
 #define TEMP_SENSOR_BED 0
418
+#define TEMP_SENSOR_PROBE 0
415 419
 #define TEMP_SENSOR_CHAMBER 0
416 420
 
417 421
 // Dummy thermistor constant temperature readings, for use with 998 and 999
@@ -439,6 +443,8 @@
439 443
 #define HEATER_3_MINTEMP   5
440 444
 #define HEATER_4_MINTEMP   5
441 445
 #define HEATER_5_MINTEMP   5
446
+#define HEATER_6_MINTEMP   5
447
+#define HEATER_7_MINTEMP   5
442 448
 #define BED_MINTEMP        5
443 449
 
444 450
 // Above this temperature the heater will be switched off.
@@ -450,6 +456,8 @@
450 456
 #define HEATER_3_MAXTEMP 275
451 457
 #define HEATER_4_MAXTEMP 275
452 458
 #define HEATER_5_MAXTEMP 275
459
+#define HEATER_6_MAXTEMP 275
460
+#define HEATER_7_MAXTEMP 275
453 461
 #define BED_MAXTEMP      150
454 462
 
455 463
 //===========================================================================
@@ -654,12 +662,13 @@
654 662
  *
655 663
  * A4988 is assumed for unspecified drivers.
656 664
  *
657
- * Options: A4988, A5984, DRV8825, LV8729, L6470, TB6560, TB6600, TMC2100,
665
+ * Options: A4988, A5984, DRV8825, LV8729, L6470, L6474, POWERSTEP01,
666
+ *          TB6560, TB6600, TMC2100,
658 667
  *          TMC2130, TMC2130_STANDALONE, TMC2160, TMC2160_STANDALONE,
659 668
  *          TMC2208, TMC2208_STANDALONE, TMC2209, TMC2209_STANDALONE,
660 669
  *          TMC26X,  TMC26X_STANDALONE,  TMC2660, TMC2660_STANDALONE,
661 670
  *          TMC5130, TMC5130_STANDALONE, TMC5160, TMC5160_STANDALONE
662
- * :['A4988', 'A5984', 'DRV8825', 'LV8729', 'L6470', 'TB6560', 'TB6600', 'TMC2100', 'TMC2130', 'TMC2130_STANDALONE', 'TMC2160', 'TMC2160_STANDALONE', 'TMC2208', 'TMC2208_STANDALONE', 'TMC2209', 'TMC2209_STANDALONE', 'TMC26X', 'TMC26X_STANDALONE', 'TMC2660', 'TMC2660_STANDALONE', 'TMC5130', 'TMC5130_STANDALONE', 'TMC5160', 'TMC5160_STANDALONE']
671
+ * :['A4988', 'A5984', 'DRV8825', 'LV8729', 'L6470', 'L6474', 'POWERSTEP01', 'TB6560', 'TB6600', 'TMC2100', 'TMC2130', 'TMC2130_STANDALONE', 'TMC2160', 'TMC2160_STANDALONE', 'TMC2208', 'TMC2208_STANDALONE', 'TMC2209', 'TMC2209_STANDALONE', 'TMC26X', 'TMC26X_STANDALONE', 'TMC2660', 'TMC2660_STANDALONE', 'TMC5130', 'TMC5130_STANDALONE', 'TMC5160', 'TMC5160_STANDALONE']
663 672
  */
664 673
 //#define X_DRIVER_TYPE  A4988
665 674
 //#define Y_DRIVER_TYPE  A4988
@@ -668,12 +677,15 @@
668 677
 //#define Y2_DRIVER_TYPE A4988
669 678
 //#define Z2_DRIVER_TYPE A4988
670 679
 //#define Z3_DRIVER_TYPE A4988
680
+//#define Z4_DRIVER_TYPE A4988
671 681
 //#define E0_DRIVER_TYPE A4988
672 682
 //#define E1_DRIVER_TYPE A4988
673 683
 //#define E2_DRIVER_TYPE A4988
674 684
 //#define E3_DRIVER_TYPE A4988
675 685
 //#define E4_DRIVER_TYPE A4988
676 686
 //#define E5_DRIVER_TYPE A4988
687
+//#define E6_DRIVER_TYPE A4988
688
+//#define E7_DRIVER_TYPE A4988
677 689
 
678 690
 // Enable this feature if all enabled endstop pins are interrupt-capable.
679 691
 // This will remove the need to poll the interrupt pins, saving many CPU cycles.
@@ -903,6 +915,13 @@
903 915
   #define Z_PROBE_RETRACT_X X_MAX_POS
904 916
 #endif
905 917
 
918
+// Duet Smart Effector (for delta printers) - https://bit.ly/2ul5U7J
919
+// When the pin is defined you can use M672 to set/reset the probe sensivity.
920
+//#define DUET_SMART_EFFECTOR
921
+#if ENABLED(DUET_SMART_EFFECTOR)
922
+  #define SMART_EFFECTOR_MOD_PIN  -1  // Connect a GPIO pin to the Smart Effector MOD pin
923
+#endif
924
+
906 925
 //
907 926
 // For Z_PROBE_ALLEN_KEY see the Delta example configurations.
908 927
 //
@@ -929,7 +948,8 @@
929 948
  */
930 949
 #define NOZZLE_TO_PROBE_OFFSET { 10, 10, 0 }
931 950
 
932
-// Certain types of probes need to stay away from edges
951
+// Most probes should stay away from the edges of the bed, but
952
+// with NOZZLE_AS_PROBE this can be negative for a wider probing area.
933 953
 #define MIN_PROBE_EDGE 10
934 954
 
935 955
 // X and Y axis travel speed (mm/m) between probes
@@ -1039,6 +1059,8 @@
1039 1059
 #define INVERT_E3_DIR false
1040 1060
 #define INVERT_E4_DIR false
1041 1061
 #define INVERT_E5_DIR false
1062
+#define INVERT_E6_DIR false
1063
+#define INVERT_E7_DIR false
1042 1064
 
1043 1065
 // @section homing
1044 1066
 
@@ -1425,11 +1447,6 @@
1425 1447
 #define BUSY_WHILE_HEATING            // Some hosts require "busy" messages even during heating
1426 1448
 
1427 1449
 //
1428
-// M100 Free Memory Watcher
1429
-//
1430
-//#define M100_FREE_MEMORY_WATCHER    // Add M100 (Free Memory Watcher) to debug memory usage
1431
-
1432
-//
1433 1450
 // G20/G21 Inch mode support
1434 1451
 //
1435 1452
 //#define INCH_MODE_SUPPORT
@@ -1519,9 +1536,10 @@
1519 1536
   // Default number of triangles
1520 1537
   #define NOZZLE_CLEAN_TRIANGLES  3
1521 1538
 
1522
-  // Specify positions as { X, Y, Z }
1523
-  #define NOZZLE_CLEAN_START_POINT {  30, 30, (Z_MIN_POS + 1) }
1524
-  #define NOZZLE_CLEAN_END_POINT   { 100, 60, (Z_MIN_POS + 1) }
1539
+  // Specify positions for each tool as { { X, Y, Z }, { X, Y, Z } }
1540
+  // Dual hotend system may use { {  -20, (Y_BED_SIZE / 2), (Z_MIN_POS + 1) },  {  420, (Y_BED_SIZE / 2), (Z_MIN_POS + 1) }}
1541
+  #define NOZZLE_CLEAN_START_POINT { {  30, 30, (Z_MIN_POS + 1) } }
1542
+  #define NOZZLE_CLEAN_END_POINT   { { 100, 60, (Z_MIN_POS + 1) } }
1525 1543
 
1526 1544
   // Circular pattern radius
1527 1545
   #define NOZZLE_CLEAN_CIRCLE_RADIUS 6.5
@@ -1942,10 +1960,11 @@
1942 1960
 // FYSETC variant of the MINI12864 graphic controller with SD support
1943 1961
 // https://wiki.fysetc.com/Mini12864_Panel/
1944 1962
 //
1945
-//#define FYSETC_MINI_12864_X_X  // Type C/D/E/F. No tunable RGB Backlight by default
1946
-//#define FYSETC_MINI_12864_1_2  // Type C/D/E/F. Simple RGB Backlight (always on)
1947
-//#define FYSETC_MINI_12864_2_0  // Type A/B. Discreet RGB Backlight
1948
-//#define FYSETC_MINI_12864_2_1  // Type A/B. Neopixel RGB Backlight
1963
+//#define FYSETC_MINI_12864_X_X    // Type C/D/E/F. No tunable RGB Backlight by default
1964
+//#define FYSETC_MINI_12864_1_2    // Type C/D/E/F. Simple RGB Backlight (always on)
1965
+//#define FYSETC_MINI_12864_2_0    // Type A/B. Discreet RGB Backlight
1966
+//#define FYSETC_MINI_12864_2_1    // Type A/B. Neopixel RGB Backlight
1967
+//#define FYSETC_GENERIC_12864_1_1 // Larger display with basic ON/OFF backlight.
1949 1968
 
1950 1969
 //
1951 1970
 // Factory display for Creality CR-10
@@ -1957,6 +1976,11 @@
1957 1976
 //#define CR10_STOCKDISPLAY
1958 1977
 
1959 1978
 //
1979
+// Ender-2 OEM display, a variant of the MKS_MINI_12864
1980
+//
1981
+//#define ENDER2_STOCKDISPLAY
1982
+
1983
+//
1960 1984
 // ANET and Tronxy Graphical Controller
1961 1985
 //
1962 1986
 // Anet 128x64 full graphics lcd with rotary encoder as used on Anet A6
@@ -2024,9 +2048,11 @@
2024 2048
 //=============================================================================
2025 2049
 
2026 2050
 //
2027
-// DGUS Touch Display with DWIN OS
2051
+// DGUS Touch Display with DWIN OS. (Choose one.)
2028 2052
 //
2029
-//#define DGUS_LCD
2053
+//#define DGUS_LCD_UI_ORIGIN
2054
+//#define DGUS_LCD_UI_FYSETC
2055
+//#define DGUS_LCD_UI_HIPRECY
2030 2056
 
2031 2057
 //
2032 2058
 // Touch-screen LCD for Malyan M200 printers

+ 302
- 72
Marlin/Configuration_adv.h Ver fichero

@@ -78,6 +78,18 @@
78 78
   #define HOTEND5_BETA                 3950    // Beta value
79 79
 #endif
80 80
 
81
+#if TEMP_SENSOR_6 == 1000
82
+  #define HOTEND6_PULLUP_RESISTOR_OHMS 4700    // Pullup resistor
83
+  #define HOTEND6_RESISTANCE_25C_OHMS  100000  // Resistance at 25C
84
+  #define HOTEND6_BETA                 3950    // Beta value
85
+#endif
86
+
87
+#if TEMP_SENSOR_7 == 1000
88
+  #define HOTEND7_PULLUP_RESISTOR_OHMS 4700    // Pullup resistor
89
+  #define HOTEND7_RESISTANCE_25C_OHMS  100000  // Resistance at 25C
90
+  #define HOTEND7_BETA                 3950    // Beta value
91
+#endif
92
+
81 93
 #if TEMP_SENSOR_BED == 1000
82 94
   #define BED_PULLUP_RESISTOR_OHMS     4700    // Pullup resistor
83 95
   #define BED_RESISTANCE_25C_OHMS      100000  // Resistance at 25C
@@ -165,28 +177,28 @@
165 177
  * Thermal Protection parameters for the bed are just as above for hotends.
166 178
  */
167 179
 #if ENABLED(THERMAL_PROTECTION_BED)
168
-  #define THERMAL_PROTECTION_BED_PERIOD 20    // Seconds
169
-  #define THERMAL_PROTECTION_BED_HYSTERESIS 2 // Degrees Celsius
180
+  #define THERMAL_PROTECTION_BED_PERIOD        20 // Seconds
181
+  #define THERMAL_PROTECTION_BED_HYSTERESIS     2 // Degrees Celsius
170 182
 
171 183
   /**
172 184
    * As described above, except for the bed (M140/M190/M303).
173 185
    */
174
-  #define WATCH_BED_TEMP_PERIOD 60                // Seconds
175
-  #define WATCH_BED_TEMP_INCREASE 2               // Degrees Celsius
186
+  #define WATCH_BED_TEMP_PERIOD                60 // Seconds
187
+  #define WATCH_BED_TEMP_INCREASE               2 // Degrees Celsius
176 188
 #endif
177 189
 
178 190
 /**
179 191
  * Thermal Protection parameters for the heated chamber.
180 192
  */
181 193
 #if ENABLED(THERMAL_PROTECTION_CHAMBER)
182
-  #define THERMAL_PROTECTION_CHAMBER_PERIOD 20    // Seconds
194
+  #define THERMAL_PROTECTION_CHAMBER_PERIOD    20 // Seconds
183 195
   #define THERMAL_PROTECTION_CHAMBER_HYSTERESIS 2 // Degrees Celsius
184 196
 
185 197
   /**
186 198
    * Heated chamber watch settings (M141/M191).
187 199
    */
188
-  #define WATCH_CHAMBER_TEMP_PERIOD 60            // Seconds
189
-  #define WATCH_CHAMBER_TEMP_INCREASE 2           // Degrees Celsius
200
+  #define WATCH_CHAMBER_TEMP_PERIOD            60 // Seconds
201
+  #define WATCH_CHAMBER_TEMP_INCREASE           2 // Degrees Celsius
190 202
 #endif
191 203
 
192 204
 #if ENABLED(PIDTEMP)
@@ -368,7 +380,7 @@
368 380
  * FAST_PWM_FAN_FREQUENCY [undefined by default]
369 381
  *   Set this to your desired frequency.
370 382
  *   If left undefined this defaults to F = F_CPU/(2*255*1)
371
- *   ie F = 31.4 Khz on 16 MHz microcontrollers or F = 39.2 KHz on 20 MHz microcontrollers
383
+ *   i.e., F = 31.4kHz on 16MHz microcontrollers or F = 39.2kHz on 20MHz microcontrollers.
372 384
  *   These defaults are the same as with the old FAST_PWM_FAN implementation - no migration is required
373 385
  *   NOTE: Setting very low frequencies (< 10 Hz) may result in unexpected timer behavior.
374 386
  *
@@ -479,7 +491,7 @@
479 491
   //#define X_DUAL_ENDSTOPS
480 492
   #if ENABLED(X_DUAL_ENDSTOPS)
481 493
     #define X2_USE_ENDSTOP _XMAX_
482
-    #define X_DUAL_ENDSTOPS_ADJUSTMENT  0
494
+    #define X2_ENDSTOP_ADJUSTMENT  0
483 495
   #endif
484 496
 #endif
485 497
 
@@ -489,27 +501,28 @@
489 501
   //#define Y_DUAL_ENDSTOPS
490 502
   #if ENABLED(Y_DUAL_ENDSTOPS)
491 503
     #define Y2_USE_ENDSTOP _YMAX_
492
-    #define Y_DUAL_ENDSTOPS_ADJUSTMENT  0
504
+    #define Y2_ENDSTOP_ADJUSTMENT  0
493 505
   #endif
494 506
 #endif
495 507
 
496
-//#define Z_DUAL_STEPPER_DRIVERS
497
-#if ENABLED(Z_DUAL_STEPPER_DRIVERS)
498
-  //#define Z_DUAL_ENDSTOPS
499
-  #if ENABLED(Z_DUAL_ENDSTOPS)
500
-    #define Z2_USE_ENDSTOP _XMAX_
501
-    #define Z_DUAL_ENDSTOPS_ADJUSTMENT  0
502
-  #endif
503
-#endif
504
-
505
-//#define Z_TRIPLE_STEPPER_DRIVERS
506
-#if ENABLED(Z_TRIPLE_STEPPER_DRIVERS)
507
-  //#define Z_TRIPLE_ENDSTOPS
508
-  #if ENABLED(Z_TRIPLE_ENDSTOPS)
509
-    #define Z2_USE_ENDSTOP _XMAX_
510
-    #define Z3_USE_ENDSTOP _YMAX_
511
-    #define Z_TRIPLE_ENDSTOPS_ADJUSTMENT2  0
512
-    #define Z_TRIPLE_ENDSTOPS_ADJUSTMENT3  0
508
+//
509
+// For Z set the number of stepper drivers
510
+//
511
+#define NUM_Z_STEPPER_DRIVERS 1   // (1-4) Z options change based on how many
512
+
513
+#if NUM_Z_STEPPER_DRIVERS > 1
514
+  //#define Z_MULTI_ENDSTOPS
515
+  #if ENABLED(Z_MULTI_ENDSTOPS)
516
+    #define Z2_USE_ENDSTOP          _XMAX_
517
+    #define Z2_ENDSTOP_ADJUSTMENT   0
518
+    #if NUM_Z_STEPPER_DRIVERS >= 3
519
+      #define Z3_USE_ENDSTOP        _YMAX_
520
+      #define Z3_ENDSTOP_ADJUSTMENT 0
521
+    #endif
522
+    #if NUM_Z_STEPPER_DRIVERS >= 4
523
+      #define Z4_USE_ENDSTOP        _ZMAX_
524
+      #define Z4_ENDSTOP_ADJUSTMENT 0
525
+    #endif
513 526
   #endif
514 527
 #endif
515 528
 
@@ -1244,6 +1257,44 @@
1244 1257
 #endif // HAS_GRAPHICAL_LCD
1245 1258
 
1246 1259
 //
1260
+// Additional options for DGUS / DWIN displays
1261
+//
1262
+#if HAS_DGUS_LCD
1263
+  #define DGUS_SERIAL_PORT 2
1264
+  #define DGUS_BAUDRATE 115200
1265
+
1266
+  #define DGUS_RX_BUFFER_SIZE 128
1267
+  #define DGUS_TX_BUFFER_SIZE 48
1268
+  //#define DGUS_SERIAL_STATS_RX_BUFFER_OVERRUNS  // Fix Rx overrun situation (Currently only for AVR)
1269
+
1270
+  #define DGUS_UPDATE_INTERVAL_MS  500    // (ms) Interval between automatic screen updates
1271
+  #define BOOTSCREEN_TIMEOUT      3000    // (ms) Duration to display the boot screen
1272
+
1273
+  #if EITHER(DGUS_LCD_UI_FYSETC, DGUS_LCD_UI_HIPRECY)
1274
+    #define DGUS_PRINT_FILENAME           // Display the filename during printing
1275
+    #define DGUS_PREHEAT_UI               // Display a preheat screen during heatup
1276
+
1277
+    #if ENABLED(DGUS_LCD_UI_FYSETC)
1278
+      //#define DUGS_UI_MOVE_DIS_OPTION   // Disabled by default for UI_FYSETC
1279
+    #else
1280
+      #define DUGS_UI_MOVE_DIS_OPTION     // Enabled by default for UI_HIPRECY
1281
+    #endif
1282
+
1283
+    #define DGUS_FILAMENT_LOADUNLOAD
1284
+    #if ENABLED(DGUS_FILAMENT_LOADUNLOAD)
1285
+      #define DGUS_FILAMENT_PURGE_LENGTH 10
1286
+      #define DGUS_FILAMENT_LOAD_LENGTH_PER_TIME 0.5 // (mm) Adjust in proportion to DGUS_UPDATE_INTERVAL_MS
1287
+    #endif
1288
+
1289
+    #define DGUS_UI_WAITING               // Show a "waiting" screen between some screens
1290
+    #if ENABLED(DGUS_UI_WAITING)
1291
+      #define DGUS_UI_WAITING_STATUS 10
1292
+      #define DGUS_UI_WAITING_STATUS_PERIOD 8 // Increase to slower waiting status looping
1293
+    #endif
1294
+  #endif
1295
+#endif // HAS_DGUS_LCD
1296
+
1297
+//
1247 1298
 // Touch UI for the FTDI Embedded Video Engine (EVE)
1248 1299
 //
1249 1300
 #if ENABLED(TOUCH_UI_FTDI_EVE)
@@ -1341,6 +1392,13 @@
1341 1392
   //#define TFT_BTOKMENU_COLOR 0x145F // 00010 100010 11111 Cyan
1342 1393
 #endif
1343 1394
 
1395
+//
1396
+// ADC Button Debounce
1397
+//
1398
+#if HAS_ADC_BUTTONS
1399
+  #define ADC_BUTTON_DEBOUNCE_DELAY 16  // (ms) Increase if buttons bounce or repeat too fast
1400
+#endif
1401
+
1344 1402
 // @section safety
1345 1403
 
1346 1404
 /**
@@ -1438,7 +1496,8 @@
1438 1496
  * Override MIN_PROBE_EDGE for each side of the build plate
1439 1497
  * Useful to get probe points to exact positions on targets or
1440 1498
  * to allow leveling to avoid plate clamps on only specific
1441
- * sides of the bed.
1499
+ * sides of the bed. With NOZZLE_AS_PROBE negative values are
1500
+ * allowed, to permit probing outside the bed.
1442 1501
  *
1443 1502
  * If you are replacing the prior *_PROBE_BED_POSITION options,
1444 1503
  * LEFT and FRONT values in most cases will map directly over
@@ -1483,18 +1542,57 @@
1483 1542
 
1484 1543
 #endif
1485 1544
 
1545
+/**
1546
+ * Thermal Probe Compensation
1547
+ * Probe measurements are adjusted to compensate for temperature distortion.
1548
+ * Use G76 to calibrate this feature. Use M871 to set values manually.
1549
+ * For a more detailed explanation of the process see G76_M871.cpp.
1550
+ */
1551
+#if HAS_BED_PROBE && TEMP_SENSOR_PROBE && TEMP_SENSOR_BED
1552
+  // Enable thermal first layer compensation using bed and probe temperatures
1553
+  #define PROBE_TEMP_COMPENSATION
1554
+
1555
+  // Add additional compensation depending on hotend temperature
1556
+  // Note: this values cannot be calibrated and have to be set manually
1557
+  #ifdef PROBE_TEMP_COMPENSATION
1558
+    // Max temperature that can be reached by heated bed.
1559
+    // This is required only for the calibration process.
1560
+    #define PTC_MAX_BED_TEMP 110
1561
+
1562
+    // Park position to wait for probe cooldown
1563
+    #define PTC_PARK_POS_X 0.0F
1564
+    #define PTC_PARK_POS_Y 0.0F
1565
+    #define PTC_PARK_POS_Z 100.0F
1566
+
1567
+    // Probe position to probe and wait for probe to reach target temperature
1568
+    #define PTC_PROBE_POS_X  90.0F
1569
+    #define PTC_PROBE_POS_Y 100.0F
1570
+
1571
+    // Enable additional compensation using hotend temperature
1572
+    // Note: this values cannot be calibrated automatically but have to be set manually
1573
+    //#define USE_TEMP_EXT_COMPENSATION
1574
+  #endif
1575
+#endif
1576
+
1486 1577
 // @section extras
1487 1578
 
1488 1579
 //
1580
+// G60/G61 Position Save and Return
1581
+//
1582
+//#define SAVED_POSITIONS 1         // Each saved position slot costs 12 bytes
1583
+
1584
+//
1489 1585
 // G2/G3 Arc Support
1490 1586
 //
1491
-#define ARC_SUPPORT               // Disable this feature to save ~3226 bytes
1587
+#define ARC_SUPPORT                 // Disable this feature to save ~3226 bytes
1492 1588
 #if ENABLED(ARC_SUPPORT)
1493
-  #define MM_PER_ARC_SEGMENT  1   // Length of each arc segment
1494
-  #define MIN_ARC_SEGMENTS   24   // Minimum number of segments in a complete circle
1495
-  #define N_ARC_CORRECTION   25   // Number of interpolated segments between corrections
1496
-  //#define ARC_P_CIRCLES         // Enable the 'P' parameter to specify complete circles
1497
-  //#define CNC_WORKSPACE_PLANES  // Allow G2/G3 to operate in XY, ZX, or YZ planes
1589
+  #define MM_PER_ARC_SEGMENT      1 // (mm) Length (or minimum length) of each arc segment
1590
+  //#define ARC_SEGMENTS_PER_R    1 // Max segment length, MM_PER = Min
1591
+  #define MIN_ARC_SEGMENTS       24 // Minimum number of segments in a complete circle
1592
+  //#define ARC_SEGMENTS_PER_SEC 50 // Use feedrate to choose segment length (with MM_PER_ARC_SEGMENT as the minimum)
1593
+  #define N_ARC_CORRECTION       25 // Number of interpolated segments between corrections
1594
+  //#define ARC_P_CIRCLES           // Enable the 'P' parameter to specify complete circles
1595
+  //#define CNC_WORKSPACE_PLANES    // Allow G2/G3 to operate in XY, ZX, or YZ planes
1498 1596
 #endif
1499 1597
 
1500 1598
 // Support for G5 with XYZE destination and IJPQ offsets. Requires ~2666 bytes.
@@ -1691,6 +1789,9 @@
1691 1789
   // Z raise distance for tool-change, as needed for some extruders
1692 1790
   #define TOOLCHANGE_ZRAISE     2  // (mm)
1693 1791
   //#define TOOLCHANGE_NO_RETURN   // Never return to the previous position on tool-change
1792
+  #if ENABLED(TOOLCHANGE_NO_RETURN)
1793
+    //#define EVENT_GCODE_AFTER_TOOLCHANGE "G12X"   // G-code to run after tool-change is complete
1794
+  #endif
1694 1795
 
1695 1796
   // Retract and prime filament on tool-change
1696 1797
   //#define TOOLCHANGE_FILAMENT_SWAP
@@ -1754,6 +1855,7 @@
1754 1855
   #define FILAMENT_UNLOAD_PURGE_RETRACT       13  // (mm) Unload initial retract length.
1755 1856
   #define FILAMENT_UNLOAD_PURGE_DELAY       5000  // (ms) Delay for the filament to cool after retract.
1756 1857
   #define FILAMENT_UNLOAD_PURGE_LENGTH         8  // (mm) An unretract is done, then this length is purged.
1858
+  #define FILAMENT_UNLOAD_PURGE_FEEDRATE      25  // (mm/s) feedrate to purge before unload
1757 1859
 
1758 1860
   #define PAUSE_PARK_NOZZLE_TIMEOUT           45  // (seconds) Time limit before the nozzle is turned off for safety.
1759 1861
   #define FILAMENT_CHANGE_ALERT_BEEPS         10  // Number of alert beeps to play when a response is needed.
@@ -1818,6 +1920,12 @@
1818 1920
     #define Z3_MICROSTEPS       16
1819 1921
   #endif
1820 1922
 
1923
+  #if AXIS_DRIVER_TYPE_Z4(TMC26X)
1924
+    #define Z4_MAX_CURRENT    1000
1925
+    #define Z4_SENSE_RESISTOR   91
1926
+    #define Z4_MICROSTEPS       16
1927
+  #endif
1928
+
1821 1929
   #if AXIS_DRIVER_TYPE_E0(TMC26X)
1822 1930
     #define E0_MAX_CURRENT    1000
1823 1931
     #define E0_SENSE_RESISTOR   91
@@ -1854,6 +1962,18 @@
1854 1962
     #define E5_MICROSTEPS       16
1855 1963
   #endif
1856 1964
 
1965
+  #if AXIS_DRIVER_TYPE_E6(TMC26X)
1966
+    #define E6_MAX_CURRENT    1000
1967
+    #define E6_SENSE_RESISTOR   91
1968
+    #define E6_MICROSTEPS       16
1969
+  #endif
1970
+
1971
+  #if AXIS_DRIVER_TYPE_E7(TMC26X)
1972
+    #define E7_MAX_CURRENT    1000
1973
+    #define E7_SENSE_RESISTOR   91
1974
+    #define E7_MICROSTEPS       16
1975
+  #endif
1976
+
1857 1977
 #endif // TMC26X
1858 1978
 
1859 1979
 // @section tmc_smart
@@ -1935,6 +2055,14 @@
1935 2055
     #define Z3_CHAIN_POS     -1
1936 2056
   #endif
1937 2057
 
2058
+  #if AXIS_IS_TMC(Z4)
2059
+    #define Z4_CURRENT      800
2060
+    #define Z4_CURRENT_HOME Z4_CURRENT
2061
+    #define Z4_MICROSTEPS    16
2062
+    #define Z4_RSENSE         0.11
2063
+    #define Z4_CHAIN_POS     -1
2064
+  #endif
2065
+
1938 2066
   #if AXIS_IS_TMC(E0)
1939 2067
     #define E0_CURRENT      800
1940 2068
     #define E0_MICROSTEPS    16
@@ -1977,6 +2105,20 @@
1977 2105
     #define E5_CHAIN_POS     -1
1978 2106
   #endif
1979 2107
 
2108
+  #if AXIS_IS_TMC(E6)
2109
+    #define E6_CURRENT      800
2110
+    #define E6_MICROSTEPS    16
2111
+    #define E6_RSENSE         0.11
2112
+    #define E6_CHAIN_POS     -1
2113
+  #endif
2114
+
2115
+  #if AXIS_IS_TMC(E7)
2116
+    #define E7_CURRENT      800
2117
+    #define E7_MICROSTEPS    16
2118
+    #define E7_RSENSE         0.11
2119
+    #define E7_CHAIN_POS     -1
2120
+  #endif
2121
+
1980 2122
   /**
1981 2123
    * Override default SPI pins for TMC2130, TMC2160, TMC2660, TMC5130 and TMC5160 drivers here.
1982 2124
    * The default pins can be found in your board's pins file.
@@ -1994,6 +2136,8 @@
1994 2136
   //#define E3_CS_PIN         -1
1995 2137
   //#define E4_CS_PIN         -1
1996 2138
   //#define E5_CS_PIN         -1
2139
+  //#define E6_CS_PIN         -1
2140
+  //#define E7_CS_PIN         -1
1997 2141
 
1998 2142
   /**
1999 2143
    * Software option for SPI driven drivers (TMC2130, TMC2160, TMC2660, TMC5130 and TMC5160).
@@ -2024,12 +2168,15 @@
2024 2168
   #define Y2_SLAVE_ADDRESS 0
2025 2169
   #define Z2_SLAVE_ADDRESS 0
2026 2170
   #define Z3_SLAVE_ADDRESS 0
2171
+  #define Z4_SLAVE_ADDRESS 0
2027 2172
   #define E0_SLAVE_ADDRESS 0
2028 2173
   #define E1_SLAVE_ADDRESS 0
2029 2174
   #define E2_SLAVE_ADDRESS 0
2030 2175
   #define E3_SLAVE_ADDRESS 0
2031 2176
   #define E4_SLAVE_ADDRESS 0
2032 2177
   #define E5_SLAVE_ADDRESS 0
2178
+  #define E6_SLAVE_ADDRESS 0
2179
+  #define E7_SLAVE_ADDRESS 0
2033 2180
 
2034 2181
   /**
2035 2182
    * Software enable
@@ -2099,12 +2246,15 @@
2099 2246
   #define Z_HYBRID_THRESHOLD       3
2100 2247
   #define Z2_HYBRID_THRESHOLD      3
2101 2248
   #define Z3_HYBRID_THRESHOLD      3
2249
+  #define Z4_HYBRID_THRESHOLD      3
2102 2250
   #define E0_HYBRID_THRESHOLD     30
2103 2251
   #define E1_HYBRID_THRESHOLD     30
2104 2252
   #define E2_HYBRID_THRESHOLD     30
2105 2253
   #define E3_HYBRID_THRESHOLD     30
2106 2254
   #define E4_HYBRID_THRESHOLD     30
2107 2255
   #define E5_HYBRID_THRESHOLD     30
2256
+  #define E6_HYBRID_THRESHOLD     30
2257
+  #define E7_HYBRID_THRESHOLD     30
2108 2258
 
2109 2259
   /**
2110 2260
    * Use StallGuard2 to home / probe X, Y, Z.
@@ -2176,12 +2326,12 @@
2176 2326
 
2177 2327
 #endif // HAS_TRINAMIC
2178 2328
 
2179
-// @section L6470
2329
+// @section L64XX
2180 2330
 
2181 2331
 /**
2182
- * L6470 Stepper Driver options
2332
+ * L64XX Stepper Driver options
2183 2333
  *
2184
- * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver.
2334
+ * Arduino-L6470 library (0.8.0 or higher) is required.
2185 2335
  * https://github.com/ameyer/Arduino-L6470
2186 2336
  *
2187 2337
  * Requires the following to be defined in your pins_YOUR_BOARD file
@@ -2189,114 +2339,160 @@
2189 2339
  *     L6470_CHAIN_MISO_PIN
2190 2340
  *     L6470_CHAIN_MOSI_PIN
2191 2341
  *     L6470_CHAIN_SS_PIN
2192
- *     L6470_RESET_CHAIN_PIN  (optional)
2342
+ *     ENABLE_RESET_L64XX_CHIPS(Q)  where Q is 1 to enable and 0 to reset
2193 2343
  */
2194
-#if HAS_DRIVER(L6470)
2195 2344
 
2196
-  //#define L6470_CHITCHAT        // Display additional status info
2345
+#if HAS_L64XX
2197 2346
 
2198
-  #if AXIS_DRIVER_TYPE_X(L6470)
2199
-    #define X_MICROSTEPS     128  // Number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128)
2200
-    #define X_OVERCURRENT   2000  // (mA) Current where the driver detects an over current (VALID: 375 x (1 - 16) - 6A max - rounds down)
2201
-    #define X_STALLCURRENT  1500  // (mA) Current where the driver detects a stall (VALID: 31.25 * (1-128) -  4A max - rounds down)
2202
-    #define X_MAX_VOLTAGE    127  // 0-255, Maximum effective voltage seen by stepper
2203
-    #define X_CHAIN_POS       -1  // Position in SPI chain. (<=0 : Not in chain. 1 : Nearest MOSI)
2204
-  #endif
2347
+  //#define L6470_CHITCHAT        // Display additional status info
2205 2348
 
2206
-  #if AXIS_DRIVER_TYPE_X2(L6470)
2349
+  #if AXIS_IS_L64XX(X)
2350
+    #define X_MICROSTEPS       128  // Number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128) - L6474 max is 16
2351
+    #define X_OVERCURRENT     2000  // (mA) Current where the driver detects an over current
2352
+                                    //   L6470 & L6474 - VALID: 375 x (1 - 16) - 6A max - rounds down
2353
+                                    //   POWERSTEP01: VALID: 1000 x (1 - 32) - 32A max - rounds down
2354
+    #define X_STALLCURRENT    1500  // (mA) Current where the driver detects a stall (VALID: 31.25 * (1-128) -  4A max - rounds down)
2355
+                                    //   L6470 & L6474 - VALID: 31.25 * (1-128) -  4A max - rounds down
2356
+                                    //   POWERSTEP01: VALID: 200 x (1 - 32) - 6.4A max - rounds down
2357
+                                    //   L6474 - STALLCURRENT setting is used to set the nominal (TVAL) current
2358
+    #define X_MAX_VOLTAGE      127  // 0-255, Maximum effective voltage seen by stepper - not used by L6474
2359
+    #define X_CHAIN_POS         -1  // Position in SPI chain, 0=Not in chain, 1=Nearest MOSI
2360
+    #define X_SLEW_RATE          1  // 0-3, Slew 0 is slowest, 3 is fastest
2361
+  #endif
2362
+
2363
+  #if AXIS_IS_L64XX(X2)
2207 2364
     #define X2_MICROSTEPS      128
2208 2365
     #define X2_OVERCURRENT    2000
2209 2366
     #define X2_STALLCURRENT   1500
2210 2367
     #define X2_MAX_VOLTAGE     127
2211 2368
     #define X2_CHAIN_POS        -1
2369
+    #define X2_SLEW_RATE         1
2212 2370
   #endif
2213 2371
 
2214
-  #if AXIS_DRIVER_TYPE_Y(L6470)
2372
+  #if AXIS_IS_L64XX(Y)
2215 2373
     #define Y_MICROSTEPS       128
2216 2374
     #define Y_OVERCURRENT     2000
2217 2375
     #define Y_STALLCURRENT    1500
2218 2376
     #define Y_MAX_VOLTAGE      127
2219 2377
     #define Y_CHAIN_POS         -1
2378
+    #define Y_SLEW_RATE          1
2220 2379
   #endif
2221 2380
 
2222
-  #if AXIS_DRIVER_TYPE_Y2(L6470)
2381
+  #if AXIS_IS_L64XX(Y2)
2223 2382
     #define Y2_MICROSTEPS      128
2224 2383
     #define Y2_OVERCURRENT    2000
2225 2384
     #define Y2_STALLCURRENT   1500
2226 2385
     #define Y2_MAX_VOLTAGE     127
2227 2386
     #define Y2_CHAIN_POS        -1
2387
+    #define Y2_SLEW_RATE         1
2228 2388
   #endif
2229 2389
 
2230
-  #if AXIS_DRIVER_TYPE_Z(L6470)
2390
+  #if AXIS_IS_L64XX(Z)
2231 2391
     #define Z_MICROSTEPS       128
2232 2392
     #define Z_OVERCURRENT     2000
2233 2393
     #define Z_STALLCURRENT    1500
2234 2394
     #define Z_MAX_VOLTAGE      127
2235 2395
     #define Z_CHAIN_POS         -1
2396
+    #define Z_SLEW_RATE          1
2236 2397
   #endif
2237 2398
 
2238
-  #if AXIS_DRIVER_TYPE_Z2(L6470)
2399
+  #if AXIS_IS_L64XX(Z2)
2239 2400
     #define Z2_MICROSTEPS      128
2240 2401
     #define Z2_OVERCURRENT    2000
2241 2402
     #define Z2_STALLCURRENT   1500
2242 2403
     #define Z2_MAX_VOLTAGE     127
2243 2404
     #define Z2_CHAIN_POS        -1
2405
+    #define Z2_SLEW_RATE         1
2244 2406
   #endif
2245 2407
 
2246
-  #if AXIS_DRIVER_TYPE_Z3(L6470)
2408
+  #if AXIS_IS_L64XX(Z3)
2247 2409
     #define Z3_MICROSTEPS      128
2248 2410
     #define Z3_OVERCURRENT    2000
2249 2411
     #define Z3_STALLCURRENT   1500
2250 2412
     #define Z3_MAX_VOLTAGE     127
2251 2413
     #define Z3_CHAIN_POS        -1
2414
+    #define Z3_SLEW_RATE         1
2415
+  #endif
2416
+
2417
+  #if AXIS_IS_L64XX(Z4)
2418
+    #define Z4_MICROSTEPS      128
2419
+    #define Z4_OVERCURRENT    2000
2420
+    #define Z4_STALLCURRENT   1500
2421
+    #define Z4_MAX_VOLTAGE     127
2422
+    #define Z4_CHAIN_POS        -1
2423
+    #define Z4_SLEW_RATE         1
2252 2424
   #endif
2253 2425
 
2254
-  #if AXIS_DRIVER_TYPE_E0(L6470)
2426
+  #if AXIS_IS_L64XX(E0)
2255 2427
     #define E0_MICROSTEPS      128
2256 2428
     #define E0_OVERCURRENT    2000
2257 2429
     #define E0_STALLCURRENT   1500
2258 2430
     #define E0_MAX_VOLTAGE     127
2259 2431
     #define E0_CHAIN_POS        -1
2432
+    #define E0_SLEW_RATE         1
2260 2433
   #endif
2261 2434
 
2262
-  #if AXIS_DRIVER_TYPE_E1(L6470)
2435
+  #if AXIS_IS_L64XX(E1)
2263 2436
     #define E1_MICROSTEPS      128
2264 2437
     #define E1_OVERCURRENT    2000
2265 2438
     #define E1_STALLCURRENT   1500
2266 2439
     #define E1_MAX_VOLTAGE     127
2267 2440
     #define E1_CHAIN_POS        -1
2441
+    #define E1_SLEW_RATE         1
2268 2442
   #endif
2269 2443
 
2270
-  #if AXIS_DRIVER_TYPE_E2(L6470)
2444
+  #if AXIS_IS_L64XX(E2)
2271 2445
     #define E2_MICROSTEPS      128
2272 2446
     #define E2_OVERCURRENT    2000
2273 2447
     #define E2_STALLCURRENT   1500
2274 2448
     #define E2_MAX_VOLTAGE     127
2275 2449
     #define E2_CHAIN_POS        -1
2450
+    #define E2_SLEW_RATE         1
2276 2451
   #endif
2277 2452
 
2278
-  #if AXIS_DRIVER_TYPE_E3(L6470)
2453
+  #if AXIS_IS_L64XX(E3)
2279 2454
     #define E3_MICROSTEPS      128
2280 2455
     #define E3_OVERCURRENT    2000
2281 2456
     #define E3_STALLCURRENT   1500
2282 2457
     #define E3_MAX_VOLTAGE     127
2283 2458
     #define E3_CHAIN_POS        -1
2459
+    #define E3_SLEW_RATE         1
2284 2460
   #endif
2285 2461
 
2286
-  #if AXIS_DRIVER_TYPE_E4(L6470)
2462
+  #if AXIS_IS_L64XX(E4)
2287 2463
     #define E4_MICROSTEPS      128
2288 2464
     #define E4_OVERCURRENT    2000
2289 2465
     #define E4_STALLCURRENT   1500
2290 2466
     #define E4_MAX_VOLTAGE     127
2291 2467
     #define E4_CHAIN_POS        -1
2468
+    #define E4_SLEW_RATE         1
2292 2469
   #endif
2293 2470
 
2294
-  #if AXIS_DRIVER_TYPE_E5(L6470)
2471
+  #if AXIS_IS_L64XX(E5)
2295 2472
     #define E5_MICROSTEPS      128
2296 2473
     #define E5_OVERCURRENT    2000
2297 2474
     #define E5_STALLCURRENT   1500
2298 2475
     #define E5_MAX_VOLTAGE     127
2299 2476
     #define E5_CHAIN_POS        -1
2477
+    #define E5_SLEW_RATE         1
2478
+  #endif
2479
+
2480
+  #if AXIS_IS_L64XX(E6)
2481
+    #define E6_MICROSTEPS      128
2482
+    #define E6_OVERCURRENT    2000
2483
+    #define E6_STALLCURRENT   1500
2484
+    #define E6_MAX_VOLTAGE     127
2485
+    #define E6_CHAIN_POS        -1
2486
+    #define E6_SLEW_RATE         1
2487
+  #endif
2488
+
2489
+  #if AXIS_IS_L64XX(E7)
2490
+    #define E7_MICROSTEPS      128
2491
+    #define E7_OVERCURRENT    2000
2492
+    #define E7_STALLCURRENT   1500
2493
+    #define E7_MAX_VOLTAGE     127
2494
+    #define E7_CHAIN_POS        -1
2495
+    #define E7_SLEW_RATE         1
2300 2496
   #endif
2301 2497
 
2302 2498
   /**
@@ -2308,7 +2504,7 @@
2308 2504
    *         I not present or I0 or I1 - X, Y, Z or E0
2309 2505
    *         I2 - X2, Y2, Z2 or E1
2310 2506
    *         I3 - Z3 or E3
2311
-   *         I4 - E4
2507
+   *         I4 - Z4 or E4
2312 2508
    *         I5 - E5
2313 2509
    * M916 - Increase drive level until get thermal warning
2314 2510
    * M917 - Find minimum current thresholds
@@ -2322,7 +2518,15 @@
2322 2518
     //#define L6470_STOP_ON_ERROR
2323 2519
   #endif
2324 2520
 
2325
-#endif // L6470
2521
+#endif // HAS_L64XX
2522
+
2523
+// @section i2cbus
2524
+
2525
+//
2526
+// I2C Master ID for LPC176x LCD and Digital Current control
2527
+// Does not apply to other peripherals based on the Wire library.
2528
+//
2529
+//#define I2C_MASTER_ID  1  // Set a value from 0 to 2
2326 2530
 
2327 2531
 /**
2328 2532
  * TWI/I2C BUS
@@ -2352,10 +2556,10 @@
2352 2556
  * echo:i2c-reply: from:99 bytes:5 data:hello
2353 2557
  */
2354 2558
 
2355
-// @section i2cbus
2356
-
2357 2559
 //#define EXPERIMENTAL_I2CBUS
2358
-#define I2C_SLAVE_ADDRESS  0 // Set a value from 8 to 127 to act as a slave
2560
+#if ENABLED(EXPERIMENTAL_I2CBUS)
2561
+  #define I2C_SLAVE_ADDRESS  0  // Set a value from 8 to 127 to act as a slave
2562
+#endif
2359 2563
 
2360 2564
 // @section extras
2361 2565
 
@@ -2384,6 +2588,20 @@
2384 2588
 
2385 2589
   // Duration to hold the switch or keep CHDK_PIN high
2386 2590
   //#define PHOTO_SWITCH_MS   50 // (ms) (M240 D)
2591
+
2592
+  /**
2593
+   * PHOTO_PULSES_US may need adjustment depending on board and camera model.
2594
+   * Pin must be running at 48.4kHz.
2595
+   * Be sure to use a PHOTOGRAPH_PIN which can rise and fall quick enough.
2596
+   * (e.g., MKS SBase temp sensor pin was too slow, so used P1.23 on J8.)
2597
+   *
2598
+   *  Example pulse data for Nikon: https://bit.ly/2FKD0Aq
2599
+   *                     IR Wiring: https://git.io/JvJf7
2600
+   */
2601
+  //#define PHOTO_PULSES_US { 2000, 27850, 400, 1580, 400, 3580, 400 }  // (µs) Durations for each 48.4kHz oscillation
2602
+  #ifdef PHOTO_PULSES_US
2603
+    #define PHOTO_PULSE_DELAY_US 13 // (µs) Approximate duration of each HIGH and LOW pulse in the oscillation
2604
+  #endif
2387 2605
 #endif
2388 2606
 
2389 2607
 /**
@@ -2723,7 +2941,11 @@
2723 2941
   #define JOY_Z_PIN   12  // RAMPS: Suggested pin A12 on AUX2
2724 2942
   #define JOY_EN_PIN  44  // RAMPS: Suggested pin D44 on AUX2
2725 2943
 
2726
-  // Use M119 to find reasonable values after connecting your hardware:
2944
+  //#define INVERT_JOY_X  // Enable if X direction is reversed
2945
+  //#define INVERT_JOY_Y  // Enable if Y direction is reversed
2946
+  //#define INVERT_JOY_Z  // Enable if Z direction is reversed
2947
+
2948
+  // Use M119 with JOYSTICK_DEBUG to find reasonable values after connecting:
2727 2949
   #define JOY_X_LIMITS { 5600, 8190-100, 8190+100, 10800 } // min, deadzone start, deadzone end, max
2728 2950
   #define JOY_Y_LIMITS { 5600, 8250-100, 8250+100, 11000 }
2729 2951
   #define JOY_Z_LIMITS { 4800, 8080-100, 8080+100, 11550 }
@@ -2778,12 +3000,15 @@
2778 3000
 /**
2779 3001
  * WiFi Support (Espressif ESP32 WiFi)
2780 3002
  */
2781
-//#define WIFISUPPORT
2782
-#if ENABLED(WIFISUPPORT)
3003
+//#define WIFISUPPORT         // Marlin embedded WiFi managenent
3004
+//#define ESP3D_WIFISUPPORT   // ESP3D Library WiFi management (https://github.com/luc-github/ESP3DLib)
3005
+
3006
+#if EITHER(WIFISUPPORT, ESP3D_WIFISUPPORT)
2783 3007
   #define WIFI_SSID "Wifi SSID"
2784 3008
   #define WIFI_PWD  "Wifi Password"
2785
-  //#define WEBSUPPORT        // Start a webserver with auto-discovery
2786
-  //#define OTASUPPORT        // Support over-the-air firmware updates
3009
+  //#define WEBSUPPORT          // Start a webserver (which may include auto-discovery)
3010
+  //#define OTASUPPORT          // Support over-the-air firmware updates
3011
+  //#define WIFI_CUSTOM_COMMAND // Accept feature config commands (e.g., WiFi ESP3D) from the host
2787 3012
 #endif
2788 3013
 
2789 3014
 /**
@@ -2855,9 +3080,14 @@
2855 3080
 
2856 3081
 // @section develop
2857 3082
 
2858
-/**
2859
- * M43 - display pin status, watch pins for changes, watch endstops & toggle LED, Z servo probe test, toggle pins
2860
- */
3083
+//
3084
+// M100 Free Memory Watcher to debug memory usage
3085
+//
3086
+//#define M100_FREE_MEMORY_WATCHER
3087
+
3088
+//
3089
+// M43 - display pin status, toggle pins, watch pins, watch endstops & toggle LED, test servo probe
3090
+//
2861 3091
 //#define PINS_DEBUGGING
2862 3092
 
2863 3093
 // Enable Marlin dev mode which adds some special commands

+ 22
- 9
Marlin/src/HAL/HAL_AVR/HAL.h Ver fichero

@@ -91,24 +91,37 @@ typedef int8_t pin_t;
91 91
   #define NUM_SERIAL 1
92 92
 #else
93 93
   #if !WITHIN(SERIAL_PORT, -1, 3)
94
-    #error "SERIAL_PORT must be from -1 to 3"
94
+    #error "SERIAL_PORT must be from -1 to 3. Please update your configuration."
95 95
   #endif
96 96
 
97 97
   #define MYSERIAL0 customizedSerial1
98 98
 
99 99
   #ifdef SERIAL_PORT_2
100 100
     #if !WITHIN(SERIAL_PORT_2, -1, 3)
101
-      #error "SERIAL_PORT_2 must be from -1 to 3"
101
+      #error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration."
102 102
     #elif SERIAL_PORT_2 == SERIAL_PORT
103
-      #error "SERIAL_PORT_2 must be different than SERIAL_PORT"
103
+      #error "SERIAL_PORT_2 must be different than SERIAL_PORT. Please update your configuration."
104 104
     #endif
105
-    #define NUM_SERIAL 2
106 105
     #define MYSERIAL1 customizedSerial2
106
+    #define NUM_SERIAL 2
107 107
   #else
108 108
     #define NUM_SERIAL 1
109 109
   #endif
110 110
 #endif
111 111
 
112
+#ifdef DGUS_SERIAL_PORT
113
+  #if !WITHIN(DGUS_SERIAL_PORT, -1, 3)
114
+    #error "DGUS_SERIAL_PORT must be from -1 to 3. Please update your configuration."
115
+  #elif DGUS_SERIAL_PORT == SERIAL_PORT
116
+    #error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration."
117
+  #elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
118
+    #error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
119
+  #endif
120
+  #define DGUS_SERIAL internalDgusSerial
121
+
122
+  #define DGUS_SERIAL_GET_TX_BUFFER_FREE DGUS_SERIAL.get_tx_buffer_free
123
+#endif
124
+
112 125
 // ------------------------
113 126
 // Public functions
114 127
 // ------------------------
@@ -345,9 +358,9 @@ void TIMER0_COMPB_vect_bottom()
345 358
 
346 359
 // ADC
347 360
 #ifdef DIDR2
348
-  #define HAL_ANALOG_SELECT(pin) do{ if (pin < 8) SBI(DIDR0, pin); else SBI(DIDR2, pin & 0x07); }while(0)
361
+  #define HAL_ANALOG_SELECT(ind) do{ if (ind < 8) SBI(DIDR0, ind); else SBI(DIDR2, ind & 0x07); }while(0)
349 362
 #else
350
-  #define HAL_ANALOG_SELECT(pin) do{ SBI(DIDR0, pin); }while(0)
363
+  #define HAL_ANALOG_SELECT(ind) SBI(DIDR0, ind);
351 364
 #endif
352 365
 
353 366
 inline void HAL_adc_init() {
@@ -358,11 +371,11 @@ inline void HAL_adc_init() {
358 371
   #endif
359 372
 }
360 373
 
361
-#define SET_ADMUX_ADCSRA(pin) ADMUX = _BV(REFS0) | (pin & 0x07); SBI(ADCSRA, ADSC)
374
+#define SET_ADMUX_ADCSRA(ch) ADMUX = _BV(REFS0) | (ch & 0x07); SBI(ADCSRA, ADSC)
362 375
 #ifdef MUX5
363
-  #define HAL_START_ADC(pin) if (pin > 7) ADCSRB = _BV(MUX5); else ADCSRB = 0; SET_ADMUX_ADCSRA(pin)
376
+  #define HAL_START_ADC(ch) if (ch > 7) ADCSRB = _BV(MUX5); else ADCSRB = 0; SET_ADMUX_ADCSRA(ch)
364 377
 #else
365
-  #define HAL_START_ADC(pin) ADCSRB = 0; SET_ADMUX_ADCSRA(pin)
378
+  #define HAL_START_ADC(ch) ADCSRB = 0; SET_ADMUX_ADCSRA(ch)
366 379
 #endif
367 380
 
368 381
 #define HAL_ADC_RESOLUTION 10

+ 28
- 1
Marlin/src/HAL/HAL_AVR/MarlinSerial.cpp Ver fichero

@@ -41,7 +41,7 @@
41 41
 #if !defined(USBCON) && (defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H))
42 42
 
43 43
   #include "MarlinSerial.h"
44
-  #include "../../Marlin.h"
44
+  #include "../../MarlinCore.h"
45 45
 
46 46
   template<typename Cfg> typename MarlinSerial<Cfg>::ring_buffer_r MarlinSerial<Cfg>::rx_buffer = { 0, 0, { 0 } };
47 47
   template<typename Cfg> typename MarlinSerial<Cfg>::ring_buffer_t MarlinSerial<Cfg>::tx_buffer = { 0 };
@@ -757,6 +757,33 @@
757 757
 
758 758
 #endif
759 759
 
760
+#ifdef DGUS_SERIAL_PORT
761
+
762
+  template<typename Cfg>
763
+  typename MarlinSerial<Cfg>::ring_buffer_pos_t MarlinSerial<Cfg>::get_tx_buffer_free() {
764
+    const ring_buffer_pos_t t = tx_buffer.tail,  // next byte to send.
765
+                            h = tx_buffer.head;  // next pos for queue.
766
+    int ret = t - h - 1;
767
+    if (ret < 0) ret += Cfg::TX_SIZE + 1;
768
+    return ret;
769
+  }
770
+
771
+  ISR(SERIAL_REGNAME(USART,DGUS_SERIAL_PORT,_RX_vect)) {
772
+    MarlinSerial<MarlinInternalSerialCfg<DGUS_SERIAL_PORT>>::store_rxd_char();
773
+  }
774
+
775
+  ISR(SERIAL_REGNAME(USART,DGUS_SERIAL_PORT,_UDRE_vect)) {
776
+    MarlinSerial<MarlinInternalSerialCfg<DGUS_SERIAL_PORT>>::_tx_udr_empty_irq();
777
+  }
778
+
779
+  // Preinstantiate
780
+  template class MarlinSerial<MarlinInternalSerialCfg<DGUS_SERIAL_PORT>>;
781
+
782
+  // Instantiate
783
+  MarlinSerial<MarlinInternalSerialCfg<DGUS_SERIAL_PORT>> internalDgusSerial;
784
+
785
+#endif
786
+
760 787
 // For AT90USB targets use the UART for BT interfacing
761 788
 #if defined(USBCON) && ENABLED(BLUETOOTH)
762 789
   HardwareSerial bluetoothSerial;

+ 20
- 0
Marlin/src/HAL/HAL_AVR/MarlinSerial.h Ver fichero

@@ -217,6 +217,9 @@
217 217
       static ring_buffer_pos_t available();
218 218
       static void write(const uint8_t c);
219 219
       static void flushTX();
220
+      #ifdef DGUS_SERIAL_PORT
221
+        static ring_buffer_pos_t get_tx_buffer_free();
222
+      #endif
220 223
 
221 224
       FORCE_INLINE static uint8_t dropped() { return Cfg::DROPPED_RX ? rx_dropped_bytes : 0; }
222 225
       FORCE_INLINE static uint8_t buffer_overruns() { return Cfg::RX_OVERRUNS ? rx_buffer_overruns : 0; }
@@ -292,6 +295,23 @@
292 295
   extern MarlinSerial<MarlinInternalSerialCfg<INTERNAL_SERIAL_PORT>> internalSerial;
293 296
 #endif
294 297
 
298
+#ifdef DGUS_SERIAL_PORT
299
+  template <uint8_t serial>
300
+  struct MarlinInternalSerialCfg {
301
+    static constexpr int PORT               = serial;
302
+    static constexpr unsigned int RX_SIZE   = 128;
303
+    static constexpr unsigned int TX_SIZE   = 48;
304
+    static constexpr bool XONOFF            = false;
305
+    static constexpr bool EMERGENCYPARSER   = false;
306
+    static constexpr bool DROPPED_RX        = false;
307
+    static constexpr bool RX_OVERRUNS       = bDGUS_SERIAL_STATS_RX_BUFFER_OVERRUNS;
308
+    static constexpr bool RX_FRAMING_ERRORS = false;
309
+    static constexpr bool MAX_RX_QUEUED     = false;
310
+  };
311
+
312
+  extern MarlinSerial<MarlinInternalSerialCfg<DGUS_SERIAL_PORT>> internalDgusSerial;
313
+#endif
314
+
295 315
 // Use the UART for Bluetooth in AT90USB configurations
296 316
 #if defined(USBCON) && ENABLED(BLUETOOTH)
297 317
   extern HardwareSerial bluetoothSerial;

+ 16
- 0
Marlin/src/HAL/HAL_AVR/endstop_interrupts.h Ver fichero

@@ -232,6 +232,22 @@ void setup_endstop_interrupts() {
232 232
       pciSetup(Z3_MIN_PIN);
233 233
     #endif
234 234
   #endif
235
+  #if HAS_Z4_MAX
236
+    #if (digitalPinToInterrupt(Z4_MAX_PIN) != NOT_AN_INTERRUPT)
237
+      _ATTACH(Z4_MAX_PIN);
238
+    #else
239
+      static_assert(digitalPinHasPCICR(Z4_MAX_PIN), "Z4_MAX_PIN is not interrupt-capable");
240
+      pciSetup(Z4_MAX_PIN);
241
+    #endif
242
+  #endif
243
+  #if HAS_Z4_MIN
244
+    #if (digitalPinToInterrupt(Z4_MIN_PIN) != NOT_AN_INTERRUPT)
245
+      _ATTACH(Z4_MIN_PIN);
246
+    #else
247
+      static_assert(digitalPinHasPCICR(Z4_MIN_PIN), "Z4_MIN_PIN is not interrupt-capable");
248
+      pciSetup(Z4_MIN_PIN);
249
+    #endif
250
+  #endif
235 251
   #if HAS_Z_MIN_PROBE_PIN
236 252
     #if (digitalPinToInterrupt(Z_MIN_PROBE_PIN) != NOT_AN_INTERRUPT)
237 253
       _ATTACH(Z_MIN_PROBE_PIN);

+ 15
- 4
Marlin/src/HAL/HAL_AVR/fastio.h Ver fichero

@@ -279,14 +279,25 @@ enum ClockSource2 : char {
279 279
  */
280 280
 
281 281
 // Determine which harware PWMs are already in use
282
+#define _PWM_CHK_FAN_B(P) (P == E0_AUTO_FAN_PIN || P == E1_AUTO_FAN_PIN || P == E2_AUTO_FAN_PIN || P == E3_AUTO_FAN_PIN || P == E4_AUTO_FAN_PIN || P == E5_AUTO_FAN_PIN || P == E6_AUTO_FAN_PIN || P == E7_AUTO_FAN_PIN || P == CHAMBER_AUTO_FAN_PIN)
282 283
 #if PIN_EXISTS(CONTROLLER_FAN)
283
-  #define PWM_CHK_FAN_B(P) (P == CONTROLLER_FAN_PIN || P == E0_AUTO_FAN_PIN || P == E1_AUTO_FAN_PIN || P == E2_AUTO_FAN_PIN || P == E3_AUTO_FAN_PIN || P == E4_AUTO_FAN_PIN || P == E5_AUTO_FAN_PIN || P == CHAMBER_AUTO_FAN_PIN)
284
+  #define PWM_CHK_FAN_B(P) (_PWM_CHK_FAN_B(P) || P == CONTROLLER_FAN_PIN)
284 285
 #else
285
-  #define PWM_CHK_FAN_B(P) (P == E0_AUTO_FAN_PIN || P == E1_AUTO_FAN_PIN || P == E2_AUTO_FAN_PIN || P == E3_AUTO_FAN_PIN || P == E4_AUTO_FAN_PIN || P == E5_AUTO_FAN_PIN || P == CHAMBER_AUTO_FAN_PIN)
286
+  #define PWM_CHK_FAN_B(P) _PWM_CHK_FAN_B(P)
286 287
 #endif
287 288
 
288
-#if ANY_PIN(FAN, FAN1, FAN2)
289
-  #if PIN_EXISTS(FAN2)
289
+#if ANY_PIN(FAN, FAN1, FAN2, FAN3, FAN4, FAN5, FAN6, FAN7)
290
+  #if PIN_EXISTS(FAN7)
291
+    #define PWM_CHK_FAN_A(P) (P == FAN0_PIN || P == FAN1_PIN || P == FAN2_PIN || P == FAN3_PIN || P == FAN4_PIN || P == FAN5_PIN || P == FAN6_PIN || P == FAN7_PIN)
292
+  #elif PIN_EXISTS(FAN6)
293
+    #define PWM_CHK_FAN_A(P) (P == FAN0_PIN || P == FAN1_PIN || P == FAN2_PIN || P == FAN3_PIN || P == FAN4_PIN || P == FAN5_PIN || P == FAN6_PIN)
294
+  #elif PIN_EXISTS(FAN5)
295
+    #define PWM_CHK_FAN_A(P) (P == FAN0_PIN || P == FAN1_PIN || P == FAN2_PIN || P == FAN3_PIN || P == FAN4_PIN || P == FAN5_PIN)
296
+  #elif PIN_EXISTS(FAN4)
297
+    #define PWM_CHK_FAN_A(P) (P == FAN0_PIN || P == FAN1_PIN || P == FAN2_PIN || P == FAN3_PIN || P == FAN4_PIN)
298
+  #elif PIN_EXISTS(FAN3)
299
+    #define PWM_CHK_FAN_A(P) (P == FAN0_PIN || P == FAN1_PIN || P == FAN2_PIN || P == FAN3_PIN)
300
+  #elif PIN_EXISTS(FAN2)
290 301
     #define PWM_CHK_FAN_A(P) (P == FAN0_PIN || P == FAN1_PIN || P == FAN2_PIN)
291 302
   #elif PIN_EXISTS(FAN1)
292 303
     #define PWM_CHK_FAN_A(P) (P == FAN0_PIN || P == FAN1_PIN)

+ 4
- 0
Marlin/src/HAL/HAL_AVR/inc/SanityCheck.h Ver fichero

@@ -59,3 +59,7 @@
59 59
 #if HAS_TRINAMIC && ENABLED(ENDSTOP_INTERRUPTS_FEATURE)
60 60
   #error "TMCStepper includes SoftwareSerial.h which is incompatible with ENDSTOP_INTERRUPTS_FEATURE. Disable ENDSTOP_INTERRUPTS_FEATURE to continue."
61 61
 #endif
62
+
63
+#if TMC_HAS_SW_SERIAL && ENABLED(MONITOR_DRIVER_STATUS)
64
+  #error "MONITOR_DRIVER_STATUS causes performance issues when used with SoftwareSerial-connected drivers. Disable MONITOR_DRIVER_STATUS or use hardware serial to continue."
65
+#endif

+ 3
- 5
Marlin/src/HAL/HAL_AVR/pinsDebug.h Ver fichero

@@ -231,11 +231,10 @@ static void err_is_interrupt()   { SERIAL_ECHOPGM("   compare interrupt enabled"
231 231
 static void err_prob_interrupt() { SERIAL_ECHOPGM("   overflow interrupt enabled"); }
232 232
 static void print_is_also_tied() { SERIAL_ECHOPGM(" is also tied to this pin"); SERIAL_ECHO_SP(14); }
233 233
 
234
-void com_print(uint8_t N, uint8_t Z) {
234
+inline void com_print(const uint8_t N, const uint8_t Z) {
235 235
   const uint8_t *TCCRA = (uint8_t*)TCCR_A(N);
236 236
   SERIAL_ECHOPGM("    COM");
237
-  SERIAL_CHAR('0' + N);
238
-  SERIAL_CHAR('A' + Z);
237
+  SERIAL_CHAR('0' + N, Z);
239 238
   SERIAL_ECHOPAIR(": ", int((*TCCRA >> (6 - Z * 2)) & 0x03));
240 239
 }
241 240
 
@@ -247,8 +246,7 @@ void timer_prefix(uint8_t T, char L, uint8_t N) {  // T - timer    L - pwm  N -
247 246
   if (N == 4) WGM |= ((*TCCRB & _BV(WGM_3)) >> 1);
248 247
 
249 248
   SERIAL_ECHOPGM("    TIMER");
250
-  SERIAL_CHAR(T + '0');
251
-  SERIAL_CHAR(L);
249
+  SERIAL_CHAR(T + '0', L);
252 250
   SERIAL_ECHO_SP(3);
253 251
 
254 252
   if (N == 3) {

+ 1
- 1
Marlin/src/HAL/HAL_AVR/watchdog.cpp Ver fichero

@@ -28,7 +28,7 @@
28 28
 
29 29
 #include "watchdog.h"
30 30
 
31
-#include "../../Marlin.h"
31
+#include "../../MarlinCore.h"
32 32
 
33 33
 // Initialize watchdog with 8s timeout, if possible. Otherwise, make it 4s.
34 34
 void watchdog_init() {

+ 2
- 2
Marlin/src/HAL/HAL_DUE/HAL.cpp Ver fichero

@@ -94,8 +94,8 @@ int freeMemory() {
94 94
 // ADC
95 95
 // ------------------------
96 96
 
97
-void HAL_adc_start_conversion(const uint8_t adc_pin) {
98
-  HAL_adc_result = analogRead(adc_pin);
97
+void HAL_adc_start_conversion(const uint8_t ch) {
98
+  HAL_adc_result = analogRead(ch);
99 99
 }
100 100
 
101 101
 uint16_t HAL_adc_get_result() {

+ 25
- 5
Marlin/src/HAL/HAL_DUE/HAL.h Ver fichero

@@ -56,8 +56,7 @@
56 56
 #ifdef SERIAL_PORT_2
57 57
   #if SERIAL_PORT_2 == SERIAL_PORT
58 58
     #error "SERIAL_PORT_2 must be different from SERIAL_PORT. Please update your configuration."
59
-  #endif
60
-  #if SERIAL_PORT_2 == -1
59
+  #elif SERIAL_PORT_2 == -1
61 60
     #define MYSERIAL1 customizedSerial2
62 61
   #elif SERIAL_PORT_2 == 0
63 62
     #define MYSERIAL1 Serial
@@ -75,6 +74,27 @@
75 74
   #define NUM_SERIAL 1
76 75
 #endif
77 76
 
77
+#ifdef DGUS_SERIAL_PORT
78
+  #if DGUS_SERIAL_PORT == SERIAL_PORT
79
+    #error "DGUS_SERIAL_PORT must be different from SERIAL_PORT. Please update your configuration."
80
+  #elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
81
+    #error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
82
+  #elif DGUS_SERIAL_PORT == -1
83
+    #define DGUS_SERIAL internalDgusSerial
84
+  #elif DGUS_SERIAL_PORT == 0
85
+    #define DGUS_SERIAL Serial
86
+  #elif DGUS_SERIAL_PORT == 1
87
+    #define DGUS_SERIAL Serial1
88
+  #elif DGUS_SERIAL_PORT == 2
89
+    #define DGUS_SERIAL Serial2
90
+  #elif DGUS_SERIAL_PORT == 3
91
+    #define DGUS_SERIAL Serial3
92
+  #else
93
+    #error "DGUS_SERIAL_PORT must be from -1 to 3. Please update your configuration."
94
+  #endif
95
+#endif
96
+
97
+
78 98
 #include "MarlinSerial.h"
79 99
 #include "MarlinSerialUSB.h"
80 100
 
@@ -128,16 +148,16 @@ extern uint16_t HAL_adc_result;     // result of last ADC conversion
128 148
   #define analogInputToDigitalPin(p) ((p < 12u) ? (p) + 54u : -1)
129 149
 #endif
130 150
 
131
-#define HAL_ANALOG_SELECT(pin)
151
+#define HAL_ANALOG_SELECT(ch)
132 152
 
133 153
 inline void HAL_adc_init() {}//todo
134 154
 
135
-#define HAL_START_ADC(pin)  HAL_adc_start_conversion(pin)
155
+#define HAL_START_ADC(ch)   HAL_adc_start_conversion(ch)
136 156
 #define HAL_ADC_RESOLUTION  10
137 157
 #define HAL_READ_ADC()      HAL_adc_result
138 158
 #define HAL_ADC_READY()     true
139 159
 
140
-void HAL_adc_start_conversion(const uint8_t adc_pin);
160
+void HAL_adc_start_conversion(const uint8_t ch);
141 161
 uint16_t HAL_adc_get_result();
142 162
 
143 163
 //

+ 1
- 1
Marlin/src/HAL/HAL_DUE/HAL_SPI.cpp Ver fichero

@@ -240,7 +240,7 @@
240 240
   }
241 241
 
242 242
   // all the others
243
-  static uint32_t spiDelayCyclesX4 = (F_CPU) / 1000000; // 4uS => 125khz
243
+  static uint32_t spiDelayCyclesX4 = (F_CPU) / 1000000; // 4µs => 125khz
244 244
 
245 245
   static uint8_t spiTransferX(uint8_t b) { // using Mode 0
246 246
     int bits = 8;

+ 1
- 1
Marlin/src/HAL/HAL_DUE/MarlinSerial.cpp Ver fichero

@@ -31,7 +31,7 @@
31 31
 
32 32
 #include "MarlinSerial.h"
33 33
 #include "InterruptVectors.h"
34
-#include "../../Marlin.h"
34
+#include "../../MarlinCore.h"
35 35
 
36 36
 template<typename Cfg> typename MarlinSerial<Cfg>::ring_buffer_r MarlinSerial<Cfg>::rx_buffer = { 0, 0, { 0 } };
37 37
 template<typename Cfg> typename MarlinSerial<Cfg>::ring_buffer_t MarlinSerial<Cfg>::tx_buffer = { 0 };

+ 1
- 1
Marlin/src/HAL/HAL_DUE/dogm/u8g_com_HAL_DUE_shared_hw_spi.cpp Ver fichero

@@ -63,7 +63,7 @@
63 63
 
64 64
 #include <U8glib.h>
65 65
 
66
-#include "../../../Marlin.h"
66
+#include "../../../MarlinCore.h"
67 67
 
68 68
 void spiBegin();
69 69
 void spiInit(uint8_t spiRate);

+ 6
- 0
Marlin/src/HAL/HAL_DUE/endstop_interrupts.h Ver fichero

@@ -77,6 +77,12 @@ void setup_endstop_interrupts() {
77 77
   #if HAS_Z3_MIN
78 78
     _ATTACH(Z3_MIN_PIN);
79 79
   #endif
80
+  #if HAS_Z4_MAX
81
+    _ATTACH(Z4_MAX_PIN);
82
+  #endif
83
+  #if HAS_Z4_MIN
84
+    _ATTACH(Z4_MIN_PIN);
85
+  #endif
80 86
   #if HAS_Z_MIN_PROBE_PIN
81 87
     _ATTACH(Z_MIN_PROBE_PIN);
82 88
   #endif

+ 4
- 0
Marlin/src/HAL/HAL_DUE/inc/SanityCheck.h Ver fichero

@@ -55,3 +55,7 @@
55 55
 #if ENABLED(FAST_PWM_FAN)
56 56
   #error "FAST_PWM_FAN is not yet implemented for this platform."
57 57
 #endif
58
+
59
+#if TMC_HAS_SW_SERIAL
60
+  #error "TMC220x Software Serial is not supported on this platform."
61
+#endif

+ 1
- 1
Marlin/src/HAL/HAL_DUE/usb/uotghs_device_due.c Ver fichero

@@ -1479,7 +1479,7 @@ static void udd_ctrl_in_sent(void)
1479 1479
 	// The IN data don't must be written in endpoint 0 DPRAM during
1480 1480
 	// a next setup reception in same endpoint 0 DPRAM.
1481 1481
 	// Thereby, an OUT ZLP reception must check before IN data write
1482
-	// and if no OUT ZLP is recevied the data must be written quickly (800us)
1482
+	// and if no OUT ZLP is received the data must be written quickly (800µs)
1483 1483
 	// before an eventually ZLP OUT and SETUP reception
1484 1484
 	flags = cpu_irq_save();
1485 1485
 	if (Is_udd_out_received(0)) {

+ 1
- 1
Marlin/src/HAL/HAL_DUE/watchdog.cpp Ver fichero

@@ -23,7 +23,7 @@
23 23
 #ifdef ARDUINO_ARCH_SAM
24 24
 
25 25
 #include "../../inc/MarlinConfig.h"
26
-#include "../../Marlin.h"
26
+#include "../../MarlinCore.h"
27 27
 #include "watchdog.h"
28 28
 
29 29
 // Override Arduino runtime to either config or disable the watchdog

+ 24
- 13
Marlin/src/HAL/HAL_ESP32/HAL.cpp Ver fichero

@@ -30,10 +30,6 @@
30 30
 
31 31
 #include "../../inc/MarlinConfigPre.h"
32 32
 
33
-#if ENABLED(WEBSUPPORT)
34
-  #include "spiffs.h"
35
-#endif
36
-
37 33
 #if ENABLED(WIFISUPPORT)
38 34
   #include <ESPAsyncWebServer.h>
39 35
   #include "wifi.h"
@@ -41,6 +37,7 @@
41 37
     #include "ota.h"
42 38
   #endif
43 39
   #if ENABLED(WEBSUPPORT)
40
+    #include "spiffs.h"
44 41
     #include "web.h"
45 42
   #endif
46 43
 #endif
@@ -78,21 +75,32 @@ volatile int numPWMUsed = 0,
78 75
 // Public functions
79 76
 // ------------------------
80 77
 
81
-void HAL_init() {
82
-  i2s_init();
83
-}
78
+#if ENABLED(WIFI_CUSTOM_COMMAND)
79
+
80
+  bool wifi_custom_command(char * const command_ptr) {
81
+    #if ENABLED(ESP3D_WIFISUPPORT)
82
+      return esp3dlib.parse(command_ptr);
83
+    #else
84
+      UNUSED(command_ptr);
85
+      return false;
86
+    #endif
87
+  }
88
+
89
+#endif
90
+
91
+void HAL_init() { i2s_init(); }
84 92
 
85 93
 void HAL_init_board() {
86
-  #if ENABLED(WEBSUPPORT)
87
-    spiffs_init();
88
-  #endif
89 94
 
90
-  #if ENABLED(WIFISUPPORT)
95
+  #if ENABLED(ESP3D_WIFISUPPORT)
96
+    esp3dlib.init();
97
+  #elif ENABLED(WIFISUPPORT)
91 98
     wifi_init();
92 99
     #if ENABLED(OTASUPPORT)
93 100
       OTA_init();
94 101
     #endif
95 102
     #if ENABLED(WEBSUPPORT)
103
+      spiffs_init();
96 104
       web_init();
97 105
     #endif
98 106
     server.begin();
@@ -100,9 +108,12 @@ void HAL_init_board() {
100 108
 }
101 109
 
102 110
 void HAL_idletask() {
103
-  #if ENABLED(OTASUPPORT)
111
+  #if BOTH(WIFISUPPORT, OTASUPPORT)
104 112
     OTA_handle();
105 113
   #endif
114
+  #if ENABLED(ESP3D_WIFISUPPORT)
115
+    esp3dlib.idletask();
116
+  #endif
106 117
 }
107 118
 
108 119
 void HAL_clear_reset_source() { }
@@ -183,7 +194,7 @@ void HAL_adc_init() {
183 194
   }
184 195
 }
185 196
 
186
-void HAL_adc_start_conversion(uint8_t adc_pin) {
197
+void HAL_adc_start_conversion(const uint8_t adc_pin) {
187 198
   const adc1_channel_t chan = get_channel(adc_pin);
188 199
   uint32_t mv;
189 200
   esp_adc_cal_get_voltage((adc_channel_t)chan, &characteristics[attenuations[chan]], &mv);

+ 56
- 5
Marlin/src/HAL/HAL_ESP32/HAL.h Ver fichero

@@ -36,7 +36,14 @@
36 36
 
37 37
 #include "timers.h"
38 38
 
39
-#include "WebSocketSerial.h"
39
+#if ENABLED(WIFISUPPORT)
40
+  #include "WebSocketSerial.h"
41
+#endif
42
+
43
+#if ENABLED(ESP3D_WIFISUPPORT)
44
+  #include "esp3dlib.h"
45
+#endif
46
+
40 47
 #include "FlushableHardwareSerial.h"
41 48
 
42 49
 // ------------------------
@@ -47,9 +54,13 @@ extern portMUX_TYPE spinlock;
47 54
 
48 55
 #define MYSERIAL0 flushableSerial
49 56
 
50
-#if ENABLED(WIFISUPPORT)
57
+#if EITHER(WIFISUPPORT, ESP3D_WIFISUPPORT)
58
+  #if ENABLED(ESP3D_WIFISUPPORT)
59
+    #define MYSERIAL1 Serial2Socket
60
+  #else
61
+    #define MYSERIAL1 webSocketSerial
62
+  #endif
51 63
   #define NUM_SERIAL 2
52
-  #define MYSERIAL1 webSocketSerial
53 64
 #else
54 65
   #define NUM_SERIAL 1
55 66
 #endif
@@ -60,7 +71,6 @@ extern portMUX_TYPE spinlock;
60 71
 #define ENABLE_ISRS()  if (spinlock.owner != portMUX_FREE_VAL) portEXIT_CRITICAL(&spinlock)
61 72
 #define DISABLE_ISRS() portENTER_CRITICAL(&spinlock)
62 73
 
63
-
64 74
 // Fix bug in pgm_read_ptr
65 75
 #undef pgm_read_ptr
66 76
 #define pgm_read_ptr(addr) (*(addr))
@@ -115,7 +125,7 @@ void HAL_adc_init();
115 125
 #define HAL_READ_ADC()      HAL_adc_result
116 126
 #define HAL_ADC_READY()     true
117 127
 
118
-void HAL_adc_start_conversion(uint8_t adc_pin);
128
+void HAL_adc_start_conversion(const uint8_t adc_pin);
119 129
 
120 130
 #define GET_PIN_MAP_PIN(index) index
121 131
 #define GET_PIN_MAP_INDEX(pin) pin
@@ -127,3 +137,44 @@ void HAL_adc_start_conversion(uint8_t adc_pin);
127 137
 void HAL_idletask();
128 138
 void HAL_init();
129 139
 void HAL_init_board();
140
+
141
+//
142
+// Delay in cycles (used by DELAY_NS / DELAY_US)
143
+//
144
+FORCE_INLINE static void DELAY_CYCLES(uint32_t x) {
145
+  unsigned long start, ccount, stop;
146
+
147
+  /**
148
+   * It's important to care for race conditions (and overflows) here.
149
+   * Race condition example: If `stop` calculates to being close to the upper boundary of
150
+   * `uint32_t` and if at the same time a longer loop interruption kicks in (e.g. due to other
151
+   * FreeRTOS tasks or interrupts), `ccount` might overflow (and therefore be below `stop` again)
152
+   * without the loop ever being able to notice that `ccount` had already been above `stop` once
153
+   * (and that therefore the number of cycles to delay has already passed).
154
+   * As DELAY_CYCLES (through DELAY_NS / DELAY_US) is used by software SPI bit banging to drive
155
+   * LCDs and therefore might be called very, very often, this seemingly improbable situation did
156
+   * actually happen in reality. It resulted in apparently random print pauses of ~17.9 seconds
157
+   * (0x100000000 / 240 MHz) or multiples thereof, essentially ruining the current print by causing
158
+   * large blobs of filament.
159
+   */
160
+
161
+  __asm__ __volatile__ ( "rsr     %0, ccount" : "=a" (start) );
162
+  stop = start + x;
163
+  ccount = start;
164
+
165
+  if (stop >= start) {
166
+    // no overflow, so only loop while in between start and stop:
167
+    // 0x00000000 -----------------start****stop-- 0xffffffff
168
+    while (ccount >= start && ccount < stop) {
169
+      __asm__ __volatile__ ( "rsr     %0, ccount" : "=a" (ccount) );
170
+    }
171
+  }
172
+  else {
173
+    // stop did overflow, so only loop while outside of stop and start:
174
+    // 0x00000000 **stop-------------------start** 0xffffffff
175
+    while (ccount >= start || ccount < stop) {
176
+      __asm__ __volatile__ ( "rsr     %0, ccount" : "=a" (ccount) );
177
+    }
178
+  }
179
+
180
+}

+ 1
- 1
Marlin/src/HAL/HAL_ESP32/Servo.cpp Ver fichero

@@ -37,7 +37,7 @@ Servo::Servo() {
37 37
 
38 38
 int8_t Servo::attach(const int inPin) {
39 39
   if (channel >= CHANNEL_MAX_NUM) return -1;
40
-  if (pin > 0) pin = inPin;
40
+  if (inPin > 0) pin = inPin;
41 41
 
42 42
   ledcSetup(channel, 50, 16); // channel X, 50 Hz, 16-bit depth
43 43
   ledcAttachPin(pin, channel);

+ 6
- 0
Marlin/src/HAL/HAL_ESP32/endstop_interrupts.h Ver fichero

@@ -72,6 +72,12 @@ void setup_endstop_interrupts() {
72 72
   #if HAS_Z3_MIN
73 73
     _ATTACH(Z3_MIN_PIN);
74 74
   #endif
75
+  #if HAS_Z4_MAX
76
+    _ATTACH(Z4_MAX_PIN);
77
+  #endif
78
+  #if HAS_Z4_MIN
79
+    _ATTACH(Z4_MIN_PIN);
80
+  #endif
75 81
   #if HAS_Z_MIN_PROBE_PIN
76 82
     _ATTACH(Z_MIN_PROBE_PIN);
77 83
   #endif

+ 1
- 1
Marlin/src/HAL/HAL_ESP32/i2s.cpp Ver fichero

@@ -177,7 +177,7 @@ int i2s_init() {
177 177
    *
178 178
    *   fwclk = fbclk / 32
179 179
    *
180
-   *   for fwclk = 250kHz (4uS pulse time)
180
+   *   for fwclk = 250kHz (4µS pulse time)
181 181
    *      N = 10
182 182
    *      M = 20
183 183
    */

+ 8
- 0
Marlin/src/HAL/HAL_ESP32/inc/SanityCheck.h Ver fichero

@@ -28,3 +28,11 @@
28 28
 #if ENABLED(FAST_PWM_FAN)
29 29
   #error "FAST_PWM_FAN is not yet implemented for this platform."
30 30
 #endif
31
+
32
+#if TMC_HAS_SW_SERIAL
33
+  #error "TMC220x Software Serial is not supported on this platform."
34
+#endif
35
+
36
+#if BOTH(WIFISUPPORT, ESP3D_WIFISUPPORT)
37
+  #error "Only enable one WiFi option, either WIFISUPPORT or ESP3D_WIFISUPPORT."
38
+#endif

+ 2
- 3
Marlin/src/HAL/HAL_ESP32/ota.cpp Ver fichero

@@ -21,7 +21,7 @@
21 21
 
22 22
 #include "../../inc/MarlinConfigPre.h"
23 23
 
24
-#if ENABLED(OTASUPPORT)
24
+#if BOTH(WIFISUPPORT, OTASUPPORT)
25 25
 
26 26
 #include <WiFi.h>
27 27
 #include <ESPmDNS.h>
@@ -67,6 +67,5 @@ void OTA_handle() {
67 67
   ArduinoOTA.handle();
68 68
 }
69 69
 
70
-#endif // OTASUPPORT
71
-
70
+#endif // WIFISUPPORT && OTASUPPORT
72 71
 #endif // ARDUINO_ARCH_ESP32

+ 2
- 2
Marlin/src/HAL/HAL_ESP32/spiffs.cpp Ver fichero

@@ -24,7 +24,7 @@
24 24
 
25 25
 #include "../../inc/MarlinConfigPre.h"
26 26
 
27
-#if ENABLED(WEBSUPPORT)
27
+#if BOTH(WIFISUPPORT, WEBSUPPORT)
28 28
 
29 29
 #include "../../core/serial.h"
30 30
 
@@ -40,5 +40,5 @@ void spiffs_init() {
40 40
     SERIAL_ERROR_MSG("SPIFFS mount failed");
41 41
 }
42 42
 
43
-#endif // WEBSUPPORT
43
+#endif // WIFISUPPORT && WEBSUPPORT
44 44
 #endif // ARDUINO_ARCH_ESP32

+ 1
- 1
Marlin/src/HAL/HAL_ESP32/timers.h Ver fichero

@@ -47,7 +47,7 @@ typedef uint64_t hal_timer_t;
47 47
 
48 48
 #if ENABLED(I2S_STEPPER_STREAM)
49 49
   #define STEPPER_TIMER_PRESCALE     1
50
-  #define STEPPER_TIMER_RATE         250000                           // 250khz, 4us pulses of i2s word clock
50
+  #define STEPPER_TIMER_RATE         250000                           // 250khz, 4µs pulses of i2s word clock
51 51
   #define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per µs // wrong would be 0.25
52 52
 #else
53 53
   #define STEPPER_TIMER_PRESCALE     40

+ 4
- 5
Marlin/src/HAL/HAL_ESP32/web.cpp Ver fichero

@@ -22,13 +22,12 @@
22 22
 
23 23
 #ifdef ARDUINO_ARCH_ESP32
24 24
 
25
-#include <SPIFFS.h>
26
-#undef DISABLED  // esp32-hal-gpio.h
27
-
28 25
 #include "../../inc/MarlinConfigPre.h"
29 26
 
30
-#if ENABLED(WEBSUPPORT)
27
+#if BOTH(WIFISUPPORT, WEBSUPPORT)
31 28
 
29
+#undef DISABLED  // esp32-hal-gpio.h
30
+#include <SPIFFS.h>
32 31
 #include "wifi.h"
33 32
 
34 33
 AsyncEventSource events("/events"); // event source (Server-Sent events)
@@ -43,5 +42,5 @@ void web_init() {
43 42
   server.onNotFound(onNotFound);
44 43
 }
45 44
 
46
-#endif // WEBSUPPORT
45
+#endif // WIFISUPPORT && WEBSUPPORT
47 46
 #endif // ARDUINO_ARCH_ESP32

+ 1
- 1
Marlin/src/HAL/HAL_LINUX/HAL.cpp Ver fichero

@@ -55,7 +55,7 @@ void HAL_adc_init() {
55 55
 
56 56
 }
57 57
 
58
-void HAL_adc_enable_channel(int ch) {
58
+void HAL_adc_enable_channel(const uint8_t ch) {
59 59
 
60 60
 }
61 61
 

+ 7
- 7
Marlin/src/HAL/HAL_LINUX/HAL.h Ver fichero

@@ -87,15 +87,15 @@ int freeMemory();
87 87
 #pragma GCC diagnostic pop
88 88
 
89 89
 // ADC
90
-#define HAL_ANALOG_SELECT(pin) HAL_adc_enable_channel(pin)
91
-#define HAL_START_ADC(pin)     HAL_adc_start_conversion(pin)
92
-#define HAL_ADC_RESOLUTION     10
93
-#define HAL_READ_ADC()         HAL_adc_get_result()
94
-#define HAL_ADC_READY()        true
90
+#define HAL_ANALOG_SELECT(ch) HAL_adc_enable_channel(ch)
91
+#define HAL_START_ADC(ch)     HAL_adc_start_conversion(ch)
92
+#define HAL_ADC_RESOLUTION    10
93
+#define HAL_READ_ADC()        HAL_adc_get_result()
94
+#define HAL_ADC_READY()       true
95 95
 
96 96
 void HAL_adc_init();
97
-void HAL_adc_enable_channel(int pin);
98
-void HAL_adc_start_conversion(const uint8_t adc_pin);
97
+void HAL_adc_enable_channel(const uint8_t ch);
98
+void HAL_adc_start_conversion(const uint8_t ch);
99 99
 uint16_t HAL_adc_get_result();
100 100
 
101 101
 // Reset source

+ 4
- 0
Marlin/src/HAL/HAL_LINUX/inc/SanityCheck.h Ver fichero

@@ -33,3 +33,7 @@
33 33
 #if ENABLED(FAST_PWM_FAN)
34 34
   #error "FAST_PWM_FAN is not yet implemented for this platform."
35 35
 #endif
36
+
37
+#if TMC_HAS_SW_SERIAL
38
+  #error "TMC220x Software Serial is not supported on this platform."
39
+#endif

+ 28
- 11
Marlin/src/HAL/HAL_LPC1768/HAL.h Ver fichero

@@ -61,10 +61,6 @@ extern "C" volatile uint32_t _millis;
61 61
   #define ST7920_DELAY_3 DELAY_NS(750)
62 62
 #endif
63 63
 
64
-#if !WITHIN(SERIAL_PORT, -1, 3)
65
-  #error "SERIAL_PORT must be from -1 to 3"
66
-#endif
67
-
68 64
 #if SERIAL_PORT == -1
69 65
   #define MYSERIAL0 UsbSerial
70 66
 #elif SERIAL_PORT == 0
@@ -75,16 +71,14 @@ extern "C" volatile uint32_t _millis;
75 71
   #define MYSERIAL0 MSerial2
76 72
 #elif SERIAL_PORT == 3
77 73
   #define MYSERIAL0 MSerial3
74
+#else
75
+  #error "SERIAL_PORT must be from -1 to 3. Please update your configuration."
78 76
 #endif
79 77
 
80 78
 #ifdef SERIAL_PORT_2
81
-  #if !WITHIN(SERIAL_PORT_2, -1, 3)
82
-    #error "SERIAL_PORT_2 must be from -1 to 3"
83
-  #elif SERIAL_PORT_2 == SERIAL_PORT
84
-    #error "SERIAL_PORT_2 must be different than SERIAL_PORT"
85
-  #endif
86
-  #define NUM_SERIAL 2
87
-  #if SERIAL_PORT_2 == -1
79
+  #if SERIAL_PORT_2 == SERIAL_PORT
80
+    #error "SERIAL_PORT_2 must be different than SERIAL_PORT. Please update your configuration."
81
+  #elif SERIAL_PORT_2 == -1
88 82
     #define MYSERIAL1 UsbSerial
89 83
   #elif SERIAL_PORT_2 == 0
90 84
     #define MYSERIAL1 MSerial
@@ -94,11 +88,34 @@ extern "C" volatile uint32_t _millis;
94 88
     #define MYSERIAL1 MSerial2
95 89
   #elif SERIAL_PORT_2 == 3
96 90
     #define MYSERIAL1 MSerial3
91
+  #else
92
+    #error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration."
97 93
   #endif
94
+  #define NUM_SERIAL 2
98 95
 #else
99 96
   #define NUM_SERIAL 1
100 97
 #endif
101 98
 
99
+#ifdef DGUS_SERIAL_PORT
100
+  #if DGUS_SERIAL_PORT == SERIAL_PORT
101
+    #error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration."
102
+  #elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
103
+    #error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
104
+  #elif DGUS_SERIAL_PORT == -1
105
+    #define DGUS_SERIAL UsbSerial
106
+  #elif DGUS_SERIAL_PORT == 0
107
+    #define DGUS_SERIAL MSerial
108
+  #elif DGUS_SERIAL_PORT == 1
109
+    #define DGUS_SERIAL MSerial1
110
+  #elif DGUS_SERIAL_PORT == 2
111
+    #define DGUS_SERIAL MSerial2
112
+  #elif DGUS_SERIAL_PORT == 3
113
+    #define DGUS_SERIAL MSerial3
114
+  #else
115
+    #error "DGUS_SERIAL_PORT must be from -1 to 3. Please update your configuration."
116
+  #endif
117
+#endif
118
+
102 119
 //
103 120
 // Interrupts
104 121
 //

+ 13
- 1
Marlin/src/HAL/HAL_LPC1768/endstop_interrupts.h Ver fichero

@@ -93,7 +93,7 @@ void setup_endstop_interrupts() {
93 93
     _ATTACH(Z2_MIN_PIN);
94 94
   #endif
95 95
   #if HAS_Z3_MAX
96
-    #if !LPC1768_PIN_INTERRUPT_M(Z3_MIN_PIN)
96
+    #if !LPC1768_PIN_INTERRUPT_M(Z3_MAX_PIN)
97 97
       #error "Z3_MIN_PIN is not INTERRUPT-capable."
98 98
     #endif
99 99
     _ATTACH(Z3_MAX_PIN);
@@ -104,6 +104,18 @@ void setup_endstop_interrupts() {
104 104
     #endif
105 105
     _ATTACH(Z3_MIN_PIN);
106 106
   #endif
107
+  #if HAS_Z4_MAX
108
+    #if !LPC1768_PIN_INTERRUPT_M(Z4_MAX_PIN)
109
+      #error "Z4_MIN_PIN is not INTERRUPT-capable."
110
+    #endif
111
+    _ATTACH(Z4_MAX_PIN);
112
+  #endif
113
+  #if HAS_Z4_MIN
114
+    #if !LPC1768_PIN_INTERRUPT_M(Z4_MIN_PIN)
115
+      #error "Z4_MIN_PIN is not INTERRUPT-capable."
116
+    #endif
117
+    _ATTACH(Z4_MIN_PIN);
118
+  #endif
107 119
   #if HAS_Z_MIN_PROBE_PIN
108 120
     #if !LPC1768_PIN_INTERRUPT_M(Z_MIN_PROBE_PIN)
109 121
       #error "Z_MIN_PROBE_PIN is not INTERRUPT-capable."

+ 4
- 0
Marlin/src/HAL/HAL_LPC1768/inc/SanityCheck.h Ver fichero

@@ -46,6 +46,10 @@
46 46
   #error "TEMP_4_PIN must be defined using the Pn_nn or Pn_nn_An format. (See the included pins files)."
47 47
 #elif _OLD_TEMP_PIN(TEMP_5)
48 48
   #error "TEMP_5_PIN must be defined using the Pn_nn or Pn_nn_An format. (See the included pins files)."
49
+#elif _OLD_TEMP_PIN(TEMP_6)
50
+  #error "TEMP_6_PIN must be defined using the Pn_nn or Pn_nn_An format. (See the included pins files)."
51
+#elif _OLD_TEMP_PIN(TEMP_7)
52
+  #error "TEMP_7_PIN must be defined using the Pn_nn or Pn_nn_An format. (See the included pins files)."
49 53
 #endif
50 54
 #undef _OLD_TEMP_PIN
51 55
 

+ 6
- 40
Marlin/src/HAL/HAL_LPC1768/include/digipot_mcp4451_I2C_routines.c Ver fichero

@@ -20,8 +20,10 @@
20 20
  *
21 21
  */
22 22
 
23
-// adapted from  I2C/master/master.c example
24
-//   https://www-users.cs.york.ac.uk/~pcc/MCP/HAPR-Course-web/CMSIS/examples/html/master_8c_source.html
23
+/**
24
+ * digipot_mcp4451_I2C_routines.c
25
+ * Adapted from https://www-users.cs.york.ac.uk/~pcc/MCP/HAPR-Course-web/CMSIS/examples/html/master_8c_source.html
26
+ */
25 27
 
26 28
 #ifdef TARGET_LPC1768
27 29
 
@@ -29,12 +31,12 @@
29 31
 
30 32
 #if MB(MKS_SBASE)
31 33
 
32
-#include "digipot_mcp4451_I2C_routines.h"
33
-
34 34
 #ifdef __cplusplus
35 35
   extern "C" {
36 36
 #endif
37 37
 
38
+#include "digipot_mcp4451_I2C_routines.h"
39
+
38 40
 // These two routines are exact copies of the lpc17xx_i2c.c routines.  Couldn't link to
39 41
 // to the lpc17xx_i2c.c routines so had to copy them into this file & rename them.
40 42
 
@@ -60,7 +62,6 @@ static void _I2C_Stop(LPC_I2C_TypeDef *I2Cx) {
60 62
   I2Cx->I2CONCLR = I2C_I2CONCLR_SIC;
61 63
 }
62 64
 
63
-PINSEL_CFG_Type PinCfg;
64 65
 I2C_M_SETUP_Type transferMCfg;
65 66
 
66 67
 #define I2C_status (LPC_I2C1->I2STAT & I2C_STAT_CODE_BITMASK)
@@ -89,41 +90,6 @@ uint8_t digipot_mcp4451_start(uint8_t sla) {  // send slave address and write bi
89 90
   return 1;
90 91
 }
91 92
 
92
-void digipot_mcp4451_init() {
93
-  /**
94
-   * Init I2C pin connect
95
-   */
96
-  PinCfg.OpenDrain = 0;
97
-  PinCfg.Pinmode = 0;
98
-  #if USEDI2CDEV_M == 0
99
-    PinCfg.Funcnum = 1;
100
-    PinCfg.Pinnum = 27;
101
-    PinCfg.Portnum = 0;
102
-    PINSEL_ConfigPin(&PinCfg); // SDA0 / D57  AUX-1
103
-    PinCfg.Pinnum = 28;
104
-    PINSEL_ConfigPin(&PinCfg); // SCL0 / D58  AUX-1
105
-  #elif USEDI2CDEV_M == 1
106
-    PinCfg.Funcnum = 3;
107
-    PinCfg.Pinnum = 0;
108
-    PinCfg.Portnum = 0;
109
-    PINSEL_ConfigPin(&PinCfg);  // SDA1 / D20 SCA
110
-    PinCfg.Pinnum = 1;
111
-    PINSEL_ConfigPin(&PinCfg);  // SCL1 / D21 SCL
112
-  #elif USEDI2CDEV_M == 2
113
-    PinCfg.Funcnum = 2;
114
-    PinCfg.Pinnum = 10;
115
-    PinCfg.Portnum = 0;
116
-    PINSEL_ConfigPin(&PinCfg); // SDA2 / D38  X_ENABLE_PIN
117
-    PinCfg.Pinnum = 11;
118
-    PINSEL_ConfigPin(&PinCfg); // SCL2 / D55  X_DIR_PIN
119
-  #endif
120
-  // Initialize I2C peripheral
121
-  I2C_Init(I2CDEV_M, 400000);  // hardwired to 400KHz bit rate, 100KHz is the other option
122
-
123
-  // Enable Master I2C operation
124
-  I2C_Cmd(I2CDEV_M, I2C_MASTER_MODE, ENABLE);
125
-}
126
-
127 93
 uint8_t digipot_mcp4451_send_byte(uint8_t data) {
128 94
   LPC_I2C1->I2DAT = data & I2C_I2DAT_BITMASK; // transmit data
129 95
   LPC_I2C1->I2CONSET = I2C_I2CONSET_AA;

+ 5
- 15
Marlin/src/HAL/HAL_LPC1768/include/digipot_mcp4451_I2C_routines.h Ver fichero

@@ -21,20 +21,10 @@
21 21
  */
22 22
 #pragma once
23 23
 
24
-// adapted from  I2C/master/master.c example
25
-//   https://www-users.cs.york.ac.uk/~pcc/MCP/HAPR-Course-web/CMSIS/examples/html/master_8c_source.html
26
-
27
-#define USEDI2CDEV_M  1  // use I2C1 controller
28
-
29
-#if USEDI2CDEV_M == 0
30
-  #define I2CDEV_M LPC_I2C0
31
-#elif USEDI2CDEV_M == 1
32
-  #define I2CDEV_M LPC_I2C1
33
-#elif USEDI2CDEV_M == 2
34
-  #define I2CDEV_M LPC_I2C2
35
-#else
36
-  #error "Master I2C device not defined!"
37
-#endif
24
+/**
25
+ * digipot_mcp4451_I2C_routines.h
26
+ * Adapted from https://www-users.cs.york.ac.uk/~pcc/MCP/HAPR-Course-web/CMSIS/examples/html/master_8c_source.html
27
+ */
38 28
 
39 29
 #ifdef __cplusplus
40 30
   extern "C" {
@@ -43,9 +33,9 @@
43 33
 #include <lpc17xx_i2c.h>
44 34
 #include <lpc17xx_pinsel.h>
45 35
 #include <lpc17xx_libcfg_default.h>
36
+#include "i2c_util.h"
46 37
 
47 38
 uint8_t digipot_mcp4451_start(uint8_t sla);
48
-void digipot_mcp4451_init();
49 39
 uint8_t digipot_mcp4451_send_byte(uint8_t data);
50 40
 
51 41
 #ifdef __cplusplus

+ 70
- 0
Marlin/src/HAL/HAL_LPC1768/include/i2c_util.c Ver fichero

@@ -0,0 +1,70 @@
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
+ * HAL_LPC1768/include/i2c_util.c
25
+ */
26
+
27
+#ifdef TARGET_LPC1768
28
+
29
+#include "i2c_util.h"
30
+
31
+#define U8G_I2C_OPT_FAST 16  // from u8g.h
32
+
33
+#ifdef __cplusplus
34
+  extern "C" {
35
+#endif
36
+
37
+void configure_i2c(const uint8_t clock_option) {
38
+  /**
39
+   * Init I2C pin connect
40
+   */
41
+  PINSEL_CFG_Type PinCfg;
42
+  PinCfg.OpenDrain = 0;
43
+  PinCfg.Pinmode = 0;
44
+  PinCfg.Portnum = 0;
45
+  #if I2C_MASTER_ID == 0
46
+    PinCfg.Funcnum = 1;
47
+    PinCfg.Pinnum = 27;     // SDA0 / D57  AUX-1 ... SCL0 / D58  AUX-1
48
+  #elif I2C_MASTER_ID == 1
49
+    PinCfg.Funcnum = 3;
50
+    PinCfg.Pinnum = 0;      // SDA1 / D20 SCA ... SCL1 / D21 SCL
51
+  #elif I2C_MASTER_ID == 2
52
+    PinCfg.Funcnum = 2;
53
+    PinCfg.Pinnum = 10;     // SDA2 / D38  X_ENABLE_PIN ... SCL2 / D55  X_DIR_PIN
54
+  #endif
55
+  PINSEL_ConfigPin(&PinCfg);
56
+  PinCfg.Pinnum += 1;
57
+  PINSEL_ConfigPin(&PinCfg);
58
+
59
+  // Initialize I2C peripheral
60
+  I2C_Init(I2CDEV_M, (clock_option & U8G_I2C_OPT_FAST) ? 400000: 100000);  // LCD data rates
61
+
62
+  // Enable Master I2C operation
63
+  I2C_Cmd(I2CDEV_M, I2C_MASTER_MODE, ENABLE);
64
+}
65
+
66
+#ifdef __cplusplus
67
+  }
68
+#endif
69
+
70
+#endif // TARGET_LPC1768

+ 56
- 0
Marlin/src/HAL/HAL_LPC1768/include/i2c_util.h Ver fichero

@@ -0,0 +1,56 @@
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
+#pragma once
23
+
24
+/**
25
+ * HAL_LPC1768/include/i2c_util.h
26
+ */
27
+
28
+#include "../../../inc/MarlinConfigPre.h"
29
+
30
+#ifndef I2C_MASTER_ID
31
+  #define I2C_MASTER_ID 1
32
+#endif
33
+
34
+#if I2C_MASTER_ID == 0
35
+  #define I2CDEV_M LPC_I2C0
36
+#elif I2C_MASTER_ID == 1
37
+  #define I2CDEV_M LPC_I2C1
38
+#elif I2C_MASTER_ID == 2
39
+  #define I2CDEV_M LPC_I2C2
40
+#else
41
+  #error "Master I2C device not defined!"
42
+#endif
43
+
44
+#include <lpc17xx_i2c.h>
45
+#include <lpc17xx_pinsel.h>
46
+#include <lpc17xx_libcfg_default.h>
47
+
48
+#ifdef __cplusplus
49
+  extern "C" {
50
+#endif
51
+
52
+void configure_i2c(const uint8_t clock_option);
53
+
54
+#ifdef __cplusplus
55
+  }
56
+#endif

+ 9
- 62
Marlin/src/HAL/HAL_LPC1768/u8g/LCD_I2C_routines.cpp Ver fichero

@@ -25,25 +25,21 @@
25 25
 
26 26
 #ifdef TARGET_LPC1768
27 27
 
28
+#include "../include/i2c_util.h"
29
+#include "../../../core/millis_t.h"
30
+
28 31
 extern int millis();
29 32
 
30 33
 #ifdef __cplusplus
31 34
   extern "C" {
32 35
 #endif
33 36
 
34
-#include <lpc17xx_i2c.h>
35
-#include <lpc17xx_pinsel.h>
36
-#include <lpc17xx_libcfg_default.h>
37
-
38
-#include "../../../core/millis_t.h"
39
-
40
-
41 37
 //////////////////////////////////////////////////////////////////////////////////////
42 38
 
43 39
 // These two routines are exact copies of the lpc17xx_i2c.c routines.  Couldn't link to
44 40
 // to the lpc17xx_i2c.c routines so had to copy them into this file & rename them.
45 41
 
46
-static uint32_t _I2C_Start (LPC_I2C_TypeDef *I2Cx) {
42
+static uint32_t _I2C_Start(LPC_I2C_TypeDef *I2Cx) {
47 43
   // Reset STA, STO, SI
48 44
   I2Cx->I2CONCLR = I2C_I2CONCLR_SIC|I2C_I2CONCLR_STOC|I2C_I2CONCLR_STAC;
49 45
 
@@ -67,30 +63,16 @@ static void _I2C_Stop (LPC_I2C_TypeDef *I2Cx) {
67 63
 
68 64
 //////////////////////////////////////////////////////////////////////////////////////
69 65
 
70
-#define U8G_I2C_OPT_FAST 16  // from u8g.h
71
-
72
-#define USEDI2CDEV_M            1
73
-
74 66
 #define I2CDEV_S_ADDR   0x78  // from SSD1306  //actual address is 0x3C - shift left 1 with LSB set to 0 to indicate write
75 67
 
76 68
 #define BUFFER_SIZE                     0x1  // only do single byte transfers with LCDs
77 69
 
78
-#if (USEDI2CDEV_M == 0)
79
-  #define I2CDEV_M LPC_I2C0
80
-#elif (USEDI2CDEV_M == 1)
81
-  #define I2CDEV_M LPC_I2C1
82
-#elif (USEDI2CDEV_M == 2)
83
-  #define I2CDEV_M LPC_I2C2
84
-#else
85
-  #error "Master I2C device not defined!"
86
-#endif
87
-
88
-PINSEL_CFG_Type PinCfg;
89 70
 I2C_M_SETUP_Type transferMCfg;
90 71
 
91 72
 #define I2C_status (LPC_I2C1->I2STAT & I2C_STAT_CODE_BITMASK)
92 73
 
93
-uint8_t u8g_i2c_start(uint8_t sla) {  // send slave address and write bit
74
+// Send slave address and write bit
75
+uint8_t u8g_i2c_start(const uint8_t sla) {
94 76
   // Sometimes TX data ACK or NAK status is returned.  That mean the start state didn't
95 77
   // happen which means only the value of the slave address was send.  Keep looping until
96 78
   // the slave address and write bit are actually sent.
@@ -114,44 +96,9 @@ uint8_t u8g_i2c_start(uint8_t sla) {  // send slave address and write bit
114 96
   return 1;
115 97
 }
116 98
 
117
-void u8g_i2c_init(uint8_t clock_option) {
118
-
119
-  /**
120
-   * Init I2C pin connect
121
-   */
122
-  PinCfg.OpenDrain = 0;
123
-  PinCfg.Pinmode = 0;
124
-  #if ((USEDI2CDEV_M == 0))
125
-    PinCfg.Funcnum = 1;
126
-    PinCfg.Pinnum = 27;
127
-    PinCfg.Portnum = 0;
128
-    PINSEL_ConfigPin(&PinCfg); // SDA0 / D57  AUX-1
129
-    PinCfg.Pinnum = 28;
130
-    PINSEL_ConfigPin(&PinCfg); // SCL0 / D58  AUX-1
131
-  #endif
132
-  #if ((USEDI2CDEV_M == 1))
133
-    PinCfg.Funcnum = 3;
134
-    PinCfg.Pinnum = 0;
135
-    PinCfg.Portnum = 0;
136
-    PINSEL_ConfigPin(&PinCfg);  // SDA1 / D20 SCA
137
-    PinCfg.Pinnum = 1;
138
-    PINSEL_ConfigPin(&PinCfg);  // SCL1 / D21 SCL
139
-  #endif
140
-  #if ((USEDI2CDEV_M == 2))
141
-    PinCfg.Funcnum = 2;
142
-    PinCfg.Pinnum = 10;
143
-    PinCfg.Portnum = 0;
144
-    PINSEL_ConfigPin(&PinCfg); // SDA2 / D38  X_ENABLE_PIN
145
-    PinCfg.Pinnum = 11;
146
-    PINSEL_ConfigPin(&PinCfg); // SCL2 / D55  X_DIR_PIN
147
-  #endif
148
-  // Initialize I2C peripheral
149
-  I2C_Init(I2CDEV_M, (clock_option & U8G_I2C_OPT_FAST) ? 400000: 100000);  // LCD data rates
150
-
151
-  // Enable Master I2C operation
152
-  I2C_Cmd(I2CDEV_M, I2C_MASTER_MODE, ENABLE);
153
-
154
-  u8g_i2c_start(0); // send slave address and write bit
99
+void u8g_i2c_init(const uint8_t clock_option) {
100
+  configure_i2c(clock_option);
101
+  u8g_i2c_start(0); // Send slave address and write bit
155 102
 }
156 103
 
157 104
 uint8_t u8g_i2c_send_byte(uint8_t data) {

+ 2
- 2
Marlin/src/HAL/HAL_LPC1768/u8g/LCD_I2C_routines.h Ver fichero

@@ -21,8 +21,8 @@
21 21
  */
22 22
 #pragma once
23 23
 
24
-void u8g_i2c_init(uint8_t options);
25
-uint8_t u8g_i2c_wait(uint8_t mask, uint8_t pos);
24
+void u8g_i2c_init(const uint8_t clock_options);
25
+//uint8_t u8g_i2c_wait(uint8_t mask, uint8_t pos);
26 26
 uint8_t u8g_i2c_start(uint8_t sla);
27 27
 uint8_t u8g_i2c_send_byte(uint8_t data);
28 28
 void u8g_i2c_stop();

+ 2
- 2
Marlin/src/HAL/HAL_LPC1768/u8g/LCD_delay.h Ver fichero

@@ -26,8 +26,8 @@
26 26
  *
27 27
  * These are based on the LPC1768 routines.
28 28
  *
29
- * Couldn't just call exact copies because the overhead resulted in the
30
- * one microsecond delay being about 4uS.
29
+ * Couldn't just call exact copies because the overhead
30
+ * results in a one microsecond delay taking about 4µS.
31 31
  */
32 32
 
33 33
 #ifdef __cplusplus

+ 0
- 2
Marlin/src/HAL/HAL_LPC1768/u8g/u8g_com_HAL_LPC1768_ssd_hw_i2c.cpp Ver fichero

@@ -86,8 +86,6 @@
86 86
 #define I2C_CMD_MODE    0x000
87 87
 #define I2C_DATA_MODE   0x040
88 88
 
89
-//#define U8G_I2C_OPT_FAST 16
90
-
91 89
 uint8_t u8g_com_ssd_I2C_start_sequence(u8g_t *u8g) {
92 90
   /* are we requested to set the a0 state? */
93 91
   if (u8g->pin_list[U8G_PI_SET_A0] == 0) return 1;

+ 0
- 254
Marlin/src/HAL/HAL_LPC1768/u8g/u8g_com_HAL_LPC1768_ssd_sw_i2c.cpp under construction Ver fichero

@@ -1,254 +0,0 @@
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 U8G2 code - u8x8_byte.c
25
- *
26
- * Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
27
- *
28
- * Copyright (c) 2016, 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
-/**
57
- * Software i2c,
58
- * ignores ACK response (which is anyway not provided by some displays)
59
- * also does not allow reading from the device
60
- */
61
-
62
-#ifdef TARGET_LPC1768
63
-
64
-#include "../../inc/MarlinConfigPre.h"
65
-
66
-#if HAS_GRAPHICAL_LCD
67
-
68
-#include <U8glib.h>
69
-
70
-//void pinMode(int16_t pin, uint8_t mode);
71
-//void digitalWrite(int16_t pin, uint8_t pin_status);
72
-
73
-
74
-#define I2C_SLA         (0x3C*2)
75
-//#define I2C_CMD_MODE  0x080
76
-#define I2C_CMD_MODE    0x000
77
-#define I2C_DATA_MODE   0x040
78
-
79
-//static uint8_t I2C_speed; // 3 - 400KHz, 13 - 100KHz
80
-//#define SPEED_400KHz 3
81
-//#define SPEED_100KHz 13
82
-
83
-//    #define U8G_I2C_OPT_FAST 16
84
-
85
-uint8_t SCL_pin_HAL_LPC1768_sw_I2C, SCL_port_HAL_LPC1768_sw_I2C, SDA_pin_HAL_LPC1768_sw_I2C, SDA_port_HAL_LPC1768_sw_I2C;
86
-
87
-#define SPI_SPEED 2  //20: 200KHz 5:750KHz 2:3-4MHz
88
-
89
-uint8_t u8g_i2c_send_byte_sw(uint8_t data) {
90
-  for (uint8_t i = 0; i < 9; i++) {   // 1 extra bit for the ack/nak
91
-
92
-    if (val & 0x80)
93
-      for (uint8_t j = 0; j < SPI_SPEED; j++) {
94
-        LPC_GPIO(SDA_port_HAL_LPC1768_sw_I2C)->FIOSET = LPC_PIN(SDA_pin_HAL_LPC1768_sw_I2C);
95
-        LPC_GPIO(SDA_port_HAL_LPC1768_sw_I2C)->FIOSET = LPC_PIN(SDA_pin_HAL_LPC1768_sw_I2C);
96
-        LPC_GPIO(SDA_port_HAL_LPC1768_sw_I2C)->FIOSET = LPC_PIN(SDA_pin_HAL_LPC1768_sw_I2C);
97
-      }
98
-    else
99
-      for (uint8_t j = 0; j < SPI_SPEED; j++) {
100
-        LPC_GPIO(SDA_port_HAL_LPC1768_sw_I2C)->FIOCLR = LPC_PIN(SDA_pin_HAL_LPC1768_sw_I2C);
101
-        LPC_GPIO(SDA_port_HAL_LPC1768_sw_I2C)->FIOCLR = LPC_PIN(SDA_pin_HAL_LPC1768_sw_I2C);
102
-        LPC_GPIO(SDA_port_HAL_LPC1768_sw_I2C)->FIOCLR = LPC_PIN(SDA_pin_HAL_LPC1768_sw_I2C);
103
-      }
104
-
105
-    for (uint8_t j = 0; j < SPI_SPEED; j++) {
106
-      LPC_GPIO(SCL_port_HAL_LPC1768_sw_I2C)->FIOSET = LPC_PIN(SCL_pin_HAL_LPC1768_sw_I2C);
107
-      LPC_GPIO(SCL_port_HAL_LPC1768_sw_I2C)->FIOSET = LPC_PIN(SCL_pin_HAL_LPC1768_sw_I2C);
108
-      LPC_GPIO(SCL_port_HAL_LPC1768_sw_I2C)->FIOSET = LPC_PIN(SCL_pin_HAL_LPC1768_sw_I2C);
109
-      LPC_GPIO(SCL_port_HAL_LPC1768_sw_I2C)->FIOSET = LPC_PIN(SCL_pin_HAL_LPC1768_sw_I2C);
110
-      LPC_GPIO(SCL_port_HAL_LPC1768_sw_I2C)->FIOSET = LPC_PIN(SCL_pin_HAL_LPC1768_sw_I2C);
111
-    }
112
-
113
-    for (uint8_t j = 0; j < SPI_SPEED; j++) {
114
-      LPC_GPIO(SCL_port_HAL_LPC1768_sw_I2C)->FIOCLR = LPC_PIN(SCL_pin_HAL_LPC1768_sw_I2C);
115
-      LPC_GPIO(SCL_port_HAL_LPC1768_sw_I2C)->FIOCLR = LPC_PIN(SCL_pin_HAL_LPC1768_sw_I2C);
116
-    }
117
-    val <<= 1;
118
-  }
119
-  return 1;
120
-}
121
-
122
-
123
-uint8_t u8g_i2c_start_sw(uint8_t sla) {  // assert start condition and then send slave address with write bit
124
-  /* send the start condition, both lines go from 1 to 0 */
125
-
126
-  LPC_GPIO(SDA_port_HAL_LPC1768_sw_I2C)->FIOCLR = LPC_PIN(SDA_pin_HAL_LPC1768_sw_I2C);
127
-  LPC_GPIO(SCL_port_HAL_LPC1768_sw_I2C)->FIOCLR = LPC_PIN(SCL_pin_HAL_LPC1768_sw_I2C);
128
-  DELAY_US(2);
129
-  LPC_GPIO(SCL_port_HAL_LPC1768_sw_I2C)->FIOSET = LPC_PIN(SCL_pin_HAL_LPC1768_sw_I2C);
130
-  DELAY_US(2);
131
-  LPC_GPIO(SDA_port_HAL_LPC1768_sw_I2C)->FIOSET = LPC_PIN(SDA_pin_HAL_LPC1768_sw_I2C);
132
-  DELAY_US(2);
133
-  LPC_GPIO(SDA_port_HAL_LPC1768_sw_I2C)->FIOCLR = LPC_PIN(SDA_pin_HAL_LPC1768_sw_I2C);
134
-  DELAY_US(2);
135
-  LPC_GPIO(SCL_port_HAL_LPC1768_sw_I2C)->FIOCLR = LPC_PIN(SCL_pin_HAL_LPC1768_sw_I2C);
136
-
137
-  u8g_i2c_send_byte_sw(I2C_SLA);  // send slave address with write bit
138
-}
139
-
140
-
141
-void u8g_i2c_stop_sw() { }
142
-
143
-void u8g_i2c_init_sw(uint8_t clock_option) { u8g_i2c_start(0); } // send slave address and write bit
144
-
145
-uint8_t  u8g_com_ssd_I2C_start_sequence_sw(u8g_t *u8g) {
146
-  /* are we requested to set the a0 state? */
147
-  if (u8g->pin_list[U8G_PI_SET_A0] == 0) return 1;
148
-
149
-  /* setup bus, might be a repeated start */
150
-  if (u8g_i2c_start(I2C_SLA) == 0) return 0;
151
-  if (u8g->pin_list[U8G_PI_A0_STATE] == 0) {
152
-    if (u8g_i2c_send_byte(I2C_CMD_MODE) == 0) return 0;
153
-  }
154
-  else if (u8g_i2c_send_byte(I2C_DATA_MODE) == 0) return 0;
155
-
156
-  u8g->pin_list[U8G_PI_SET_A0] = 0;
157
-
158
-  return 1;
159
-}
160
-
161
-uint8_t u8g_com_HAL_LPC1768_ssd_sw_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) {
162
-  switch (msg) {
163
-    case U8G_COM_MSG_INIT:
164
-
165
-      #define LPC1768_PIN_PORT(pin) ((uint8_t)((pin >> 5) & 0b111))
166
-      #define LPC1768_PIN_PIN(pin) ((uint8_t)(pin & 0b11111))
167
-      SCL_pin_HAL_LPC1768_sw_I2C = LPC1768_PIN_PIN(u8g->pin_list[U8G_PI_SCL]);
168
-      SCL_port_HAL_LPC1768_sw_I2C = LPC1768_PIN_PORT(u8g->pin_list[U8G_PI_SCL]);
169
-      SDA_pin_HAL_LPC1768_sw_I2C = LPC1768_PIN_PIN(u8g->pin_list[U8G_PI_SDA]);
170
-      SDA_port_HAL_LPC1768_sw_I2C = LPC1768_PIN_PORT(u8g->pin_list[U8G_PI_SDA]);
171
-      // As defined by Arduino INPUT(0x0), OUTPUT(0x1), INPUT_PULLUP(0x2)
172
-      #define OUTPUT 0x1
173
-      u8g_SetPIOutput(u8g, U8G_PI_SCL);
174
-      u8g_SetPIOutput(u8g, U8G_PI_SDA);
175
-      if (U8G_PIN_NONE != u8g->pin_list[U8G_PI_CS])  u8g_SetPIOutput(u8g, U8G_PI_CS);
176
-      if (U8G_PIN_NONE != u8g->pin_list[U8G_PI_A0])  u8g_SetPIOutput(u8g, U8G_PI_A0);
177
-      if (U8G_PIN_NONE != u8g->pin_list[U8G_PI_RESET])  u8g_SetPIOutput(u8g, U8G_PI_RESET);
178
-
179
-      //u8g_com_arduino_digital_write(u8g, U8G_PI_SCL, HIGH);
180
-      //u8g_com_arduino_digital_write(u8g, U8G_PI_SDA, HIGH);
181
-      //u8g->pin_list[U8G_PI_A0_STATE] = 0;       /* initial RS state: unknown mode */
182
-
183
-      u8g_i2c_init_sw(u8g->pin_list[U8G_PI_I2C_OPTION]);
184
-      u8g_com_ssd_I2C_start_sequence_sw(u8g);
185
-      break;
186
-
187
-    case U8G_COM_MSG_STOP: break;
188
-
189
-    case U8G_COM_MSG_RESET: break;
190
-
191
-    case U8G_COM_MSG_CHIP_SELECT:
192
-      u8g->pin_list[U8G_PI_A0_STATE] = 0;
193
-      u8g->pin_list[U8G_PI_SET_A0] = 1;   /* force a0 to set again, also forces start condition */
194
-      if (arg_val == 0) {
195
-        /* disable chip, send stop condition */
196
-        u8g_i2c_stop_sw();
197
-      }
198
-      else {
199
-        /* enable, do nothing: any byte writing will trigger the i2c start */
200
-      }
201
-      break;
202
-
203
-    case U8G_COM_MSG_WRITE_BYTE:
204
-      //u8g->pin_list[U8G_PI_SET_A0] = 1;
205
-      //if (u8g_com_arduino_ssd_start_sequence(u8g) == 0)
206
-      //  return u8g_i2c_stop(), 0;
207
-      if (u8g_i2c_send_byte_sw(arg_val) == 0)
208
-        return u8g_i2c_stop_sw(), 0;
209
-        // u8g_i2c_stop();
210
-      break;
211
-
212
-    case U8G_COM_MSG_WRITE_SEQ: {
213
-      //u8g->pin_list[U8G_PI_SET_A0] = 1;
214
-      if (u8g_com_ssd_I2C_start_sequence_sw(u8g) == 0)
215
-        return u8g_i2c_stop_sw(), 0;
216
-
217
-        uint8_t *ptr = (uint8_t *)arg_ptr;
218
-        while (arg_val > 0) {
219
-          if (u8g_i2c_send_byte_sw(*ptr++) == 0)
220
-            return u8g_i2c_stop_sw(), 0;
221
-          arg_val--;
222
-        }
223
-      }
224
-      // u8g_i2c_stop();
225
-      break;
226
-
227
-    case U8G_COM_MSG_WRITE_SEQ_P: {
228
-      //u8g->pin_list[U8G_PI_SET_A0] = 1;
229
-      if (u8g_com_ssd_I2C_start_sequence_sw(u8g) == 0)
230
-        return u8g_i2c_stop_sw(), 0;
231
-
232
-        uint8_t *ptr = (uint8_t *)arg_ptr;
233
-        while (arg_val > 0) {
234
-          if (u8g_i2c_send_byte_sw(u8g_pgm_read(ptr)) == 0) return 0;
235
-          ptr++;
236
-          arg_val--;
237
-        }
238
-      }
239
-      // u8g_i2c_stop();
240
-      break;
241
-
242
-    case U8G_COM_MSG_ADDRESS:                     /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
243
-      u8g->pin_list[U8G_PI_A0_STATE] = arg_val;
244
-      u8g->pin_list[U8G_PI_SET_A0] = 1;   /* force a0 to set again */
245
-      u8g_i2c_start_sw(0); // send slave address and write bit
246
-      u8g_i2c_send_byte_sw(arg_val ? 0x40 : 0x80);  // Write to ? Graphics DRAM mode : Command mode
247
-      break;
248
-  }
249
-  return 1;
250
-}
251
-
252
-#endif // HAS_GRAPHICAL_LCD
253
-
254
-#endif // TARGET_LPC1768

+ 12
- 12
Marlin/src/HAL/HAL_LPC1768/upload_extra_script.py Ver fichero

@@ -9,7 +9,9 @@ target_filename = "FIRMWARE.CUR"
9 9
 target_drive = "REARM"
10 10
 
11 11
 import os
12
+import getpass
12 13
 import platform
14
+
13 15
 current_OS = platform.system()
14 16
 Import("env")
15 17
 
@@ -77,28 +79,26 @@ try:
77 79
         upload_disk = 'Disk not found'
78 80
         target_file_found = False
79 81
         target_drive_found = False
80
-        medias = os.listdir('/media')  #
81
-        for media in medias:
82
-            drives = os.listdir('/media/' + media)  #
83
-            if target_drive in drives and target_file_found == False:  # set upload if not found target file yet
84
-                target_drive_found = True
85
-                upload_disk = '/media/' + media + '/' + target_drive + '/'
82
+        drives = os.listdir(os.path.join(os.sep, 'media', getpass.getuser()))
83
+        if target_drive in drives:  # If target drive is found, use it.
84
+            target_drive_found = True
85
+            upload_disk = os.path.join(os.sep, 'media', getpass.getuser(), target_drive) + os.sep
86
+        else:
86 87
             for drive in drives:
87 88
                 try:
88
-                    files = os.listdir('/media/' + media + '/' + drive)
89
+                    files = os.listdir(os.path.join(os.sep, 'media', getpass.getuser(), drive))
89 90
                 except:
90 91
                     continue
91 92
                 else:
92 93
                     if target_filename in files:
93
-                        if target_file_found == False:
94
-                            upload_disk = '/media/' + media + '/' + drive + '/'
95
-                            target_file_found = True
96
-
94
+                        upload_disk = os.path.join(os.sep, 'media', getpass.getuser(), drive) + os.sep
95
+                        target_file_found = True
96
+                        break
97 97
         #
98 98
         # set upload_port to drive if found
99 99
         #
100 100
 
101
-        if target_file_found == True or target_drive_found == True:
101
+        if target_file_found or target_drive_found:
102 102
             env.Replace(
103 103
                 UPLOAD_FLAGS="-P$UPLOAD_PORT",
104 104
                 UPLOAD_PORT=upload_disk

+ 0
- 1
Marlin/src/HAL/HAL_LPC1768/watchdog.cpp Ver fichero

@@ -68,5 +68,4 @@ bool watchdog_timed_out() { return TEST(WDT_ReadTimeOutFlag(), 0); }
68 68
 void watchdog_clear_timeout_flag() { WDT_ClrTimeOutFlag(); }
69 69
 
70 70
 #endif // USE_WATCHDOG
71
-
72 71
 #endif // TARGET_LPC1768

+ 61
- 11
Marlin/src/HAL/HAL_SAMD51/HAL.cpp Ver fichero

@@ -59,6 +59,21 @@
59 59
 #else
60 60
   #define GET_TEMP_5_ADC()          -1
61 61
 #endif
62
+#if HAS_TEMP_ADC_6
63
+  #define GET_TEMP_6_ADC()          PIN_TO_ADC(TEMP_6_PIN)
64
+#else
65
+  #define GET_TEMP_6_ADC()          -1
66
+#endif
67
+#if HAS_TEMP_ADC_7
68
+  #define GET_TEMP_7_ADC()          PIN_TO_ADC(TEMP_7_PIN)
69
+#else
70
+  #define GET_TEMP_7_ADC()          -1
71
+#endif
72
+#if HAS_TEMP_PROBE
73
+  #define GET_PROBE_ADC()           PIN_TO_ADC(TEMP_PROBE_PIN)
74
+#else
75
+  #define GET_PROBE_ADC()           -1
76
+#endif
62 77
 #if HAS_TEMP_ADC_BED
63 78
   #define GET_BED_ADC()             PIN_TO_ADC(TEMP_BED_PIN)
64 79
 #else
@@ -80,12 +95,15 @@
80 95
   #define GET_BUTTONS_ADC()         -1
81 96
 #endif
82 97
 
83
-#define IS_ADC_REQUIRED(n)      (GET_TEMP_0_ADC() == n || GET_TEMP_1_ADC() == n || GET_TEMP_2_ADC() == n      \
84
-                                 || GET_TEMP_3_ADC() == n || GET_TEMP_4_ADC() == n || GET_TEMP_5_ADC() == n   \
85
-                                 || GET_BED_ADC() == n                                                        \
86
-                                 || GET_CHAMBER_ADC() == n                                                    \
87
-                                 || GET_FILAMENT_WIDTH_ADC() == n                                             \
88
-                                 || GET_BUTTONS_ADC() == n)
98
+#define IS_ADC_REQUIRED(n) ( \
99
+     GET_TEMP_0_ADC() == n || GET_TEMP_1_ADC() == n || GET_TEMP_2_ADC() == n || GET_TEMP_3_ADC() == n \
100
+  || GET_TEMP_4_ADC() == n || GET_TEMP_5_ADC() == n || GET_TEMP_6_ADC() == n || GET_TEMP_7_ADC() == n \
101
+  || GET_PROBE_ADC() == n          \
102
+  || GET_BED_ADC() == n            \
103
+  || GET_CHAMBER_ADC() == n        \
104
+  || GET_FILAMENT_WIDTH_ADC() == n \
105
+  || GET_BUTTONS_ADC() == n        \
106
+)
89 107
 
90 108
 #define ADC0_IS_REQUIRED    IS_ADC_REQUIRED(0)
91 109
 #define ADC1_IS_REQUIRED    IS_ADC_REQUIRED(1)
@@ -145,6 +163,15 @@ uint16_t HAL_adc_result;
145 163
     #if GET_TEMP_5_ADC() == 0
146 164
       TEMP_5_PIN,
147 165
     #endif
166
+    #if GET_TEMP_6_ADC() == 0
167
+      TEMP_6_PIN,
168
+    #endif
169
+    #if GET_TEMP_7_ADC() == 0
170
+      TEMP_7_PIN,
171
+    #endif
172
+    #if GET_PROBE_ADC() == 0
173
+      TEMP_PROBE_PIN,
174
+    #endif
148 175
     #if GET_BED_ADC() == 0
149 176
       TEMP_BED_PIN,
150 177
     #endif
@@ -176,6 +203,15 @@ uint16_t HAL_adc_result;
176 203
     #if GET_TEMP_5_ADC() == 1
177 204
       TEMP_5_PIN,
178 205
     #endif
206
+    #if GET_TEMP_6_ADC() == 1
207
+      TEMP_6_PIN,
208
+    #endif
209
+    #if GET_TEMP_7_ADC() == 1
210
+      TEMP_7_PIN,
211
+    #endif
212
+    #if GET_PROBE_ADC() == 1
213
+      TEMP_PROBE_PIN,
214
+    #endif
179 215
     #if GET_BED_ADC() == 1
180 216
       TEMP_BED_PIN,
181 217
     #endif
@@ -215,6 +251,15 @@ uint16_t HAL_adc_result;
215 251
       #if GET_TEMP_5_ADC() == 0
216 252
         { PIN_TO_INPUTCTRL(TEMP_5_PIN) },
217 253
       #endif
254
+      #if GET_TEMP_6_ADC() == 0
255
+        { PIN_TO_INPUTCTRL(TEMP_6_PIN) },
256
+      #endif
257
+      #if GET_TEMP_7_ADC() == 0
258
+        { PIN_TO_INPUTCTRL(TEMP_7_PIN) },
259
+      #endif
260
+      #if GET_PROBE_ADC() == 0
261
+        { PIN_TO_INPUTCTRL(TEMP_PROBE_PIN) },
262
+      #endif
218 263
       #if GET_BED_ADC() == 0
219 264
         { PIN_TO_INPUTCTRL(TEMP_BED_PIN) },
220 265
       #endif
@@ -255,6 +300,15 @@ uint16_t HAL_adc_result;
255 300
       #if GET_TEMP_5_ADC() == 1
256 301
         { PIN_TO_INPUTCTRL(TEMP_5_PIN) },
257 302
       #endif
303
+      #if GET_TEMP_6_ADC() == 1
304
+        { PIN_TO_INPUTCTRL(TEMP_6_PIN) },
305
+      #endif
306
+      #if GET_TEMP_7_ADC() == 1
307
+        { PIN_TO_INPUTCTRL(TEMP_7_PIN) },
308
+      #endif
309
+      #if GET_PROBE_ADC() == 1
310
+        { PIN_TO_INPUTCTRL(TEMP_PROBE_PIN) },
311
+      #endif
258 312
       #if GET_BED_ADC() == 1
259 313
         { PIN_TO_INPUTCTRL(TEMP_BED_PIN) },
260 314
       #endif
@@ -426,7 +480,7 @@ void HAL_adc_init() {
426 480
     memset(HAL_adc_results, 0xFF, sizeof(HAL_adc_results));                 // Fill result with invalid values
427 481
 
428 482
     for (uint8_t pi = 0; pi < COUNT(adc_pins); ++pi)
429
-        pinPeripheral(adc_pins[pi], PIO_ANALOG);
483
+      pinPeripheral(adc_pins[pi], PIO_ANALOG);
430 484
 
431 485
     for (uint8_t ai = FIRST_ADC; ai <= LAST_ADC; ++ai) {
432 486
       Adc* adc = ((Adc*[])ADC_INSTS)[ai];
@@ -471,8 +525,4 @@ void HAL_adc_start_conversion(const uint8_t adc_pin) {
471 525
   HAL_adc_result = 0xFFFF;
472 526
 }
473 527
 
474
-uint16_t HAL_adc_get_result() {
475
-  return HAL_adc_result;
476
-}
477
-
478 528
 #endif // __SAMD51__

+ 32
- 13
Marlin/src/HAL/HAL_SAMD51/HAL.h Ver fichero

@@ -33,11 +33,9 @@
33 33
   #include "MarlinSerial_AGCM4.h"
34 34
 
35 35
   // Serial ports
36
-  #if !WITHIN(SERIAL_PORT, -1, 3)
37
-    #error "SERIAL_PORT must be from -1 to 3"
38
-  #endif
39 36
 
40 37
   // MYSERIAL0 required before MarlinSerial includes!
38
+
41 39
   #if SERIAL_PORT == -1
42 40
     #define MYSERIAL0 Serial
43 41
   #elif SERIAL_PORT == 0
@@ -46,18 +44,16 @@
46 44
     #define MYSERIAL0 Serial2
47 45
   #elif SERIAL_PORT == 2
48 46
     #define MYSERIAL0 Serial3
49
-  #else
47
+  #elif SERIAL_PORT == 3
50 48
     #define MYSERIAL0 Serial4
49
+  #else
50
+    #error "SERIAL_PORT must be from -1 to 3. Please update your configuration."
51 51
   #endif
52 52
 
53 53
   #ifdef SERIAL_PORT_2
54
-    #if !WITHIN(SERIAL_PORT_2, -1, 3)
55
-      #error "SERIAL_PORT_2 must be from -1 to 3"
56
-    #elif SERIAL_PORT_2 == SERIAL_PORT
57
-      #error "SERIAL_PORT_2 must be different than SERIAL_PORT"
58
-    #endif
59
-    #define NUM_SERIAL 2
60
-    #if SERIAL_PORT_2 == -1
54
+    #if SERIAL_PORT_2 == SERIAL_PORT
55
+      #error "SERIAL_PORT_2 must be different than SERIAL_PORT. Please update your configuration."
56
+    #elif SERIAL_PORT_2 == -1
61 57
       #define MYSERIAL1 Serial
62 58
     #elif SERIAL_PORT_2 == 0
63 59
       #define MYSERIAL1 Serial1
@@ -65,13 +61,36 @@
65 61
       #define MYSERIAL1 Serial2
66 62
     #elif SERIAL_PORT_2 == 2
67 63
       #define MYSERIAL1 Serial3
68
-    #else
64
+    #elif SERIAL_PORT_2 == 3
69 65
       #define MYSERIAL1 Serial4
66
+    #else
67
+      #error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration."
70 68
     #endif
69
+    #define NUM_SERIAL 2
71 70
   #else
72 71
     #define NUM_SERIAL 1
73 72
   #endif
74 73
 
74
+  #ifdef DGUS_SERIAL_PORT
75
+    #if DGUS_SERIAL_PORT == SERIAL_PORT
76
+      #error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration."
77
+    #elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
78
+      #error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
79
+    #elif DGUS_SERIAL_PORT == -1
80
+      #define DGUS_SERIAL Serial
81
+    #elif DGUS_SERIAL_PORT == 0
82
+      #define DGUS_SERIAL Serial1
83
+    #elif DGUS_SERIAL_PORT == 1
84
+      #define DGUS_SERIAL Serial2
85
+    #elif DGUS_SERIAL_PORT == 2
86
+      #define DGUS_SERIAL Serial3
87
+    #elif DGUS_SERIAL_PORT == 2
88
+      #define DGUS_SERIAL Serial4
89
+    #else
90
+      #error "DGUS_SERIAL_PORT must be from -1 to 3. Please update your configuration."
91
+    #endif
92
+  #endif
93
+
75 94
 #endif // ADAFRUIT_GRAND_CENTRAL_M4
76 95
 
77 96
 typedef int8_t pin_t;
@@ -116,7 +135,7 @@ void HAL_adc_init();
116 135
 #define HAL_ADC_READY()     true
117 136
 
118 137
 void HAL_adc_start_conversion(const uint8_t adc_pin);
119
-uint16_t HAL_adc_get_result();
138
+inline uint16_t HAL_adc_get_result() { return HAL_adc_result; }
120 139
 
121 140
 //
122 141
 // Pin Map

+ 34
- 11
Marlin/src/HAL/HAL_SAMD51/endstop_interrupts.h Ver fichero

@@ -98,6 +98,16 @@
98 98
 #else
99 99
   #define MATCH_Z3_MIN_EILINE(P) false
100 100
 #endif
101
+#if HAS_Z4_MAX
102
+  #define MATCH_Z4_MAX_EILINE(P) MATCH_EILINE(P, Z4_MAX_PIN)
103
+#else
104
+  #define MATCH_Z4_MAX_EILINE(P) false
105
+#endif
106
+#if HAS_Z4_MIN
107
+  #define MATCH_Z4_MIN_EILINE(P) MATCH_EILINE(P, Z4_MIN_PIN)
108
+#else
109
+  #define MATCH_Z4_MIN_EILINE(P) false
110
+#endif
101 111
 #if HAS_Z_MIN_PROBE_PIN
102 112
   #define MATCH_Z_MIN_PROBE_EILINE(P)   MATCH_EILINE(P, Z_MIN_PROBE_PIN)
103 113
 #else
@@ -109,6 +119,7 @@
109 119
                                  && !MATCH_Z_MAX_EILINE(P) && !MATCH_Z_MIN_EILINE(P)    \
110 120
                                  && !MATCH_Z2_MAX_EILINE(P) && !MATCH_Z2_MIN_EILINE(P)  \
111 121
                                  && !MATCH_Z3_MAX_EILINE(P) && !MATCH_Z3_MIN_EILINE(P)  \
122
+                                 && !MATCH_Z4_MAX_EILINE(P) && !MATCH_Z4_MIN_EILINE(P)  \
112 123
                                  && !MATCH_Z_MIN_PROBE_EILINE(P))
113 124
 
114 125
 // One ISR for all EXT-Interrupts
@@ -117,67 +128,79 @@ void endstop_ISR() { endstops.update(); }
117 128
 void setup_endstop_interrupts() {
118 129
   #if HAS_X_MAX
119 130
     #if !AVAILABLE_EILINE(X_MAX_PIN)
120
-      static_assert(false, "X_MAX_PIN has no EXTINT line available.");
131
+      #error "X_MAX_PIN has no EXTINT line available."
121 132
     #endif
122 133
     attachInterrupt(X_MAX_PIN, endstop_ISR, CHANGE);
123 134
   #endif
124 135
   #if HAS_X_MIN
125 136
     #if !AVAILABLE_EILINE(X_MIN_PIN)
126
-      static_assert(false, "X_MIN_PIN has no EXTINT line available.");
137
+      #error "X_MIN_PIN has no EXTINT line available."
127 138
     #endif
128 139
     attachInterrupt(X_MIN_PIN, endstop_ISR, CHANGE);
129 140
   #endif
130 141
   #if HAS_Y_MAX
131 142
     #if !AVAILABLE_EILINE(Y_MAX_PIN)
132
-      static_assert(false, "Y_MAX_PIN has no EXTINT line available.");
143
+      #error "Y_MAX_PIN has no EXTINT line available."
133 144
     #endif
134 145
     attachInterrupt(Y_MAX_PIN, endstop_ISR, CHANGE);
135 146
   #endif
136 147
   #if HAS_Y_MIN
137 148
     #if !AVAILABLE_EILINE(Y_MIN_PIN)
138
-      static_assert(false, "Y_MIN_PIN has no EXTINT line available.");
149
+      #error "Y_MIN_PIN has no EXTINT line available."
139 150
     #endif
140 151
     attachInterrupt(Y_MIN_PIN, endstop_ISR, CHANGE);
141 152
   #endif
142 153
   #if HAS_Z_MAX
143 154
     #if !AVAILABLE_EILINE(Z_MAX_PIN)
144
-      static_assert(false, "Z_MAX_PIN has no EXTINT line available.");
155
+      #error "Z_MAX_PIN has no EXTINT line available."
145 156
     #endif
146 157
     attachInterrupt(Z_MAX_PIN, endstop_ISR, CHANGE);
147 158
   #endif
148 159
   #if HAS_Z_MIN
149 160
     #if !AVAILABLE_EILINE(Z_MIN_PIN)
150
-      static_assert(false, "Z_MIN_PIN has no EXTINT line available.");
161
+      #error "Z_MIN_PIN has no EXTINT line available."
151 162
     #endif
152 163
     attachInterrupt(Z_MIN_PIN, endstop_ISR, CHANGE);
153 164
   #endif
154 165
   #if HAS_Z2_MAX
155 166
     #if !AVAILABLE_EILINE(Z2_MAX_PIN)
156
-      static_assert(false, "Z2_MAX_PIN has no EXTINT line available.");
167
+      #error "Z2_MAX_PIN has no EXTINT line available."
157 168
     #endif
158 169
     attachInterrupt(Z2_MAX_PIN, endstop_ISR, CHANGE);
159 170
   #endif
160 171
   #if HAS_Z2_MIN
161 172
     #if !AVAILABLE_EILINE(Z2_MIN_PIN)
162
-      static_assert(false, "Z2_MIN_PIN has no EXTINT line available.");
173
+      #error "Z2_MIN_PIN has no EXTINT line available."
163 174
     #endif
164 175
     attachInterrupt(Z2_MIN_PIN, endstop_ISR, CHANGE);
165 176
   #endif
166 177
   #if HAS_Z3_MAX
167 178
     #if !AVAILABLE_EILINE(Z3_MAX_PIN)
168
-      static_assert(false, "Z3_MAX_PIN has no EXTINT line available.");
179
+      #error "Z3_MAX_PIN has no EXTINT line available."
169 180
     #endif
170 181
     attachInterrupt(Z3_MAX_PIN, endstop_ISR, CHANGE);
171 182
   #endif
172 183
   #if HAS_Z3_MIN
173 184
     #if !AVAILABLE_EILINE(Z3_MIN_PIN)
174
-      static_assert(false, "Z3_MIN_PIN has no EXTINT line available.");
185
+      #error "Z3_MIN_PIN has no EXTINT line available."
175 186
     #endif
176 187
     attachInterrupt(Z3_MIN_PIN, endstop_ISR, CHANGE);
177 188
   #endif
189
+  #if HAS_Z4_MAX
190
+    #if !AVAILABLE_EILINE(Z4_MAX_PIN)
191
+      #error "Z4_MAX_PIN has no EXTINT line available."
192
+    #endif
193
+    attachInterrupt(Z4_MAX_PIN, endstop_ISR, CHANGE);
194
+  #endif
195
+  #if HAS_Z4_MIN
196
+    #if !AVAILABLE_EILINE(Z4_MIN_PIN)
197
+      #error "Z4_MIN_PIN has no EXTINT line available."
198
+    #endif
199
+    attachInterrupt(Z4_MIN_PIN, endstop_ISR, CHANGE);
200
+  #endif
178 201
   #if HAS_Z_MIN_PROBE_PIN
179 202
     #if !AVAILABLE_EILINE(Z_MIN_PROBE_PIN)
180
-      static_assert(false, "Z_MIN_PROBE_PIN has no EXTINT line available.");
203
+      #error "Z_MIN_PROBE_PIN has no EXTINT line available."
181 204
     #endif
182 205
     attachInterrupt(Z_MIN_PROBE_PIN, endstop_ISR, CHANGE);
183 206
   #endif

+ 4
- 0
Marlin/src/HAL/HAL_SAMD51/inc/SanityCheck.h Ver fichero

@@ -46,3 +46,7 @@
46 46
 #if ENABLED(EEPROM_SETTINGS) && NONE(SPI_EEPROM, I2C_EEPROM)
47 47
   #warning "Did you activate the SmartEEPROM? See https://github.com/GMagician/SAMD51-SmartEEprom-Activator"
48 48
 #endif
49
+
50
+#if TMC_HAS_SW_SERIAL
51
+  #error "TMC220x Software Serial is not supported on this platform."
52
+#endif

+ 23
- 13
Marlin/src/HAL/HAL_STM32/HAL.cpp Ver fichero

@@ -28,13 +28,7 @@
28 28
 #include "../../inc/MarlinConfig.h"
29 29
 #include "../shared/Delay.h"
30 30
 
31
-#if (__cplusplus == 201703L) && defined(__has_include)
32
-  #define HAS_SWSERIAL __has_include(<SoftwareSerial.h>)
33
-#else
34
-  #define HAS_SWSERIAL HAS_TMC220x
35
-#endif
36
-
37
-#if HAS_SWSERIAL
31
+#if TMC_HAS_SW_SERIAL
38 32
   #include "SoftwareSerial.h"
39 33
 #endif
40 34
 
@@ -93,7 +87,7 @@ void HAL_init() {
93 87
   while (!LL_PWR_IsActiveFlag_BRR());
94 88
   #endif // EEPROM_EMULATED_SRAM
95 89
 
96
-  #if HAS_SWSERIAL
90
+  #if TMC_HAS_SW_SERIAL
97 91
     SoftwareSerial::setInterruptPriority(SWSERIAL_TIMER_IRQ_PRIO, 0);
98 92
   #endif
99 93
 }
@@ -101,11 +95,27 @@ void HAL_init() {
101 95
 void HAL_clear_reset_source() { __HAL_RCC_CLEAR_RESET_FLAGS(); }
102 96
 
103 97
 uint8_t HAL_get_reset_source() {
104
-  if (__HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST) != RESET) return RST_WATCHDOG;
105
-  if (__HAL_RCC_GET_FLAG(RCC_FLAG_SFTRST) != RESET)  return RST_SOFTWARE;
106
-  if (__HAL_RCC_GET_FLAG(RCC_FLAG_PINRST) != RESET)  return RST_EXTERNAL;
107
-  if (__HAL_RCC_GET_FLAG(RCC_FLAG_PORRST) != RESET)  return RST_POWER_ON;
108
-  return 0;
98
+  return
99
+    #ifdef RCC_FLAG_IWDGRST // Some sources may not exist...
100
+      RESET != __HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST)  ? RST_WATCHDOG :
101
+    #endif
102
+    #ifdef RCC_FLAG_IWDG1RST
103
+      RESET != __HAL_RCC_GET_FLAG(RCC_FLAG_IWDG1RST) ? RST_WATCHDOG :
104
+    #endif
105
+    #ifdef RCC_FLAG_IWDG2RST
106
+      RESET != __HAL_RCC_GET_FLAG(RCC_FLAG_IWDG2RST) ? RST_WATCHDOG :
107
+    #endif
108
+    #ifdef RCC_FLAG_SFTRST
109
+      RESET != __HAL_RCC_GET_FLAG(RCC_FLAG_SFTRST)   ? RST_SOFTWARE :
110
+    #endif
111
+    #ifdef RCC_FLAG_PINRST
112
+      RESET != __HAL_RCC_GET_FLAG(RCC_FLAG_PINRST)   ? RST_EXTERNAL :
113
+    #endif
114
+    #ifdef RCC_FLAG_PORRST
115
+      RESET != __HAL_RCC_GET_FLAG(RCC_FLAG_PORRST)   ? RST_POWER_ON :
116
+    #endif
117
+    0
118
+  ;
109 119
 }
110 120
 
111 121
 void _delay_ms(const int delay_ms) { delay(delay_ms); }

+ 38
- 16
Marlin/src/HAL/HAL_STM32/HAL.h Ver fichero

@@ -44,13 +44,8 @@
44 44
 // ------------------------
45 45
 
46 46
 #if SERIAL_PORT == 0
47
-  #error "Serial port 0 does not exist"
48
-#endif
49
-
50
-#if !WITHIN(SERIAL_PORT, -1, 6)
51
-  #error "SERIAL_PORT must be from -1 to 6"
52
-#endif
53
-#if SERIAL_PORT == -1
47
+  #error "SERIAL_PORT cannot be 0. (Port 0 does not exist.) Please update your configuration."
48
+#elif SERIAL_PORT == -1
54 49
   #define MYSERIAL0 SerialUSB
55 50
 #elif SERIAL_PORT == 1
56 51
   #define MYSERIAL0 Serial1
@@ -64,20 +59,17 @@
64 59
   #define MYSERIAL0 Serial5
65 60
 #elif SERIAL_PORT == 6
66 61
   #define MYSERIAL0 Serial6
62
+#else
63
+  #error "SERIAL_PORT must be from -1 to 6. Please update your configuration."
67 64
 #endif
68 65
 
69 66
 #ifdef SERIAL_PORT_2
67
+  #define NUM_SERIAL 2
70 68
   #if SERIAL_PORT_2 == 0
71
-    #error "Serial port 0 does not exist"
72
-  #endif
73
-
74
-  #if !WITHIN(SERIAL_PORT_2, -1, 6)
75
-    #error "SERIAL_PORT_2 must be from -1 to 6"
69
+    #error "SERIAL_PORT_2 cannot be 0. (Port 0 does not exist.) Please update your configuration."
76 70
   #elif SERIAL_PORT_2 == SERIAL_PORT
77
-    #error "SERIAL_PORT_2 must be different than SERIAL_PORT"
78
-  #endif
79
-  #define NUM_SERIAL 2
80
-  #if SERIAL_PORT_2 == -1
71
+    #error "SERIAL_PORT_2 must be different than SERIAL_PORT. Please update your configuration."
72
+  #elif SERIAL_PORT_2 == -1
81 73
     #define MYSERIAL1 SerialUSB
82 74
   #elif SERIAL_PORT_2 == 1
83 75
     #define MYSERIAL1 Serial1
@@ -91,11 +83,41 @@
91 83
     #define MYSERIAL1 Serial5
92 84
   #elif SERIAL_PORT_2 == 6
93 85
     #define MYSERIAL1 Serial6
86
+  #else
87
+    #error "SERIAL_PORT_2 must be from -1 to 6. Please update your configuration."
94 88
   #endif
95 89
 #else
96 90
   #define NUM_SERIAL 1
97 91
 #endif
98 92
 
93
+#if HAS_DGUS_LCD
94
+  #if DGUS_SERIAL_PORT == 0
95
+    #error "DGUS_SERIAL_PORT cannot be 0. (Port 0 does not exist.) Please update your configuration."
96
+  #elif DGUS_SERIAL_PORT == SERIAL_PORT
97
+    #error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration."
98
+  #elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
99
+    #error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
100
+  #elif DGUS_SERIAL_PORT == -1
101
+    #define DGUS_SERIAL SerialUSB
102
+  #elif DGUS_SERIAL_PORT == 1
103
+    #define DGUS_SERIAL Serial1
104
+  #elif DGUS_SERIAL_PORT == 2
105
+    #define DGUS_SERIAL Serial2
106
+  #elif DGUS_SERIAL_PORT == 3
107
+    #define DGUS_SERIAL Serial3
108
+  #elif DGUS_SERIAL_PORT == 4
109
+    #define DGUS_SERIAL Serial4
110
+  #elif DGUS_SERIAL_PORT == 5
111
+    #define DGUS_SERIAL Serial5
112
+  #elif DGUS_SERIAL_PORT == 6
113
+    #define DGUS_SERIAL Serial6
114
+  #else
115
+    #error "DGUS_SERIAL_PORT must be from -1 to 6. Please update your configuration."
116
+  #endif
117
+
118
+  #define DGUS_SERIAL_GET_TX_BUFFER_FREE DGUS_SERIAL.availableForWrite
119
+#endif
120
+
99 121
 #include "timers.h"
100 122
 
101 123
 /**

+ 173
- 101
Marlin/src/HAL/HAL_STM32/HAL_SPI.cpp Ver fichero

@@ -37,121 +37,193 @@ static SPISettings spiConfig;
37 37
 // ------------------------
38 38
 
39 39
 #if ENABLED(SOFTWARE_SPI)
40
+
40 41
   // ------------------------
41 42
   // Software SPI
42 43
   // ------------------------
43
-  #error "Software SPI not supported for STM32. Use Hardware SPI."
44 44
 
45
-#else
45
+  #include "../shared/Delay.h"
46 46
 
47
-// ------------------------
48
-// Hardware SPI
49
-// ------------------------
47
+  void spiBegin(void) {
48
+    OUT_WRITE(SS_PIN, HIGH);
49
+    OUT_WRITE(SCK_PIN, HIGH);
50
+    SET_INPUT(MISO_PIN);
51
+    OUT_WRITE(MOSI_PIN, HIGH);
52
+  }
50 53
 
51
-/**
52
- * VGPV SPI speed start and PCLK2/2, by default 108/2 = 54Mhz
53
- */
54
+  static uint16_t delay_STM32_soft_spi;
55
+
56
+  void spiInit(uint8_t spiRate) {
57
+    // Use datarates Marlin uses
58
+    switch (spiRate) {
59
+      case SPI_FULL_SPEED:   delay_STM32_soft_spi =  125; break;  // desired: 8,000,000  actual: ~1.1M
60
+      case SPI_HALF_SPEED:   delay_STM32_soft_spi =  125; break;  // desired: 4,000,000  actual: ~1.1M
61
+      case SPI_QUARTER_SPEED:delay_STM32_soft_spi =  250; break;  // desired: 2,000,000  actual: ~890K
62
+      case SPI_EIGHTH_SPEED: delay_STM32_soft_spi =  500; break;  // desired: 1,000,000  actual: ~590K
63
+      case SPI_SPEED_5:      delay_STM32_soft_spi = 1000; break;  // desired:   500,000  actual: ~360K
64
+      case SPI_SPEED_6:      delay_STM32_soft_spi = 2000; break;  // desired:   250,000  actual: ~210K
65
+      default:               delay_STM32_soft_spi = 4000; break;  // desired:   125,000  actual: ~123K
66
+    }
67
+    SPI.begin();
68
+  }
54 69
 
55
-/**
56
- * @brief  Begin SPI port setup
57
- *
58
- * @return Nothing
59
- *
60
- * @details Only configures SS pin since stm32duino creates and initialize the SPI object
61
- */
62
-void spiBegin() {
63
-  #if !PIN_EXISTS(SS)
64
-    #error "SS_PIN not defined!"
65
-  #endif
66
-
67
-  OUT_WRITE(SS_PIN, HIGH);
68
-}
69
-
70
-/** Configure SPI for specified SPI speed */
71
-void spiInit(uint8_t spiRate) {
72
-  // Use datarates Marlin uses
73
-  uint32_t clock;
74
-  switch (spiRate) {
75
-    case SPI_FULL_SPEED:    clock = 20000000; break; // 13.9mhz=20000000  6.75mhz=10000000  3.38mhz=5000000  .833mhz=1000000
76
-    case SPI_HALF_SPEED:    clock =  5000000; break;
77
-    case SPI_QUARTER_SPEED: clock =  2500000; break;
78
-    case SPI_EIGHTH_SPEED:  clock =  1250000; break;
79
-    case SPI_SPEED_5:       clock =   625000; break;
80
-    case SPI_SPEED_6:       clock =   300000; break;
81
-    default:
82
-      clock = 4000000; // Default from the SPI library
70
+  // Begin SPI transaction, set clock, bit order, data mode
71
+  void spiBeginTransaction(uint32_t spiClock, uint8_t bitOrder, uint8_t dataMode) { /* do nothing */ }
72
+
73
+  uint8_t HAL_SPI_STM32_SpiTransfer_Mode_3(uint8_t b) { // using Mode 3
74
+    for (uint8_t bits = 8; bits--;) {
75
+      WRITE(SCK_PIN, LOW);
76
+      WRITE(MOSI_PIN, b & 0x80);
77
+
78
+      DELAY_NS(delay_STM32_soft_spi);
79
+      WRITE(SCK_PIN, HIGH);
80
+      DELAY_NS(delay_STM32_soft_spi);
81
+
82
+      b <<= 1;        // little setup time
83
+      b |= (READ(MISO_PIN) != 0);
84
+    }
85
+    DELAY_NS(125);
86
+    return b;
83 87
   }
84
-  spiConfig = SPISettings(clock, MSBFIRST, SPI_MODE0);
85 88
 
86
-  #if ENABLED(CUSTOM_SPI_PINS)
87
-    SPI.setMISO(MISO_PIN);
88
-    SPI.setMOSI(MOSI_PIN);
89
-    SPI.setSCLK(SCK_PIN);
90
-    SPI.setSSEL(SS_PIN);
91
-  #endif
89
+  // Soft SPI receive byte
90
+  uint8_t spiRec() {
91
+    DISABLE_ISRS();                                               // No interrupts during byte receive
92
+    const uint8_t data = HAL_SPI_STM32_SpiTransfer_Mode_3(0xFF);
93
+    ENABLE_ISRS();                                                // Enable interrupts
94
+    return data;
95
+  }
92 96
 
93
-  SPI.begin();
94
-}
97
+  // Soft SPI read data
98
+  void spiRead(uint8_t *buf, uint16_t nbyte) {
99
+    for (uint16_t i = 0; i < nbyte; i++)
100
+      buf[i] = spiRec();
101
+  }
95 102
 
96
-/**
97
- * @brief  Receives a single byte from the SPI port.
98
- *
99
- * @return Byte received
100
- *
101
- * @details
102
- */
103
-uint8_t spiRec() {
104
-  SPI.beginTransaction(spiConfig);
105
-  uint8_t returnByte = SPI.transfer(0xFF);
106
-  SPI.endTransaction();
107
-  return returnByte;
108
-}
103
+  // Soft SPI send byte
104
+  void spiSend(uint8_t data) {
105
+    DISABLE_ISRS();                         // No interrupts during byte send
106
+    HAL_SPI_STM32_SpiTransfer_Mode_3(data); // Don't care what is received
107
+    ENABLE_ISRS();                          // Enable interrupts
108
+  }
109 109
 
110
-/**
111
- * @brief  Receives a number of bytes from the SPI port to a buffer
112
- *
113
- * @param  buf   Pointer to starting address of buffer to write to.
114
- * @param  nbyte Number of bytes to receive.
115
- * @return Nothing
116
- *
117
- * @details Uses DMA
118
- */
119
-void spiRead(uint8_t* buf, uint16_t nbyte) {
120
-  if (nbyte == 0) return;
121
-  memset(buf, 0xFF, nbyte);
122
-  SPI.beginTransaction(spiConfig);
123
-  SPI.transfer(buf, nbyte);
124
-  SPI.endTransaction();
125
-}
110
+  // Soft SPI send block
111
+  void spiSendBlock(uint8_t token, const uint8_t *buf) {
112
+    spiSend(token);
113
+    for (uint16_t i = 0; i < 512; i++)
114
+      spiSend(buf[i]);
115
+  }
126 116
 
127
-/**
128
- * @brief  Sends a single byte on SPI port
129
- *
130
- * @param  b Byte to send
131
- *
132
- * @details
133
- */
134
-void spiSend(uint8_t b) {
135
-  SPI.beginTransaction(spiConfig);
136
-  SPI.transfer(b);
137
-  SPI.endTransaction();
138
-}
117
+#else
139 118
 
140
-/**
141
- * @brief  Write token and then write from 512 byte buffer to SPI (for SD card)
142
- *
143
- * @param  buf   Pointer with buffer start address
144
- * @return Nothing
145
- *
146
- * @details Use DMA
147
- */
148
-void spiSendBlock(uint8_t token, const uint8_t* buf) {
149
-  uint8_t rxBuf[512];
150
-  SPI.beginTransaction(spiConfig);
151
-  SPI.transfer(token);
152
-  SPI.transfer((uint8_t*)buf, &rxBuf, 512);
153
-  SPI.endTransaction();
154
-}
119
+  // ------------------------
120
+  // Hardware SPI
121
+  // ------------------------
122
+
123
+  /**
124
+   * VGPV SPI speed start and PCLK2/2, by default 108/2 = 54Mhz
125
+   */
126
+
127
+  /**
128
+   * @brief  Begin SPI port setup
129
+   *
130
+   * @return Nothing
131
+   *
132
+   * @details Only configures SS pin since stm32duino creates and initialize the SPI object
133
+   */
134
+  void spiBegin() {
135
+    #if !PIN_EXISTS(SS)
136
+      #error "SS_PIN not defined!"
137
+    #endif
138
+
139
+    OUT_WRITE(SS_PIN, HIGH);
140
+  }
141
+
142
+  // Configure SPI for specified SPI speed
143
+  void spiInit(uint8_t spiRate) {
144
+    // Use datarates Marlin uses
145
+    uint32_t clock;
146
+    switch (spiRate) {
147
+      case SPI_FULL_SPEED:    clock = 20000000; break; // 13.9mhz=20000000  6.75mhz=10000000  3.38mhz=5000000  .833mhz=1000000
148
+      case SPI_HALF_SPEED:    clock =  5000000; break;
149
+      case SPI_QUARTER_SPEED: clock =  2500000; break;
150
+      case SPI_EIGHTH_SPEED:  clock =  1250000; break;
151
+      case SPI_SPEED_5:       clock =   625000; break;
152
+      case SPI_SPEED_6:       clock =   300000; break;
153
+      default:
154
+        clock = 4000000; // Default from the SPI library
155
+    }
156
+    spiConfig = SPISettings(clock, MSBFIRST, SPI_MODE0);
157
+
158
+    #if ENABLED(CUSTOM_SPI_PINS)
159
+      SPI.setMISO(MISO_PIN);
160
+      SPI.setMOSI(MOSI_PIN);
161
+      SPI.setSCLK(SCK_PIN);
162
+      SPI.setSSEL(SS_PIN);
163
+    #endif
164
+
165
+    SPI.begin();
166
+  }
167
+
168
+  /**
169
+   * @brief  Receives a single byte from the SPI port.
170
+   *
171
+   * @return Byte received
172
+   *
173
+   * @details
174
+   */
175
+  uint8_t spiRec() {
176
+    SPI.beginTransaction(spiConfig);
177
+    uint8_t returnByte = SPI.transfer(0xFF);
178
+    SPI.endTransaction();
179
+    return returnByte;
180
+  }
181
+
182
+  /**
183
+   * @brief  Receive a number of bytes from the SPI port to a buffer
184
+   *
185
+   * @param  buf   Pointer to starting address of buffer to write to.
186
+   * @param  nbyte Number of bytes to receive.
187
+   * @return Nothing
188
+   *
189
+   * @details Uses DMA
190
+   */
191
+  void spiRead(uint8_t* buf, uint16_t nbyte) {
192
+    if (nbyte == 0) return;
193
+    memset(buf, 0xFF, nbyte);
194
+    SPI.beginTransaction(spiConfig);
195
+    SPI.transfer(buf, nbyte);
196
+    SPI.endTransaction();
197
+  }
198
+
199
+  /**
200
+   * @brief  Send a single byte on SPI port
201
+   *
202
+   * @param  b Byte to send
203
+   *
204
+   * @details
205
+   */
206
+  void spiSend(uint8_t b) {
207
+    SPI.beginTransaction(spiConfig);
208
+    SPI.transfer(b);
209
+    SPI.endTransaction();
210
+  }
211
+
212
+  /**
213
+   * @brief  Write token and then write from 512 byte buffer to SPI (for SD card)
214
+   *
215
+   * @param  buf   Pointer with buffer start address
216
+   * @return Nothing
217
+   *
218
+   * @details Use DMA
219
+   */
220
+  void spiSendBlock(uint8_t token, const uint8_t* buf) {
221
+    uint8_t rxBuf[512];
222
+    SPI.beginTransaction(spiConfig);
223
+    SPI.transfer(token);
224
+    SPI.transfer((uint8_t*)buf, &rxBuf, 512);
225
+    SPI.endTransaction();
226
+  }
155 227
 
156 228
 #endif // SOFTWARE_SPI
157 229
 

+ 6
- 0
Marlin/src/HAL/HAL_STM32/endstop_interrupts.h Ver fichero

@@ -58,6 +58,12 @@ void setup_endstop_interrupts() {
58 58
   #if HAS_Z3_MIN
59 59
     attachInterrupt(Z3_MIN_PIN, endstop_ISR, CHANGE);
60 60
   #endif
61
+  #if HAS_Z4_MAX
62
+    attachInterrupt(Z4_MAX_PIN, endstop_ISR, CHANGE);
63
+  #endif
64
+  #if HAS_Z4_MIN
65
+    attachInterrupt(Z4_MIN_PIN, endstop_ISR, CHANGE);
66
+  #endif
61 67
   #if HAS_Z_MIN_PROBE_PIN
62 68
     attachInterrupt(Z_MIN_PROBE_PIN, endstop_ISR, CHANGE);
63 69
   #endif

+ 30
- 7
Marlin/src/HAL/HAL_STM32/timers.h Ver fichero

@@ -33,7 +33,6 @@
33 33
 #define hal_timer_t uint32_t
34 34
 #define HAL_TIMER_TYPE_MAX 0xFFFFFFFF // Timers can be 16 or 32 bit
35 35
 
36
-
37 36
 #ifdef STM32F0xx
38 37
 
39 38
   #define HAL_TIMER_RATE (F_CPU) // frequency of timer peripherals
@@ -58,18 +57,42 @@
58 57
     #define TEMP_TIMER 2
59 58
   #endif
60 59
 
61
-#elif defined(STM32F4xx) || defined(STM32F7xx)
60
+#elif defined(STM32F401xC) || defined(STM32F401xE)
61
+
62
+  #define HAL_TIMER_RATE (F_CPU / 2) // frequency of timer peripherals
63
+
64
+  #ifndef STEP_TIMER
65
+    #define STEP_TIMER 9
66
+  #endif
67
+
68
+  #ifndef TEMP_TIMER
69
+    #define TEMP_TIMER 10
70
+  #endif
71
+
72
+#elif defined(STM32F4xx)
62 73
 
63
-  #define HAL_TIMER_RATE (F_CPU/2) // frequency of timer peripherals
74
+  #define HAL_TIMER_RATE (F_CPU / 2) // frequency of timer peripherals
64 75
 
65 76
   #ifndef STEP_TIMER
66
-    #define STEP_TIMER 5
77
+    #define STEP_TIMER 6  // STM32F401 has no TIM6, TIM7, or TIM8
67 78
   #endif
68 79
 
69 80
   #ifndef TEMP_TIMER
70 81
     #define TEMP_TIMER 14 // TIM7 is consumed by Software Serial if used.
71 82
   #endif
72 83
 
84
+#elif defined(STM32F7xx)
85
+
86
+  #define HAL_TIMER_RATE (F_CPU / 2) // frequency of timer peripherals
87
+
88
+  #ifndef STEP_TIMER
89
+    #define STEP_TIMER 6  // the RIGHT timer!
90
+  #endif
91
+
92
+  #ifndef TEMP_TIMER
93
+    #define TEMP_TIMER 14
94
+  #endif
95
+
73 96
 #endif
74 97
 
75 98
 #ifndef SWSERIAL_TIMER_IRQ_PRIO
@@ -81,16 +104,16 @@
81 104
 #endif
82 105
 
83 106
 #ifndef TEMP_TIMER_IRQ_PRIO
84
-  #define TEMP_TIMER_IRQ_PRIO 14 //14 = after hardware ISRs
107
+  #define TEMP_TIMER_IRQ_PRIO 14   // 14 = after hardware ISRs
85 108
 #endif
86 109
 
87 110
 #define STEP_TIMER_NUM 0  // index of timer to use for stepper
88 111
 #define TEMP_TIMER_NUM 1  // index of timer to use for temperature
89 112
 #define PULSE_TIMER_NUM STEP_TIMER_NUM
90 113
 
91
-#define TEMP_TIMER_FREQUENCY 1000 //Temperature::isr() is expected to be called at around 1kHz
114
+#define TEMP_TIMER_FREQUENCY 1000   // Temperature::isr() is expected to be called at around 1kHz
92 115
 
93
-//TODO: get rid of manual rate/prescale/ticks/cycles taken for procedures in stepper.cpp
116
+// TODO: get rid of manual rate/prescale/ticks/cycles taken for procedures in stepper.cpp
94 117
 #define STEPPER_TIMER_RATE 2000000 // 2 Mhz
95 118
 #define STEPPER_TIMER_PRESCALE ((HAL_TIMER_RATE)/(STEPPER_TIMER_RATE))
96 119
 #define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per µs

+ 18
- 0
Marlin/src/HAL/HAL_STM32F1/HAL.cpp Ver fichero

@@ -118,6 +118,12 @@ const uint8_t adc_pins[] = {
118 118
   #if HAS_TEMP_ADC_5
119 119
     TEMP_5_PIN,
120 120
   #endif
121
+  #if HAS_TEMP_ADC_6
122
+    TEMP_6_PIN,
123
+  #endif
124
+  #if HAS_TEMP_ADC_7
125
+    TEMP_7_PIN,
126
+  #endif
121 127
   #if ENABLED(FILAMENT_WIDTH_SENSOR)
122 128
     FILWIDTH_PIN,
123 129
   #endif
@@ -160,6 +166,12 @@ enum TEMP_PINS : char {
160 166
   #if HAS_TEMP_ADC_5
161 167
     TEMP_5,
162 168
   #endif
169
+  #if HAS_TEMP_ADC_6
170
+    TEMP_6,
171
+  #endif
172
+  #if HAS_TEMP_ADC_7
173
+    TEMP_7,
174
+  #endif
163 175
   #if ENABLED(FILAMENT_WIDTH_SENSOR)
164 176
     FILWIDTH,
165 177
   #endif
@@ -346,6 +358,12 @@ void HAL_adc_start_conversion(const uint8_t adc_pin) {
346 358
     #if HAS_TEMP_ADC_5
347 359
       case TEMP_5_PIN: pin_index = TEMP_5; break;
348 360
     #endif
361
+    #if HAS_TEMP_ADC_6
362
+      case TEMP_6_PIN: pin_index = TEMP_6; break;
363
+    #endif
364
+    #if HAS_TEMP_ADC_7
365
+      case TEMP_7_PIN: pin_index = TEMP_7; break;
366
+    #endif
349 367
     #if HAS_JOY_ADC_X
350 368
       case JOY_X_PIN: pin_index = JOY_X; break;
351 369
     #endif

+ 37
- 14
Marlin/src/HAL/HAL_STM32F1/HAL.h Ver fichero

@@ -78,13 +78,10 @@
78 78
   #define MSerial5  Serial4
79 79
 #endif
80 80
 
81
-#if !WITHIN(SERIAL_PORT, -1, 5)
82
-  #error "SERIAL_PORT must be from -1 to 5"
83
-#endif
84
-#if SERIAL_PORT == -1
81
+#if SERIAL_PORT == 0
82
+  #error "SERIAL_PORT cannot be 0. (Port 0 does not exist.) Please update your configuration."
83
+#elif SERIAL_PORT == -1
85 84
   #define MYSERIAL0 UsbSerial
86
-#elif SERIAL_PORT == 0
87
-  #error "Serial port 0 does not exist"
88 85
 #elif SERIAL_PORT == 1
89 86
   #define MYSERIAL0 MSerial1
90 87
 #elif SERIAL_PORT == 2
@@ -95,19 +92,17 @@
95 92
   #define MYSERIAL0 MSerial4
96 93
 #elif SERIAL_PORT == 5
97 94
   #define MYSERIAL0 MSerial5
95
+#else
96
+  #error "SERIAL_PORT must be from -1 to 5. Please update your configuration."
98 97
 #endif
99 98
 
100 99
 #ifdef SERIAL_PORT_2
101
-  #if !WITHIN(SERIAL_PORT_2, -1, 5)
102
-    #error "SERIAL_PORT_2 must be from -1 to 5"
100
+  #if SERIAL_PORT_2 == 0
101
+    #error "SERIAL_PORT_2 cannot be 0. (Port 0 does not exist.) Please update your configuration."
103 102
   #elif SERIAL_PORT_2 == SERIAL_PORT
104
-    #error "SERIAL_PORT_2 must be different than SERIAL_PORT"
105
-  #endif
106
-  #define NUM_SERIAL 2
107
-  #if SERIAL_PORT_2 == -1
103
+    #error "SERIAL_PORT_2 must be different than SERIAL_PORT. Please update your configuration."
104
+  #elif SERIAL_PORT_2 == -1
108 105
     #define MYSERIAL1 UsbSerial
109
-  #elif SERIAL_PORT_2 == 0
110
-  #error "Serial port 0 does not exist"
111 106
   #elif SERIAL_PORT_2 == 1
112 107
     #define MYSERIAL1 MSerial1
113 108
   #elif SERIAL_PORT_2 == 2
@@ -118,11 +113,39 @@
118 113
     #define MYSERIAL1 MSerial4
119 114
   #elif SERIAL_PORT_2 == 5
120 115
     #define MYSERIAL1 MSerial5
116
+  #else
117
+    #error "SERIAL_PORT_2 must be from -1 to 5. Please update your configuration."
121 118
   #endif
119
+  #define NUM_SERIAL 2
122 120
 #else
123 121
   #define NUM_SERIAL 1
124 122
 #endif
125 123
 
124
+#ifdef DGUS_SERIAL
125
+  #if DGUS_SERIAL_PORT == 0
126
+    #error "DGUS_SERIAL_PORT cannot be 0. (Port 0 does not exist.) Please update your configuration."
127
+  #elif DGUS_SERIAL_PORT == SERIAL_PORT
128
+    #error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration."
129
+  #elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
130
+    #error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
131
+  #elif DGUS_SERIAL_PORT == -1
132
+    #define DGUS_SERIAL UsbSerial
133
+  #elif DGUS_SERIAL_PORT == 1
134
+    #define DGUS_SERIAL MSerial1
135
+  #elif DGUS_SERIAL_PORT == 2
136
+    #define DGUS_SERIAL MSerial2
137
+  #elif DGUS_SERIAL_PORT == 3
138
+    #define DGUS_SERIAL MSerial3
139
+  #elif DGUS_SERIAL_PORT == 4
140
+    #define DGUS_SERIAL MSerial4
141
+  #elif DGUS_SERIAL_PORT == 5
142
+    #define DGUS_SERIAL MSerial5
143
+  #else
144
+    #error "DGUS_SERIAL_PORT must be from -1 to 5. Please update your configuration."
145
+  #endif
146
+#endif
147
+
148
+
126 149
 // Set interrupt grouping for this MCU
127 150
 void HAL_init();
128 151
 #define HAL_IDLETASK 1

+ 13
- 2
Marlin/src/HAL/HAL_STM32F1/dogm/u8g_com_stm32duino_fsmc.cpp Ver fichero

@@ -49,6 +49,7 @@
49 49
 void LCD_IO_Init(uint8_t cs, uint8_t rs);
50 50
 void LCD_IO_WriteData(uint16_t RegValue);
51 51
 void LCD_IO_WriteReg(uint16_t Reg);
52
+uint16_t LCD_IO_ReadData(uint16_t RegValue);
52 53
 uint32_t LCD_IO_ReadData(uint16_t RegValue, uint8_t ReadSize);
53 54
 #ifdef LCD_USE_DMA_FSMC
54 55
   void LCD_IO_WriteMultiple(uint16_t data, uint32_t count);
@@ -79,8 +80,11 @@ uint8_t u8g_com_stm32duino_fsmc_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, voi
79 80
       LCD_IO_Init(u8g->pin_list[U8G_PI_CS], u8g->pin_list[U8G_PI_A0]);
80 81
       u8g_Delay(50);
81 82
 
82
-      if (arg_ptr)
83
-        *((uint32_t *)arg_ptr) = LCD_IO_ReadData(LCD_READ_ID, 3);
83
+      if (arg_ptr) {
84
+        *((uint32_t *)arg_ptr) = LCD_IO_ReadData(0x0000);
85
+        if (*((uint32_t *)arg_ptr) == 0)
86
+          *((uint32_t *)arg_ptr) = (LCD_READ_ID << 24) | LCD_IO_ReadData(LCD_READ_ID, 3);
87
+      }
84 88
       isCommand = 0;
85 89
       break;
86 90
 
@@ -265,6 +269,13 @@ void LCD_IO_WriteReg(uint16_t Reg) {
265 269
   __DSB();
266 270
 }
267 271
 
272
+uint16_t LCD_IO_ReadData(uint16_t RegValue) {
273
+  LCD->REG = RegValue;
274
+  __DSB();
275
+
276
+  return LCD->RAM;
277
+}
278
+
268 279
 uint32_t LCD_IO_ReadData(uint16_t RegValue, uint8_t ReadSize) {
269 280
   volatile uint32_t data;
270 281
   LCD->REG = RegValue;

+ 6
- 0
Marlin/src/HAL/HAL_STM32F1/endstop_interrupts.h Ver fichero

@@ -83,6 +83,12 @@ void setup_endstop_interrupts() {
83 83
   #if HAS_Z3_MIN
84 84
     attachInterrupt(Z3_MIN_PIN, endstop_ISR, CHANGE);
85 85
   #endif
86
+    #if HAS_Z4_MAX
87
+    attachInterrupt(Z4_MAX_PIN, endstop_ISR, CHANGE);
88
+  #endif
89
+  #if HAS_Z4_MIN
90
+    attachInterrupt(Z4_MIN_PIN, endstop_ISR, CHANGE);
91
+  #endif
86 92
   #if HAS_Z_MIN_PROBE_PIN
87 93
     attachInterrupt(Z_MIN_PROBE_PIN, endstop_ISR, CHANGE);
88 94
   #endif

+ 1
- 1
Marlin/src/HAL/HAL_STM32F1/inc/SanityCheck.h Ver fichero

@@ -37,7 +37,7 @@
37 37
   #error "FAST_PWM_FAN is not yet implemented for this platform."
38 38
 #endif
39 39
 
40
-#if !defined(HAVE_SW_SERIAL) && HAS_TMC220x
40
+#if !defined(HAVE_SW_SERIAL) && TMC_HAS_SW_SERIAL
41 41
   #warning "With TMC2208/9 consider using SoftwareSerialM with HAVE_SW_SERIAL and appropriate SS_TIMER."
42 42
   #error "Missing SoftwareSerial implementation."
43 43
 #endif

+ 37
- 16
Marlin/src/HAL/HAL_STM32_F4_F7/HAL.h Ver fichero

@@ -44,17 +44,12 @@
44 44
 // Defines
45 45
 // ------------------------
46 46
 
47
-//Serial override
47
+// Serial override
48 48
 //extern HalSerial usb_serial;
49 49
 
50 50
 #if defined(STM32F4) && SERIAL_PORT == 0
51
-  #error "Serial port 0 does not exist"
52
-#endif
53
-
54
-#if !WITHIN(SERIAL_PORT, -1, 6)
55
-  #error "SERIAL_PORT must be from -1 to 6"
56
-#endif
57
-#if SERIAL_PORT == -1
51
+  #error "SERIAL_PORT cannot be 0. (Port 0 does not exist.) Please update your configuration."
52
+#elif SERIAL_PORT == -1
58 53
   #define MYSERIAL0 SerialUSB
59 54
 #elif SERIAL_PORT == 1
60 55
   #define MYSERIAL0 SerialUART1
@@ -68,19 +63,16 @@
68 63
   #define MYSERIAL0 SerialUART5
69 64
 #elif SERIAL_PORT == 6
70 65
   #define MYSERIAL0 SerialUART6
66
+#else
67
+  #error "SERIAL_PORT must be from -1 to 6. Please update your configuration."
71 68
 #endif
72 69
 
73 70
 #ifdef SERIAL_PORT_2
74 71
   #if defined(STM32F4) && SERIAL_PORT_2 == 0
75
-    #error "Serial port 0 does not exist"
76
-  #endif
77
-  #if !WITHIN(SERIAL_PORT_2, -1, 6)
78
-    #error "SERIAL_PORT_2 must be from -1 to 6"
72
+    #error "SERIAL_PORT_2 cannot be 0. (Port 0 does not exist.) Please update your configuration."
79 73
   #elif SERIAL_PORT_2 == SERIAL_PORT
80
-    #error "SERIAL_PORT_2 must be different than SERIAL_PORT"
81
-  #endif
82
-  #define NUM_SERIAL 2
83
-  #if SERIAL_PORT_2 == -1
74
+    #error "SERIAL_PORT_2 must be different than SERIAL_PORT. Please update your configuration."
75
+  #elif SERIAL_PORT_2 == -1
84 76
     #define MYSERIAL1 SerialUSB
85 77
   #elif SERIAL_PORT_2 == 1
86 78
     #define MYSERIAL1 SerialUART1
@@ -94,11 +86,40 @@
94 86
     #define MYSERIAL1 SerialUART5
95 87
   #elif SERIAL_PORT_2 == 6
96 88
     #define MYSERIAL1 SerialUART6
89
+  #else
90
+    #error "SERIAL_PORT_2 must be from -1 to 6. Please update your configuration."
97 91
   #endif
92
+  #define NUM_SERIAL 2
98 93
 #else
99 94
   #define NUM_SERIAL 1
100 95
 #endif
101 96
 
97
+#ifdef DGUS_SERIAL_PORT
98
+  #if defined(STM32F4) && DGUS_SERIAL_PORT == 0
99
+    #error "DGUS_SERIAL_PORT cannot be 0. (Port 0 does not exist.) Please update your configuration."
100
+  #elif DGUS_SERIAL_PORT == SERIAL_PORT
101
+    #error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration."
102
+  #elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
103
+    #error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
104
+  #elif DGUS_SERIAL_PORT == -1
105
+    #define DGUS_SERIAL SerialUSB
106
+  #elif DGUS_SERIAL_PORT == 1
107
+    #define DGUS_SERIAL SerialUART1
108
+  #elif DGUS_SERIAL_PORT == 2
109
+    #define DGUS_SERIAL SerialUART2
110
+  #elif DGUS_SERIAL_PORT == 3
111
+    #define DGUS_SERIAL SerialUART3
112
+  #elif DGUS_SERIAL_PORT == 4
113
+    #define DGUS_SERIAL SerialUART4
114
+  #elif DGUS_SERIAL_PORT == 5
115
+    #define DGUS_SERIAL SerialUART5
116
+  #elif DGUS_SERIAL_PORT == 6
117
+    #define DGUS_SERIAL SerialUART6
118
+  #else
119
+    #error "DGUS_SERIAL_PORT must be from -1 to 6. Please update your configuration."
120
+  #endif
121
+#endif
122
+
102 123
 /**
103 124
  * TODO: review this to return 1 for pins that are not analog input
104 125
  */

+ 1
- 1
Marlin/src/HAL/HAL_STM32_F4_F7/STM32F7/TMC2660.cpp Ver fichero

@@ -36,7 +36,7 @@
36 36
 #include "TMC2660.h"
37 37
 
38 38
 #include "../../../inc/MarlinConfig.h"
39
-#include "../../../Marlin.h"
39
+#include "../../../MarlinCore.h"
40 40
 #include "../../../module/stepper/indirection.h"
41 41
 #include "../../../module/printcounter.h"
42 42
 #include "../../../libs/duration_t.h"

+ 6
- 0
Marlin/src/HAL/HAL_STM32_F4_F7/endstop_interrupts.h Ver fichero

@@ -58,6 +58,12 @@ void setup_endstop_interrupts() {
58 58
   #if HAS_Z3_MIN
59 59
     attachInterrupt(Z3_MIN_PIN, endstop_ISR, CHANGE);
60 60
   #endif
61
+  #if HAS_Z4_MAX
62
+    attachInterrupt(Z4_MAX_PIN, endstop_ISR, CHANGE);
63
+  #endif
64
+  #if HAS_Z4_MIN
65
+    attachInterrupt(Z4_MIN_PIN, endstop_ISR, CHANGE);
66
+  #endif
61 67
   #if HAS_Z_MIN_PROBE_PIN
62 68
     attachInterrupt(Z_MIN_PROBE_PIN, endstop_ISR, CHANGE);
63 69
   #endif

+ 4
- 0
Marlin/src/HAL/HAL_STM32_F4_F7/inc/SanityCheck.h Ver fichero

@@ -35,3 +35,7 @@
35 35
 #if ENABLED(FAST_PWM_FAN)
36 36
   #error "FAST_PWM_FAN is not yet implemented for this platform."
37 37
 #endif
38
+
39
+#if TMC_HAS_SW_SERIAL
40
+  #error "TMC220x Software Serial is not supported on this platform."
41
+#endif

+ 4
- 0
Marlin/src/HAL/HAL_TEENSY31_32/inc/SanityCheck.h Ver fichero

@@ -32,3 +32,7 @@
32 32
 #if ENABLED(FAST_PWM_FAN)
33 33
   #error "FAST_PWM_FAN is not yet implemented for this platform."
34 34
 #endif
35
+
36
+#if TMC_HAS_SW_SERIAL
37
+  #error "TMC220x Software Serial is not supported on this platform."
38
+#endif

+ 1
- 1
Marlin/src/HAL/HAL_TEENSY35_36/HAL.cpp Ver fichero

@@ -94,7 +94,7 @@ extern "C" {
94 94
 }
95 95
 
96 96
 void HAL_adc_start_conversion(const uint8_t adc_pin) {
97
-  uint16_t pin = pin2sc1a[adc_pin];
97
+  const uint16_t pin = pin2sc1a[adc_pin];
98 98
   if (pin == 0xFF) {
99 99
     // Digital only
100 100
     HAL_adc_select = -1;

+ 6
- 0
Marlin/src/HAL/HAL_TEENSY35_36/endstop_interrupts.h Ver fichero

@@ -76,6 +76,12 @@ void setup_endstop_interrupts() {
76 76
   #if HAS_Z3_MIN
77 77
     _ATTACH(Z3_MIN_PIN);
78 78
   #endif
79
+  #if HAS_Z4_MAX
80
+    _ATTACH(Z4_MAX_PIN);
81
+  #endif
82
+  #if HAS_Z4_MIN
83
+    _ATTACH(Z4_MIN_PIN);
84
+  #endif
79 85
   #if HAS_Z_MIN_PROBE_PIN
80 86
     _ATTACH(Z_MIN_PROBE_PIN);
81 87
   #endif

+ 4
- 0
Marlin/src/HAL/HAL_TEENSY35_36/inc/SanityCheck.h Ver fichero

@@ -32,3 +32,7 @@
32 32
 #if ENABLED(FAST_PWM_FAN)
33 33
   #error "FAST_PWM_FAN is not yet implemented for this platform."
34 34
 #endif
35
+
36
+#if TMC_HAS_SW_SERIAL
37
+  #error "TMC220x Software Serial is not supported on this platform."
38
+#endif

+ 1
- 15
Marlin/src/HAL/shared/Delay.h Ver fichero

@@ -145,21 +145,7 @@
145 145
   }
146 146
   #undef nop
147 147
 
148
-#elif defined(ESP32)
149
-
150
-  FORCE_INLINE static void DELAY_CYCLES(uint32_t x) {
151
-    unsigned long ccount, stop;
152
-
153
-    __asm__ __volatile__ ( "rsr     %0, ccount" : "=a" (ccount) );
154
-
155
-    stop = ccount + x; // This can overflow
156
-
157
-    while (ccount < stop) { // This doesn't deal with overflows
158
-      __asm__ __volatile__ ( "rsr     %0, ccount" : "=a" (ccount) );
159
-    }
160
-  }
161
-
162
-#elif defined(__PLAT_LINUX__)
148
+#elif defined(__PLAT_LINUX__) || defined(ESP32)
163 149
 
164 150
   // specified inside platform
165 151
 

+ 44
- 33
Marlin/src/HAL/shared/HAL_spi_L6470.cpp Ver fichero

@@ -27,12 +27,12 @@
27 27
 
28 28
 #include "../../inc/MarlinConfig.h"
29 29
 
30
-#if HAS_DRIVER(L6470)
30
+#if HAS_L64XX
31 31
 
32 32
 #include "Delay.h"
33 33
 
34 34
 #include "../../core/serial.h"
35
-#include "../../libs/L6470/L6470_Marlin.h"
35
+#include "../../libs/L64XX/L64XX_Marlin.h"
36 36
 
37 37
 // Make sure GCC optimizes this file.
38 38
 // Note that this line triggers a bug in GCC which is fixed by casting.
@@ -40,7 +40,7 @@
40 40
 #pragma GCC optimize (3)
41 41
 
42 42
 // run at ~4Mhz
43
-uint8_t L6470_SpiTransfer_Mode_0(uint8_t b) { // using Mode 0
43
+inline uint8_t L6470_SpiTransfer_Mode_0(uint8_t b) { // using Mode 0
44 44
   for (uint8_t bits = 8; bits--;) {
45 45
     WRITE(L6470_CHAIN_MOSI_PIN, b & 0x80);
46 46
     b <<= 1;        // little setup time
@@ -56,39 +56,60 @@ uint8_t L6470_SpiTransfer_Mode_0(uint8_t b) { // using Mode 0
56 56
   return b;
57 57
 }
58 58
 
59
-uint8_t L6470_SpiTransfer_Mode_3(uint8_t b) { // using Mode 3
59
+inline uint8_t L6470_SpiTransfer_Mode_3(uint8_t b) { // using Mode 3
60 60
   for (uint8_t bits = 8; bits--;) {
61 61
     WRITE(L6470_CHAIN_SCK_PIN, LOW);
62 62
     WRITE(L6470_CHAIN_MOSI_PIN, b & 0x80);
63 63
 
64 64
     DELAY_NS(125);  // 10 cycles @ 84mhz
65
-
66 65
     WRITE(L6470_CHAIN_SCK_PIN, HIGH);
66
+    DELAY_NS(125);  // Need more delay for fast CPUs
67 67
 
68 68
     b <<= 1;        // little setup time
69 69
     b |= (READ(L6470_CHAIN_MISO_PIN) != 0);
70 70
   }
71
-
72
-  DELAY_NS(125);  // 10 cycles @ 84mhz
71
+  DELAY_NS(125);    // 10 cycles @ 84mhz
73 72
   return b;
74 73
 }
75 74
 
76 75
 /**
77
- * The following are weak-linked and defined as do-nothing
78
- * functions by the L6470-Arduino library. They must be
79
- * defined by the client (Marlin) to provide an SPI interface.
76
+ * L64XX methods for SPI init and transfer
80 77
  */
78
+void L64XX_Marlin::spi_init() {
79
+  OUT_WRITE(L6470_CHAIN_SS_PIN, HIGH);
80
+  OUT_WRITE(L6470_CHAIN_SCK_PIN, HIGH);
81
+  OUT_WRITE(L6470_CHAIN_MOSI_PIN, HIGH);
82
+  SET_INPUT(L6470_CHAIN_MISO_PIN);
83
+
84
+  #if PIN_EXISTS(L6470_BUSY)
85
+    SET_INPUT(L6470_BUSY_PIN);
86
+  #endif
81 87
 
82
-uint8_t L6470_transfer(uint8_t data, int16_t ss_pin, const uint8_t chain_position) {
88
+  OUT_WRITE(L6470_CHAIN_MOSI_PIN, HIGH);
89
+}
90
+
91
+uint8_t L64XX_Marlin::transfer_single(uint8_t data, int16_t ss_pin) {
92
+  // First device in chain has data sent last
93
+  extDigitalWrite(ss_pin, LOW);
94
+
95
+  DISABLE_ISRS(); // Disable interrupts during SPI transfer (can't allow partial command to chips)
96
+  const uint8_t data_out = L6470_SpiTransfer_Mode_3(data);
97
+  ENABLE_ISRS();  // Enable interrupts
98
+
99
+  extDigitalWrite(ss_pin, HIGH);
100
+  return data_out;
101
+}
102
+
103
+uint8_t L64XX_Marlin::transfer_chain(uint8_t data, int16_t ss_pin, uint8_t chain_position) {
83 104
   uint8_t data_out = 0;
84 105
 
85 106
   // first device in chain has data sent last
86 107
   extDigitalWrite(ss_pin, LOW);
87 108
 
88
-  for (uint8_t i = L6470::chain[0]; (i >= 1) && !spi_abort; i--) {    // stop sending data if spi_abort is active
89
-    DISABLE_ISRS();  // disable interrupts during SPI transfer (can't allow partial command to chips)
90
-    uint8_t temp = L6470_SpiTransfer_Mode_3(uint8_t(i == chain_position ? data : dSPIN_NOP));
91
-    ENABLE_ISRS();  // enable interrupts
109
+  for (uint8_t i = L64XX::chain[0]; !L64xxManager.spi_abort && i >= 1; i--) {   // Send data unless aborted
110
+    DISABLE_ISRS();   // Disable interrupts during SPI transfer (can't allow partial command to chips)
111
+    const uint8_t temp = L6470_SpiTransfer_Mode_3(uint8_t(i == chain_position ? data : dSPIN_NOP));
112
+    ENABLE_ISRS();    // Enable interrupts
92 113
     if (i == chain_position) data_out = temp;
93 114
   }
94 115
 
@@ -96,11 +117,14 @@ uint8_t L6470_transfer(uint8_t data, int16_t ss_pin, const uint8_t chain_positio
96 117
   return data_out;
97 118
 }
98 119
 
99
-void L6470_transfer(uint8_t L6470_buf[], const uint8_t length) {
100
-  // first device in chain has data sent last
120
+/**
121
+ * Platform-supplied L6470 buffer transfer method
122
+ */
123
+void L64XX_Marlin::transfer(uint8_t L6470_buf[], const uint8_t length) {
124
+  // First device in chain has its data sent last
101 125
 
102
-  if (spi_active) {                    // interrupted SPI transfer so need to
103
-    WRITE(L6470_CHAIN_SS_PIN, HIGH);   // guarantee min high of 650nS
126
+  if (spi_active) {                   // Interrupted SPI transfer so need to
127
+    WRITE(L6470_CHAIN_SS_PIN, HIGH);  //  guarantee min high of 650ns
104 128
     DELAY_US(1);
105 129
   }
106 130
 
@@ -110,19 +134,6 @@ void L6470_transfer(uint8_t L6470_buf[], const uint8_t length) {
110 134
   WRITE(L6470_CHAIN_SS_PIN, HIGH);
111 135
 }
112 136
 
113
-void L6470_spi_init() {
114
-  OUT_WRITE(L6470_CHAIN_SS_PIN, HIGH);
115
-  OUT_WRITE(L6470_CHAIN_SCK_PIN, HIGH);
116
-  OUT_WRITE(L6470_CHAIN_MOSI_PIN, HIGH);
117
-  SET_INPUT(L6470_CHAIN_MISO_PIN);
118
-
119
-  #if PIN_EXISTS(L6470_BUSY)
120
-    SET_INPUT(L6470_BUSY_PIN);
121
-  #endif
122
-
123
-  OUT_WRITE(L6470_CHAIN_MOSI_PIN, HIGH);
124
-}
125
-
126 137
 #pragma GCC reset_options
127 138
 
128
-#endif // HAS_DRIVER(L6470)
139
+#endif // HAS_L64XX

+ 7
- 0
Marlin/src/HAL/shared/MarlinSerial.h Ver fichero

@@ -28,6 +28,13 @@
28 28
 #include "../../inc/MarlinConfigPre.h"
29 29
 
30 30
 constexpr bool
31
+  #if HAS_DGUS_LCD
32
+    bDGUS_SERIAL_STATS_RX_BUFFER_OVERRUNS = (false
33
+      #if ENABLED(DGUS_SERIAL_STATS_RX_BUFFER_OVERRUNS)
34
+        || true
35
+      #endif
36
+    ),
37
+  #endif
31 38
   bSERIAL_XON_XOFF = (false
32 39
     #if ENABLED(SERIAL_XON_XOFF)
33 40
       || true

+ 1
- 1
Marlin/src/HAL/shared/backtrace/backtrace.cpp Ver fichero

@@ -35,7 +35,7 @@ static bool UnwReportOut(void* ctx, const UnwReport* bte) {
35 35
 
36 36
   (*p)++;
37 37
 
38
-  SERIAL_CHAR('#'); SERIAL_PRINT(*p,DEC); SERIAL_ECHOPGM(" : ");
38
+  SERIAL_CHAR('#'); SERIAL_PRINT(*p, DEC); SERIAL_ECHOPGM(" : ");
39 39
   SERIAL_ECHOPGM(bte->name ? bte->name : "unknown"); SERIAL_ECHOPGM("@0x"); SERIAL_PRINT(bte->function, HEX);
40 40
   SERIAL_CHAR('+'); SERIAL_PRINT(bte->address - bte->function,DEC);
41 41
   SERIAL_ECHOPGM(" PC:"); SERIAL_PRINT(bte->address,HEX); SERIAL_CHAR('\n');

+ 1
- 1
Marlin/src/HAL/shared/backtrace/unwinder.h Ver fichero

@@ -164,7 +164,7 @@ typedef struct {
164 164
  * link register (i.e. not a normal register) and the stack pointer value
165 165
  * supplied.
166 166
  *
167
- * -If the program was compiled with -funwind-tables , it will use them to
167
+ * -If the program was compiled with -funwind-tables it will use them to
168 168
  * perform the traceback. Otherwise, brute force will be employed
169 169
  * -If the program was compiled with -mpoke-function-name, then you will
170 170
  * get function names in the traceback. Otherwise, you will not.

+ 0
- 381
Marlin/src/Marlin.h Ver fichero

@@ -1,381 +0,0 @@
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
-#pragma once
23
-
24
-#include "inc/MarlinConfig.h"
25
-
26
-#ifdef DEBUG_GCODE_PARSER
27
-  #include "gcode/parser.h"
28
-#endif
29
-
30
-#include <math.h>
31
-#include <stdio.h>
32
-#include <stdlib.h>
33
-
34
-#if HAS_DRIVER(L6470)
35
-  #include "libs/L6470/L6470_Marlin.h"
36
-  extern uint8_t axis_known_position;
37
-#endif
38
-
39
-void stop();
40
-
41
-void idle(
42
-  #if ENABLED(ADVANCED_PAUSE_FEATURE)
43
-    bool no_stepper_sleep = false  // pass true to keep steppers from disabling on timeout
44
-  #endif
45
-);
46
-
47
-void manage_inactivity(const bool ignore_stepper_queue=false);
48
-
49
-//
50
-// X, Y, Z Stepper enable / disable
51
-//
52
-#if AXIS_DRIVER_TYPE_X(L6470)
53
-  extern L6470 stepperX;
54
-  #define X_enable()  NOOP
55
-  #define X_disable() stepperX.free()
56
-#elif HAS_X_ENABLE
57
-  #define X_enable()  X_ENABLE_WRITE( X_ENABLE_ON)
58
-  #define X_disable() X_ENABLE_WRITE(!X_ENABLE_ON)
59
-#else
60
-  #define X_enable()  NOOP
61
-  #define X_disable() NOOP
62
-#endif
63
-
64
-#if AXIS_DRIVER_TYPE_X2(L6470)
65
-  extern L6470 stepperX2;
66
-  #define X2_enable()  NOOP
67
-  #define X2_disable() stepperX2.free()
68
-#elif HAS_X2_ENABLE
69
-  #define X2_enable()  X2_ENABLE_WRITE( X_ENABLE_ON)
70
-  #define X2_disable() X2_ENABLE_WRITE(!X_ENABLE_ON)
71
-#else
72
-  #define X2_enable()  NOOP
73
-  #define X2_disable() NOOP
74
-#endif
75
-
76
-#define  enable_X() do{ X_enable(); X2_enable(); }while(0)
77
-#define disable_X() do{ X_disable(); X2_disable(); CBI(axis_known_position, X_AXIS); }while(0)
78
-
79
-#if AXIS_DRIVER_TYPE_Y(L6470)
80
-  extern L6470 stepperY;
81
-  #define Y_enable()  NOOP
82
-  #define Y_disable() stepperY.free()
83
-#elif HAS_Y_ENABLE
84
-  #define Y_enable()  Y_ENABLE_WRITE( Y_ENABLE_ON)
85
-  #define Y_disable() Y_ENABLE_WRITE(!Y_ENABLE_ON)
86
-#else
87
-  #define Y_enable()  NOOP
88
-  #define Y_disable() NOOP
89
-#endif
90
-
91
-#if AXIS_DRIVER_TYPE_Y2(L6470)
92
-  extern L6470 stepperY2;
93
-  #define Y2_enable()  NOOP
94
-  #define Y2_disable() stepperY2.free()
95
-#elif HAS_Y2_ENABLE
96
-  #define Y2_enable()  Y2_ENABLE_WRITE( Y_ENABLE_ON)
97
-  #define Y2_disable() Y2_ENABLE_WRITE(!Y_ENABLE_ON)
98
-#else
99
-  #define Y2_enable()  NOOP
100
-  #define Y2_disable() NOOP
101
-#endif
102
-
103
-#define  enable_Y() do{ Y_enable(); Y2_enable(); }while(0)
104
-#define disable_Y() do{ Y_disable(); Y2_disable(); CBI(axis_known_position, Y_AXIS); }while(0)
105
-
106
-#if AXIS_DRIVER_TYPE_Z(L6470)
107
-  extern L6470 stepperZ;
108
-  #define Z_enable()  NOOP
109
-  #define Z_disable() stepperZ.free()
110
-#elif HAS_Z_ENABLE
111
-  #define Z_enable()  Z_ENABLE_WRITE( Z_ENABLE_ON)
112
-  #define Z_disable() Z_ENABLE_WRITE(!Z_ENABLE_ON)
113
-#else
114
-  #define Z_enable()  NOOP
115
-  #define Z_disable() NOOP
116
-#endif
117
-
118
-#if AXIS_DRIVER_TYPE_Z2(L6470)
119
-  extern L6470 stepperZ2;
120
-  #define Z2_enable()  NOOP
121
-  #define Z2_disable() stepperZ2.free()
122
-#elif HAS_Z2_ENABLE
123
-  #define Z2_enable()  Z2_ENABLE_WRITE( Z_ENABLE_ON)
124
-  #define Z2_disable() Z2_ENABLE_WRITE(!Z_ENABLE_ON)
125
-#else
126
-  #define Z2_enable()  NOOP
127
-  #define Z2_disable() NOOP
128
-#endif
129
-
130
-#if AXIS_DRIVER_TYPE_Z3(L6470)
131
-  extern L6470 stepperZ3;
132
-  #define Z3_enable()  NOOP
133
-  #define Z3_disable() stepperZ3.free()
134
-#elif HAS_Z3_ENABLE
135
-  #define Z3_enable()  Z3_ENABLE_WRITE( Z_ENABLE_ON)
136
-  #define Z3_disable() Z3_ENABLE_WRITE(!Z_ENABLE_ON)
137
-#else
138
-  #define Z3_enable()  NOOP
139
-  #define Z3_disable() NOOP
140
-#endif
141
-
142
-#define  enable_Z() do{ Z_enable(); Z2_enable(); Z3_enable(); }while(0)
143
-#define disable_Z() do{ Z_disable(); Z2_disable(); Z3_disable(); CBI(axis_known_position, Z_AXIS); }while(0)
144
-
145
-//
146
-// Extruder Stepper enable / disable
147
-//
148
-
149
-// define the individual enables/disables
150
-#if AXIS_DRIVER_TYPE_E0(L6470)
151
-  extern L6470 stepperE0;
152
-  #define  E0_enable() NOOP
153
-  #define E0_disable() do{ stepperE0.free(); CBI(axis_known_position, E_AXIS); }while(0)
154
-#elif HAS_E0_ENABLE
155
-  #define  E0_enable() E0_ENABLE_WRITE( E_ENABLE_ON)
156
-  #define E0_disable() E0_ENABLE_WRITE(!E_ENABLE_ON)
157
-#else
158
-  #define  E0_enable() NOOP
159
-  #define E0_disable() NOOP
160
-#endif
161
-
162
-#if AXIS_DRIVER_TYPE_E1(L6470)
163
-  extern L6470 stepperE1;
164
-  #define  E1_enable() NOOP
165
-  #define E1_disable() do{ stepperE1.free(); CBI(axis_known_position, E_AXIS); }while(0)
166
-#elif E_STEPPERS > 1 && HAS_E1_ENABLE
167
-  #define  E1_enable() E1_ENABLE_WRITE( E_ENABLE_ON)
168
-  #define E1_disable() E1_ENABLE_WRITE(!E_ENABLE_ON)
169
-#else
170
-  #define  E1_enable() NOOP
171
-  #define E1_disable() NOOP
172
-#endif
173
-
174
-#if AXIS_DRIVER_TYPE_E2(L6470)
175
-  extern L6470 stepperE2;
176
-  #define  E2_enable() NOOP
177
-  #define E2_disable() do{ stepperE2.free(); CBI(axis_known_position, E_AXIS); }while(0)
178
-#elif E_STEPPERS > 2 && HAS_E2_ENABLE
179
-  #define  E2_enable() E2_ENABLE_WRITE( E_ENABLE_ON)
180
-  #define E2_disable() E2_ENABLE_WRITE(!E_ENABLE_ON)
181
-#else
182
-  #define  E2_enable() NOOP
183
-  #define E2_disable() NOOP
184
-#endif
185
-
186
-#if AXIS_DRIVER_TYPE_E3(L6470)
187
-  extern L6470 stepperE3;
188
-  #define  E3_enable() NOOP
189
-  #define E3_disable() do{ stepperE3.free(); CBI(axis_known_position, E_AXIS); }while(0)
190
-#elif E_STEPPERS > 3 && HAS_E3_ENABLE
191
-  #define  E3_enable() E3_ENABLE_WRITE( E_ENABLE_ON)
192
-  #define E3_disable() E3_ENABLE_WRITE(!E_ENABLE_ON)
193
-#else
194
-  #define  E3_enable() NOOP
195
-  #define E3_disable() NOOP
196
-#endif
197
-
198
-#if AXIS_DRIVER_TYPE_E4(L6470)
199
-  extern L6470 stepperE4;
200
-  #define  E4_enable() NOOP
201
-  #define E4_disable() do{ stepperE4.free(); CBI(axis_known_position, E_AXIS); }while(0)
202
-#elif E_STEPPERS > 4 && HAS_E4_ENABLE
203
-  #define  E4_enable() E4_ENABLE_WRITE( E_ENABLE_ON)
204
-  #define E4_disable() E4_ENABLE_WRITE(!E_ENABLE_ON)
205
-#else
206
-  #define  E4_enable() NOOP
207
-  #define E4_disable() NOOP
208
-#endif
209
-
210
-#if AXIS_DRIVER_TYPE_E5(L6470)
211
-  extern L6470 stepperE5;
212
-  #define  E5_enable() NOOP
213
-  #define E5_disable() do{ stepperE5.free(); CBI(axis_known_position, E_AXIS); }while(0)
214
-#elif E_STEPPERS > 5 && HAS_E5_ENABLE
215
-  #define  E5_enable() E5_ENABLE_WRITE( E_ENABLE_ON)
216
-  #define E5_disable() E5_ENABLE_WRITE(!E_ENABLE_ON)
217
-#else
218
-  #define  E5_enable() NOOP
219
-  #define E5_disable() NOOP
220
-#endif
221
-
222
-#if ENABLED(MIXING_EXTRUDER)
223
-
224
-  /**
225
-   * Mixing steppers synchronize their enable (and direction) together
226
-   */
227
-  #if MIXING_STEPPERS > 5
228
-    #define  enable_E0() { E0_enable();  E1_enable();  E2_enable();  E3_enable();  E4_enable();  E5_enable(); }
229
-    #define disable_E0() { E0_disable(); E1_disable(); E2_disable(); E3_disable(); E4_disable(); E5_disable(); }
230
-  #elif MIXING_STEPPERS > 4
231
-    #define  enable_E0() { E0_enable();  E1_enable();  E2_enable();  E3_enable();  E4_enable(); }
232
-    #define disable_E0() { E0_disable(); E1_disable(); E2_disable(); E3_disable(); E4_disable(); }
233
-  #elif MIXING_STEPPERS > 3
234
-    #define  enable_E0() { E0_enable();  E1_enable();  E2_enable();  E3_enable(); }
235
-    #define disable_E0() { E0_disable(); E1_disable(); E2_disable(); E3_disable(); }
236
-  #elif MIXING_STEPPERS > 2
237
-    #define  enable_E0() { E0_enable();  E1_enable();  E2_enable(); }
238
-    #define disable_E0() { E0_disable(); E1_disable(); E2_disable(); }
239
-  #else
240
-    #define  enable_E0() { E0_enable();  E1_enable(); }
241
-    #define disable_E0() { E0_disable(); E1_disable(); }
242
-  #endif
243
-  #define  enable_E1() NOOP
244
-  #define disable_E1() NOOP
245
-  #define  enable_E2() NOOP
246
-  #define disable_E2() NOOP
247
-  #define  enable_E3() NOOP
248
-  #define disable_E3() NOOP
249
-  #define  enable_E4() NOOP
250
-  #define disable_E4() NOOP
251
-  #define  enable_E5() NOOP
252
-  #define disable_E5() NOOP
253
-
254
-#else // !MIXING_EXTRUDER
255
-
256
-  #if HAS_E0_ENABLE
257
-    #define  enable_E0() E0_enable()
258
-    #define disable_E0() E0_disable()
259
-  #else
260
-    #define  enable_E0() NOOP
261
-    #define disable_E0() NOOP
262
-  #endif
263
-
264
-  #if E_STEPPERS > 1 && HAS_E1_ENABLE
265
-    #define  enable_E1() E1_enable()
266
-    #define disable_E1() E1_disable()
267
-  #else
268
-    #define  enable_E1() NOOP
269
-    #define disable_E1() NOOP
270
-  #endif
271
-
272
-  #if E_STEPPERS > 2 && HAS_E2_ENABLE
273
-    #define  enable_E2() E2_enable()
274
-    #define disable_E2() E2_disable()
275
-  #else
276
-    #define  enable_E2() NOOP
277
-    #define disable_E2() NOOP
278
-  #endif
279
-
280
-  #if E_STEPPERS > 3 && HAS_E3_ENABLE
281
-    #define  enable_E3() E3_enable()
282
-    #define disable_E3() E3_disable()
283
-  #else
284
-    #define  enable_E3() NOOP
285
-    #define disable_E3() NOOP
286
-  #endif
287
-
288
-  #if E_STEPPERS > 4 && HAS_E4_ENABLE
289
-    #define  enable_E4() E4_enable()
290
-    #define disable_E4() E4_disable()
291
-  #else
292
-    #define  enable_E4() NOOP
293
-    #define disable_E4() NOOP
294
-  #endif
295
-
296
-  #if E_STEPPERS > 5 && HAS_E5_ENABLE
297
-    #define  enable_E5() E5_enable()
298
-    #define disable_E5() E5_disable()
299
-  #else
300
-    #define  enable_E5() NOOP
301
-    #define disable_E5() NOOP
302
-  #endif
303
-
304
-#endif // !MIXING_EXTRUDER
305
-
306
-#if ENABLED(EXPERIMENTAL_I2CBUS)
307
-  #include "feature/twibus.h"
308
-  extern TWIBus i2c;
309
-#endif
310
-
311
-#if ENABLED(G38_PROBE_TARGET)
312
-  extern uint8_t G38_move;          // Flag to tell the ISR that G38 is in progress, and the type
313
-  extern bool G38_did_trigger;      // Flag from the ISR to indicate the endstop changed
314
-#endif
315
-
316
-/**
317
- * The axis order in all axis related arrays is X, Y, Z, E
318
- */
319
-void enable_e_steppers();
320
-void enable_all_steppers();
321
-void disable_e_stepper(const uint8_t e);
322
-void disable_e_steppers();
323
-void disable_all_steppers();
324
-
325
-void kill(PGM_P const lcd_error=nullptr, PGM_P const lcd_component=nullptr, const bool steppers_off=false);
326
-void minkill(const bool steppers_off=false);
327
-
328
-void quickstop_stepper();
329
-
330
-extern bool Running;
331
-inline bool IsRunning() { return  Running; }
332
-inline bool IsStopped() { return !Running; }
333
-
334
-bool printingIsActive();
335
-bool printingIsPaused();
336
-void startOrResumeJob();
337
-
338
-extern bool wait_for_heatup;
339
-
340
-#if HAS_RESUME_CONTINUE
341
-  extern bool wait_for_user;
342
-#endif
343
-
344
-#if HAS_AUTO_REPORTING || ENABLED(HOST_KEEPALIVE_FEATURE)
345
-  extern bool suspend_auto_report;
346
-#endif
347
-
348
-// Inactivity shutdown timer
349
-extern millis_t max_inactive_time, stepper_inactive_time;
350
-
351
-#if ENABLED(USE_CONTROLLER_FAN)
352
-  extern uint8_t controllerfan_speed;
353
-#endif
354
-
355
-#if ENABLED(PSU_CONTROL)
356
-  extern bool powersupply_on;
357
-  #define PSU_PIN_ON()  do{ OUT_WRITE(PS_ON_PIN,  PSU_ACTIVE_HIGH); powersupply_on = true; }while(0)
358
-  #define PSU_PIN_OFF() do{ OUT_WRITE(PS_ON_PIN, !PSU_ACTIVE_HIGH); powersupply_on = false; }while(0)
359
-  #if ENABLED(AUTO_POWER_CONTROL)
360
-    #define PSU_ON()  powerManager.power_on()
361
-    #define PSU_OFF() powerManager.power_off()
362
-  #else
363
-    #define PSU_ON()  PSU_PIN_ON()
364
-    #define PSU_OFF() PSU_PIN_OFF()
365
-  #endif
366
-#endif
367
-
368
-bool pin_is_protected(const pin_t pin);
369
-void protected_pin_err();
370
-
371
-#if HAS_SUICIDE
372
-  inline void suicide() { OUT_WRITE(SUICIDE_PIN, SUICIDE_PIN_INVERTING); }
373
-#endif
374
-
375
-#if ENABLED(G29_RETRY_AND_RECOVER)
376
-  void event_probe_recover();
377
-  void event_probe_failure();
378
-#endif
379
-
380
-extern const char NUL_STR[], G28_STR[], M21_STR[], M23_STR[], M24_STR[],
381
-                  SP_X_STR[], SP_Y_STR[], SP_Z_STR[], SP_E_STR[];

Marlin/src/Marlin.cpp → Marlin/src/MarlinCore.cpp Ver fichero

@@ -28,7 +28,7 @@
28 28
  *  - https://github.com/grbl/grbl
29 29
  */
30 30
 
31
-#include "Marlin.h"
31
+#include "MarlinCore.h"
32 32
 
33 33
 #include "core/utility.h"
34 34
 #include "lcd/ultralcd.h"
@@ -177,11 +177,12 @@
177 177
   #include "feature/prusa_MMU2/mmu2.h"
178 178
 #endif
179 179
 
180
-#if HAS_DRIVER(L6470)
181
-  #include "libs/L6470/L6470_Marlin.h"
180
+#if HAS_L64XX
181
+  #include "libs/L64XX/L64XX_Marlin.h"
182 182
 #endif
183 183
 
184 184
 const char NUL_STR[] PROGMEM = "",
185
+           M112_KILL_STR[] PROGMEM = "M112 Shutdown",
185 186
            G28_STR[] PROGMEM = "G28",
186 187
            M21_STR[] PROGMEM = "M21",
187 188
            M23_STR[] PROGMEM = "M23 %s",
@@ -406,7 +407,7 @@ void startOrResumeJob() {
406 407
     thermalManager.zero_fan_speeds();
407 408
     wait_for_heatup = false;
408 409
     #if ENABLED(POWER_LOSS_RECOVERY)
409
-      card.removeJobRecoveryFile();
410
+      recovery.purge();
410 411
     #endif
411 412
     #ifdef EVENT_GCODE_SD_STOP
412 413
       queue.inject_P(PSTR(EVENT_GCODE_SD_STOP));
@@ -605,7 +606,7 @@ void manage_inactivity(const bool ignore_stepper_queue/*=false*/) {
605 606
   #endif
606 607
 
607 608
   #if ENABLED(MONITOR_L6470_DRIVER_STATUS)
608
-    L6470.monitor_driver();
609
+    L64xxManager.monitor_driver();
609 610
   #endif
610 611
 
611 612
   // Limit check_axes_activity frequency to 10Hz
@@ -618,7 +619,7 @@ void manage_inactivity(const bool ignore_stepper_queue/*=false*/) {
618 619
   #if PIN_EXISTS(FET_SAFETY)
619 620
     static millis_t FET_next;
620 621
     if (ELAPSED(ms, FET_next)) {
621
-      FET_next = ms + FET_SAFETY_DELAY;  // 2uS pulse every FET_SAFETY_DELAY mS
622
+      FET_next = ms + FET_SAFETY_DELAY;  // 2µs pulse every FET_SAFETY_DELAY mS
622 623
       OUT_WRITE(FET_SAFETY_PIN, !FET_SAFETY_INVERTED);
623 624
       DELAY_US(2);
624 625
       WRITE(FET_SAFETY_PIN, FET_SAFETY_INVERTED);
@@ -822,8 +823,12 @@ void setup() {
822 823
 
823 824
   HAL_init();
824 825
 
825
-  #if HAS_DRIVER(L6470)
826
-    L6470.init();         // setup SPI and then init chips
826
+  #if HAS_L64XX
827
+    L64xxManager.init();  // Set up SPI, init drivers
828
+  #endif
829
+
830
+  #if ENABLED(SMART_EFFECTOR) && PIN_EXISTS(SMART_EFFECTOR_MOD)
831
+    OUT_WRITE(SMART_EFFECTOR_MOD_PIN, LOW);   // Put Smart Effector into NORMAL mode
827 832
   #endif
828 833
 
829 834
   #if ENABLED(MAX7219_DEBUG)
@@ -1128,10 +1133,9 @@ void setup() {
1128 1133
  *  - Call inactivity manager
1129 1134
  */
1130 1135
 void loop() {
1136
+  do {
1131 1137
 
1132
-  for (;;) {
1133
-
1134
-    idle(); // Do an idle first so boot is slightly faster
1138
+    idle();
1135 1139
 
1136 1140
     #if ENABLED(SDSUPPORT)
1137 1141
       card.checkautostart();
@@ -1141,5 +1145,10 @@ void loop() {
1141 1145
     queue.advance();
1142 1146
 
1143 1147
     endstops.event_handler();
1144
-  }
1148
+
1149
+  } while (false        // Return to caller for best compatibility
1150
+    #ifdef __AVR__
1151
+      || true           // Loop forever on slower (AVR) boards
1152
+    #endif
1153
+  );
1145 1154
 }

+ 124
- 0
Marlin/src/MarlinCore.h Ver fichero

@@ -0,0 +1,124 @@
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
+#pragma once
23
+
24
+#include "inc/MarlinConfig.h"
25
+
26
+#ifdef DEBUG_GCODE_PARSER
27
+  #include "gcode/parser.h"
28
+#endif
29
+
30
+#include <math.h>
31
+#include <stdio.h>
32
+#include <stdlib.h>
33
+
34
+#if HAS_L64XX
35
+  #include "libs/L64XX/L64XX_Marlin.h"
36
+  extern uint8_t axis_known_position;
37
+#endif
38
+
39
+void stop();
40
+
41
+void idle(
42
+  #if ENABLED(ADVANCED_PAUSE_FEATURE)
43
+    bool no_stepper_sleep = false  // pass true to keep steppers from disabling on timeout
44
+  #endif
45
+);
46
+
47
+void manage_inactivity(const bool ignore_stepper_queue=false);
48
+
49
+#if ENABLED(EXPERIMENTAL_I2CBUS)
50
+  #include "feature/twibus.h"
51
+  extern TWIBus i2c;
52
+#endif
53
+
54
+#if ENABLED(G38_PROBE_TARGET)
55
+  extern uint8_t G38_move;          // Flag to tell the ISR that G38 is in progress, and the type
56
+  extern bool G38_did_trigger;      // Flag from the ISR to indicate the endstop changed
57
+#endif
58
+
59
+/**
60
+ * The axis order in all axis related arrays is X, Y, Z, E
61
+ */
62
+void enable_e_steppers();
63
+void enable_all_steppers();
64
+void disable_e_stepper(const uint8_t e);
65
+void disable_e_steppers();
66
+void disable_all_steppers();
67
+
68
+void kill(PGM_P const lcd_error=nullptr, PGM_P const lcd_component=nullptr, const bool steppers_off=false);
69
+void minkill(const bool steppers_off=false);
70
+
71
+void quickstop_stepper();
72
+
73
+extern bool Running;
74
+inline bool IsRunning() { return  Running; }
75
+inline bool IsStopped() { return !Running; }
76
+
77
+bool printingIsActive();
78
+bool printingIsPaused();
79
+void startOrResumeJob();
80
+
81
+extern bool wait_for_heatup;
82
+
83
+#if HAS_RESUME_CONTINUE
84
+  extern bool wait_for_user;
85
+#endif
86
+
87
+#if HAS_AUTO_REPORTING || ENABLED(HOST_KEEPALIVE_FEATURE)
88
+  extern bool suspend_auto_report;
89
+#endif
90
+
91
+// Inactivity shutdown timer
92
+extern millis_t max_inactive_time, stepper_inactive_time;
93
+
94
+#if ENABLED(USE_CONTROLLER_FAN)
95
+  extern uint8_t controllerfan_speed;
96
+#endif
97
+
98
+#if ENABLED(PSU_CONTROL)
99
+  extern bool powersupply_on;
100
+  #define PSU_PIN_ON()  do{ OUT_WRITE(PS_ON_PIN,  PSU_ACTIVE_HIGH); powersupply_on = true; }while(0)
101
+  #define PSU_PIN_OFF() do{ OUT_WRITE(PS_ON_PIN, !PSU_ACTIVE_HIGH); powersupply_on = false; }while(0)
102
+  #if ENABLED(AUTO_POWER_CONTROL)
103
+    #define PSU_ON()  powerManager.power_on()
104
+    #define PSU_OFF() powerManager.power_off()
105
+  #else
106
+    #define PSU_ON()  PSU_PIN_ON()
107
+    #define PSU_OFF() PSU_PIN_OFF()
108
+  #endif
109
+#endif
110
+
111
+bool pin_is_protected(const pin_t pin);
112
+void protected_pin_err();
113
+
114
+#if HAS_SUICIDE
115
+  inline void suicide() { OUT_WRITE(SUICIDE_PIN, SUICIDE_PIN_INVERTING); }
116
+#endif
117
+
118
+#if ENABLED(G29_RETRY_AND_RECOVER)
119
+  void event_probe_recover();
120
+  void event_probe_failure();
121
+#endif
122
+
123
+extern const char NUL_STR[], M112_KILL_STR[], G28_STR[], M21_STR[], M23_STR[], M24_STR[],
124
+                  SP_X_STR[], SP_Y_STR[], SP_Z_STR[], SP_E_STR[];

+ 37
- 28
Marlin/src/core/boards.h Ver fichero

@@ -90,17 +90,18 @@
90 90
 #define BOARD_RAMPS_ENDER_4           1134  // Creality: Ender-4, CR-8
91 91
 #define BOARD_RAMPS_CREALITY          1135  // Creality: CR10S, CR20, CR-X
92 92
 #define BOARD_RAMPS_DAGOMA            1136  // Dagoma F5
93
-#define BOARD_FYSETC_F6_13            1137  // FYSETC F6
94
-#define BOARD_DUPLICATOR_I3_PLUS      1138  // Wanhao Duplicator i3 Plus
95
-#define BOARD_VORON                   1139  // VORON Design
96
-#define BOARD_TRONXY_V3_1_0           1140  // Tronxy TRONXY-V3-1.0
97
-#define BOARD_Z_BOLT_X_SERIES         1141  // Z-Bolt X Series
98
-#define BOARD_TT_OSCAR                1142  // TT OSCAR
99
-#define BOARD_OVERLORD                1143  // Overlord/Overlord Pro
100
-#define BOARD_HJC2560C_REV1           1144  // ADIMLab Gantry v1
101
-#define BOARD_HJC2560C_REV2           1145  // ADIMLab Gantry v2
102
-#define BOARD_TANGO                   1146  // BIQU Tango V1
103
-#define BOARD_MKS_GEN_L_V2            1147  // MKS GEN L V2
93
+#define BOARD_FYSETC_F6_13            1137  // FYSETC F6 1.3
94
+#define BOARD_FYSETC_F6_14            1138  // FYSETC F6 1.4
95
+#define BOARD_DUPLICATOR_I3_PLUS      1139  // Wanhao Duplicator i3 Plus
96
+#define BOARD_VORON                   1140  // VORON Design
97
+#define BOARD_TRONXY_V3_1_0           1141  // Tronxy TRONXY-V3-1.0
98
+#define BOARD_Z_BOLT_X_SERIES         1142  // Z-Bolt X Series
99
+#define BOARD_TT_OSCAR                1143  // TT OSCAR
100
+#define BOARD_OVERLORD                1144  // Overlord/Overlord Pro
101
+#define BOARD_HJC2560C_REV1           1145  // ADIMLab Gantry v1
102
+#define BOARD_HJC2560C_REV2           1146  // ADIMLab Gantry v2
103
+#define BOARD_TANGO                   1147  // BIQU Tango V1
104
+#define BOARD_MKS_GEN_L_V2            1148  // MKS GEN L V2
104 105
 
105 106
 //
106 107
 // RAMBo and derivatives
@@ -138,6 +139,7 @@
138 139
 #define BOARD_GT2560_V3_A20           1318  // Geeetech GT2560 Rev B for A20(M/D)
139 140
 #define BOARD_EINSTART_S              1319  // Einstart retrofit
140 141
 #define BOARD_WANHAO_ONEPLUS          1320  // Wanhao 0ne+ i3 Mini
142
+#define BOARD_LEAPFROG_XEED2015       1321  // Leapfrog Xeed 2015
141 143
 
142 144
 //
143 145
 // ATmega1281, ATmega2561
@@ -201,22 +203,28 @@
201 203
 #define BOARD_RAMPS_14_RE_ARM_SF      2004  // Re-ARM with RAMPS 1.4 (Power outputs: Spindle, Controller Fan)
202 204
 #define BOARD_MKS_SBASE               2005  // MKS-Sbase (Power outputs: Hotend0, Hotend1, Bed, Fan)
203 205
 #define BOARD_AZSMZ_MINI              2006  // AZSMZ Mini
204
-#define BOARD_AZTEEG_X5_GT            2007  // Azteeg X5 GT (Power outputs: Hotend0, Hotend1, Bed, Fan)
205
-#define BOARD_BIQU_BQ111_A4           2008  // BIQU BQ111-A4 (Power outputs: Hotend, Fan, Bed)
206
-#define BOARD_SELENA_COMPACT          2009  // Selena Compact (Power outputs: Hotend0, Hotend1, Bed0, Bed1, Fan0, Fan1)
207
-#define BOARD_COHESION3D_REMIX        2010  // Cohesion3D ReMix
208
-#define BOARD_COHESION3D_MINI         2011  // Cohesion3D Mini
209
-#define BOARD_SMOOTHIEBOARD           2012  // Smoothieboard
210
-#define BOARD_AZTEEG_X5_MINI_WIFI     2013  // Azteeg X5 Mini Wifi (Power outputs: Hotend0, Bed, Fan)
211
-#define BOARD_BIQU_B300_V1_0          2014  // BIQU B300_V1.0 (Power outputs: Hotend0, Fan, Bed, SPI Driver)
212
-#define BOARD_AZTEEG_X5_MINI          2015  // Azteeg X5 Mini (Power outputs: Hotend0, Bed, Fan)
213
-#define BOARD_MKS_SGEN                2016  // MKS-SGen (Power outputs: Hotend0, Hotend1, Bed, Fan)
214
-#define BOARD_MKS_SGEN_L              2017  // MKS-SGen-L (Power outputs: Hotend0, Hotend1, Bed, Fan)
215
-#define BOARD_TH3D_EZBOARD            2018  // TH3D EZBoard v1.0
216
-#define BOARD_GMARSH_X6_REV1          2019  // GMARSH X6 board, revision 1 prototype
217
-#define BOARD_BIGTREE_SKR_V1_1        2020  // BigTreeTech SKR v1.1 (Power outputs: Hotend0, Hotend1, Fan, Bed)
218
-#define BOARD_BIGTREE_SKR_V1_3        2021  // BigTreeTech SKR v1.3 (Power outputs: Hotend0, Hotend1, Fan, Bed)
219
-#define BOARD_BIGTREE_SKR_V1_4        2022  // BigTreeTech SKR v1.4 (Power outputs: Hotend0, Hotend1, Fan, Bed)
206
+#define BOARD_BIQU_BQ111_A4           2007  // BIQU BQ111-A4 (Power outputs: Hotend, Fan, Bed)
207
+#define BOARD_SELENA_COMPACT          2008  // Selena Compact (Power outputs: Hotend0, Hotend1, Bed0, Bed1, Fan0, Fan1)
208
+#define BOARD_BIQU_B300_V1_0          2009  // BIQU B300_V1.0 (Power outputs: Hotend0, Fan, Bed, SPI Driver)
209
+#define BOARD_MKS_SGEN_L              2010  // MKS-SGen-L (Power outputs: Hotend0, Hotend1, Bed, Fan)
210
+#define BOARD_GMARSH_X6_REV1          2011  // GMARSH X6 board, revision 1 prototype
211
+#define BOARD_BIGTREE_SKR_V1_1        2012  // BigTreeTech SKR v1.1 (Power outputs: Hotend0, Hotend1, Fan, Bed)
212
+#define BOARD_BIGTREE_SKR_V1_3        2013  // BigTreeTech SKR v1.3 (Power outputs: Hotend0, Hotend1, Fan, Bed)
213
+#define BOARD_BIGTREE_SKR_V1_4        2014  // BigTreeTech SKR v1.4 (Power outputs: Hotend0, Hotend1, Fan, Bed)
214
+
215
+//
216
+// LPC1769 ARM Cortex M3
217
+//
218
+
219
+#define BOARD_MKS_SGEN                2500  // MKS-SGen (Power outputs: Hotend0, Hotend1, Bed, Fan)
220
+#define BOARD_AZTEEG_X5_GT            2501  // Azteeg X5 GT (Power outputs: Hotend0, Hotend1, Bed, Fan)
221
+#define BOARD_AZTEEG_X5_MINI          2502  // Azteeg X5 Mini (Power outputs: Hotend0, Bed, Fan)
222
+#define BOARD_AZTEEG_X5_MINI_WIFI     2503  // Azteeg X5 Mini Wifi (Power outputs: Hotend0, Bed, Fan)
223
+#define BOARD_COHESION3D_REMIX        2504  // Cohesion3D ReMix
224
+#define BOARD_COHESION3D_MINI         2505  // Cohesion3D Mini
225
+#define BOARD_SMOOTHIEBOARD           2506  // Smoothieboard
226
+#define BOARD_TH3D_EZBOARD            2507  // TH3D EZBoard v1.0
227
+#define BOARD_BIGTREE_SKR_V1_4_TURBO  2508  // BigTreeTech SKR v1.4 TURBO (Power outputs: Hotend0, Hotend1, Fan, Bed)
220 228
 
221 229
 //
222 230
 // SAM3X8E ARM Cortex M3
@@ -248,6 +256,7 @@
248 256
 #define BOARD_ARCHIM1                 3023  // UltiMachine Archim1 (with DRV8825 drivers)
249 257
 #define BOARD_ARCHIM2                 3024  // UltiMachine Archim2 (with TMC2130 drivers)
250 258
 #define BOARD_ALLIGATOR               3025  // Alligator Board R2
259
+#define BOARD_CNCONTROLS_15D          3026  // Cartesio CN Controls V15 on DUE
251 260
 
252 261
 //
253 262
 // SAM3X8C ARM Cortex M3
@@ -303,7 +312,7 @@
303 312
 #define BOARD_RUMBA32                 4203  // RUMBA32 STM32F4-based controller
304 313
 #define BOARD_BLACK_STM32F407VE       4204  // BLACK_STM32F407VE
305 314
 #define BOARD_BLACK_STM32F407ZE       4205  // BLACK_STM32F407ZE
306
-#define BOARD_STEVAL                  4206  // STEVAL-3DP001V1 3D PRINTER BOARD
315
+#define BOARD_STEVAL_3DP001V1         4206  // STEVAL-3DP001V1 3D PRINTER BOARD
307 316
 #define BOARD_BIGTREE_SKR_PRO_V1_1    4207  // BigTreeTech SKR Pro v1.1 (STM32F407ZG)
308 317
 #define BOARD_BIGTREE_BTT002_V1_0     4208  // BigTreeTech BTT002 v1.0 (STM32F407VE)
309 318
 #define BOARD_LERDGE_K                4209  // Lerdge K (STM32F407ZG)

+ 74
- 42
Marlin/src/core/drivers.h Ver fichero

@@ -23,30 +23,33 @@
23 23
 
24 24
 #include "../inc/MarlinConfigPre.h"
25 25
 
26
-#define _A4988              0x001
27
-#define _A5984              0x002
28
-#define _DRV8825            0x003
29
-#define _LV8729             0x004
30
-#define _L6470              0x105
31
-#define _TB6560             0x006
32
-#define _TB6600             0x007
33
-#define _TMC2100            0x008
34
-#define _TMC2130            2130
35
-#define _TMC2130_STANDALONE 0x009
36
-#define _TMC2160            2160
37
-#define _TMC2160_STANDALONE 2161
38
-#define _TMC2208            2208
39
-#define _TMC2208_STANDALONE 0x00A
40
-#define _TMC2209            2209
41
-#define _TMC2209_STANDALONE 0x00D
42
-#define _TMC26X             0x10B
43
-#define _TMC26X_STANDALONE  0x00B
44
-#define _TMC2660            2660
45
-#define _TMC2660_STANDALONE 0x00C
46
-#define _TMC5130            5130
47
-#define _TMC5130_STANDALONE 5131
48
-#define _TMC5160            5160
49
-#define _TMC5160_STANDALONE 5161
26
+#define _A4988              0x4988
27
+#define _A5984              0x5984
28
+#define _DRV8825            0x8825
29
+#define _LV8729             0x8729
30
+#define _L6470              0x6470
31
+#define _L6474              0x6474
32
+#define _L6480              0x6480
33
+#define _POWERSTEP01        0xF00D
34
+#define _TB6560             0x6560
35
+#define _TB6600             0x6600
36
+#define _TMC2100            0x2100
37
+#define _TMC2130            0x2130A
38
+#define _TMC2130_STANDALONE 0x2130B
39
+#define _TMC2160            0x2160A
40
+#define _TMC2160_STANDALONE 0x2160B
41
+#define _TMC2208            0x2208A
42
+#define _TMC2208_STANDALONE 0x2208B
43
+#define _TMC2209            0x2209A
44
+#define _TMC2209_STANDALONE 0x2209B
45
+#define _TMC26X             0x2600A
46
+#define _TMC26X_STANDALONE  0x2600B
47
+#define _TMC2660            0x2660A
48
+#define _TMC2660_STANDALONE 0x2660B
49
+#define _TMC5130            0x5130A
50
+#define _TMC5130_STANDALONE 0x5130B
51
+#define _TMC5160            0x5160A
52
+#define _TMC5160_STANDALONE 0x5160B
50 53
 
51 54
 #define _DRIVER_ID(V) _CAT(_, V)
52 55
 #define _AXIS_DRIVER_TYPE(A,T) (_DRIVER_ID(A##_DRIVER_TYPE) == _CAT(_, T))
@@ -54,26 +57,35 @@
54 57
 #define AXIS_DRIVER_TYPE_X(T) _AXIS_DRIVER_TYPE(X,T)
55 58
 #define AXIS_DRIVER_TYPE_Y(T) _AXIS_DRIVER_TYPE(Y,T)
56 59
 #define AXIS_DRIVER_TYPE_Z(T) _AXIS_DRIVER_TYPE(Z,T)
57
-#define AXIS_DRIVER_TYPE_X2(T) (EITHER(X_DUAL_STEPPER_DRIVERS, DUAL_X_CARRIAGE) && _AXIS_DRIVER_TYPE(X2,T))
60
+#if EITHER(X_DUAL_STEPPER_DRIVERS, DUAL_X_CARRIAGE)
61
+  #define AXIS_DRIVER_TYPE_X2(T) _AXIS_DRIVER_TYPE(X2,T)
62
+#else
63
+  #define AXIS_DRIVER_TYPE_X2(T) false
64
+#endif
58 65
 #define AXIS_DRIVER_TYPE_Y2(T) (ENABLED(Y_DUAL_STEPPER_DRIVERS) && _AXIS_DRIVER_TYPE(Y2,T))
59
-#define AXIS_DRIVER_TYPE_Z2(T) (Z_MULTI_STEPPER_DRIVERS && _AXIS_DRIVER_TYPE(Z2,T))
60
-#define AXIS_DRIVER_TYPE_Z3(T) (ENABLED(Z_TRIPLE_STEPPER_DRIVERS) && _AXIS_DRIVER_TYPE(Z3,T))
66
+#define AXIS_DRIVER_TYPE_Z2(T) (NUM_Z_STEPPER_DRIVERS >= 2 && _AXIS_DRIVER_TYPE(Z2,T))
67
+#define AXIS_DRIVER_TYPE_Z3(T) (NUM_Z_STEPPER_DRIVERS >= 3 && _AXIS_DRIVER_TYPE(Z3,T))
68
+#define AXIS_DRIVER_TYPE_Z4(T) (NUM_Z_STEPPER_DRIVERS >= 4 && _AXIS_DRIVER_TYPE(Z4,T))
61 69
 #define AXIS_DRIVER_TYPE_E0(T) (E_STEPPERS > 0 && _AXIS_DRIVER_TYPE(E0,T))
62 70
 #define AXIS_DRIVER_TYPE_E1(T) (E_STEPPERS > 1 && _AXIS_DRIVER_TYPE(E1,T))
63 71
 #define AXIS_DRIVER_TYPE_E2(T) (E_STEPPERS > 2 && _AXIS_DRIVER_TYPE(E2,T))
64 72
 #define AXIS_DRIVER_TYPE_E3(T) (E_STEPPERS > 3 && _AXIS_DRIVER_TYPE(E3,T))
65 73
 #define AXIS_DRIVER_TYPE_E4(T) (E_STEPPERS > 4 && _AXIS_DRIVER_TYPE(E4,T))
66 74
 #define AXIS_DRIVER_TYPE_E5(T) (E_STEPPERS > 5 && _AXIS_DRIVER_TYPE(E5,T))
75
+#define AXIS_DRIVER_TYPE_E6(T) (E_STEPPERS > 6 && _AXIS_DRIVER_TYPE(E6,T))
76
+#define AXIS_DRIVER_TYPE_E7(T) (E_STEPPERS > 7 && _AXIS_DRIVER_TYPE(E7,T))
67 77
 
68 78
 #define AXIS_DRIVER_TYPE(A,T) AXIS_DRIVER_TYPE_##A(T)
69 79
 
70 80
 #define HAS_E_DRIVER(T) (  AXIS_DRIVER_TYPE_E0(T) || AXIS_DRIVER_TYPE_E1(T) \
71 81
                         || AXIS_DRIVER_TYPE_E2(T) || AXIS_DRIVER_TYPE_E3(T) \
72
-                        || AXIS_DRIVER_TYPE_E4(T) || AXIS_DRIVER_TYPE_E5(T) )
82
+                        || AXIS_DRIVER_TYPE_E4(T) || AXIS_DRIVER_TYPE_E5(T) \
83
+                        || AXIS_DRIVER_TYPE_E6(T) || AXIS_DRIVER_TYPE_E7(T) )
73 84
 
74 85
 #define HAS_DRIVER(T) (    AXIS_DRIVER_TYPE_X(T)  || AXIS_DRIVER_TYPE_X2(T) \
75 86
                         || AXIS_DRIVER_TYPE_Y(T)  || AXIS_DRIVER_TYPE_Y2(T) \
76
-                        || AXIS_DRIVER_TYPE_Z(T)  || AXIS_DRIVER_TYPE_Z2(T) || AXIS_DRIVER_TYPE_Z3(T) \
87
+                        || AXIS_DRIVER_TYPE_Z(T)  || AXIS_DRIVER_TYPE_Z2(T) \
88
+                        || AXIS_DRIVER_TYPE_Z3(T) || AXIS_DRIVER_TYPE_Z4(T) \
77 89
                         || HAS_E_DRIVER(T) )
78 90
 
79 91
 // Test for supported TMC drivers that require advanced configuration
@@ -86,6 +98,18 @@
86 98
                        || HAS_DRIVER(TMC5130) \
87 99
                        || HAS_DRIVER(TMC5160) )
88 100
 
101
+#define HAS_TRINAMIC_STANDALONE (    HAS_DRIVER(TMC2130_STANDALONE) \
102
+                                  || HAS_DRIVER(TMC2208_STANDALONE) \
103
+                                  || HAS_DRIVER(TMC2209_STANDALONE) \
104
+                                  || HAS_DRIVER(TMC26X_STANDALONE)  \
105
+                                  || HAS_DRIVER(TMC2660_STANDALONE) \
106
+                                  || HAS_DRIVER(TMC5130_STANDALONE) \
107
+                                  || HAS_DRIVER(TMC5160_STANDALONE) \
108
+                                  || HAS_DRIVER(TMC2160_STANDALONE) )
109
+
110
+#define HAS_TMCX1X0 (    HAS_DRIVER(TMC2130) || HAS_DRIVER(TMC2160) \
111
+                      || HAS_DRIVER(TMC5130) || HAS_DRIVER(TMC5160))
112
+
89 113
 #define HAS_TMC220x (HAS_DRIVER(TMC2208) || HAS_DRIVER(TMC2209))
90 114
 
91 115
 #define AXIS_IS_TMC(A)   (    AXIS_DRIVER_TYPE(A,TMC2130) \
@@ -107,6 +131,8 @@
107 131
 #define AXIS_HAS_UART(A) (    AXIS_DRIVER_TYPE(A,TMC2208) \
108 132
                            || AXIS_DRIVER_TYPE(A,TMC2209) )
109 133
 
134
+#define AXIS_HAS_SW_SERIAL(A) ((AXIS_HAS_UART(A) && !defined(A##_HARDWARE_SERIAL)))
135
+
110 136
 #define AXIS_HAS_STALLGUARD(A)   (    AXIS_DRIVER_TYPE(A,TMC2130) \
111 137
                                    || AXIS_DRIVER_TYPE(A,TMC2160) \
112 138
                                    || AXIS_DRIVER_TYPE(A,TMC2209) \
@@ -121,19 +147,20 @@
121 147
                                    || AXIS_DRIVER_TYPE(A,TMC5130) \
122 148
                                    || AXIS_DRIVER_TYPE(A,TMC5160) )
123 149
 
124
-#define HAS_TMC_E_DRIVER (    HAS_E_DRIVER(TMC2130) \
125
-                           || HAS_E_DRIVER(TMC2160) \
126
-                           || HAS_E_DRIVER(TMC2660) \
127
-                           || HAS_E_DRIVER(TMC2209) \
128
-                           || HAS_E_DRIVER(TMC5130) \
129
-                           || HAS_E_DRIVER(TMC5160) )
130
-
131
-#define HAS_TMC_STANDALONE_E_DRIVER  (    HAS_E_DRIVER(TMC2130_STANDALONE) \
132
-                                       || HAS_E_DRIVER(TMC2160_STANDALONE) \
133
-                                       || HAS_E_DRIVER(TMC2660_STANDALONE) \
134
-                                       || HAS_E_DRIVER(TMC2209_STANDALONE) \
135
-                                       || HAS_E_DRIVER(TMC5130_STANDALONE) \
136
-                                       || HAS_E_DRIVER(TMC5160_STANDALONE) )
150
+#define ANY_AXIS_HAS(T) (    AXIS_HAS_##T(X)  || AXIS_HAS_##T(X2) \
151
+                          || AXIS_HAS_##T(Y)  || AXIS_HAS_##T(Y2) \
152
+                          || AXIS_HAS_##T(Z)  || AXIS_HAS_##T(Z2) \
153
+                          || AXIS_HAS_##T(Z3) \
154
+                          || AXIS_HAS_##T(E0) || AXIS_HAS_##T(E1) \
155
+                          || AXIS_HAS_##T(E2) || AXIS_HAS_##T(E3) \
156
+                          || AXIS_HAS_##T(E4) || AXIS_HAS_##T(E5) \
157
+                          || AXIS_HAS_##T(E6) || AXIS_HAS_##T(E7) )
158
+
159
+#define HAS_STEALTHCHOP    ANY_AXIS_HAS(STEALTHCHOP)
160
+#define HAS_STALLGUARD     ANY_AXIS_HAS(STALLGUARD)
161
+#define TMC_HAS_SPI        ANY_AXIS_HAS(SPI)
162
+#define TMC_HAS_SW_SERIAL  ANY_AXIS_HAS(SW_SERIAL)
163
+
137 164
 //
138 165
 // Stretching 'drivers.h' to include LPC/SAMD51 SD options
139 166
 //
@@ -142,3 +169,8 @@
142 169
 #define _SDCARD_CUSTOM_CABLE 3
143 170
 #define _SDCARD_ID(V) _CAT(_SDCARD_, V)
144 171
 #define SD_CONNECTION_IS(V) (_SDCARD_ID(SDCARD_CONNECTION) == _SDCARD_ID(V))
172
+
173
+#define HAS_L64XX (HAS_DRIVER(L6470) || HAS_DRIVER(L6474) || HAS_DRIVER(L6480) || HAS_DRIVER(POWERSTEP01))
174
+#define HAS_L64XX_NOT_L6474 (HAS_L64XX && !HAS_DRIVER(L6474))
175
+
176
+#define AXIS_IS_L64XX(A) (AXIS_DRIVER_TYPE_##A(L6470) || AXIS_DRIVER_TYPE_##A(L6474) ||  AXIS_DRIVER_TYPE_##A(L6480) || AXIS_DRIVER_TYPE_##A(POWERSTEP01))

+ 13
- 0
Marlin/src/core/language.h Ver fichero

@@ -195,6 +195,8 @@
195 195
 #define MSG_Z2_MAX                          "z2_max"
196 196
 #define MSG_Z3_MIN                          "z3_min"
197 197
 #define MSG_Z3_MAX                          "z3_max"
198
+#define MSG_Z4_MIN                          "z4_min"
199
+#define MSG_Z4_MAX                          "z4_max"
198 200
 #define MSG_Z_PROBE                         "z_probe"
199 201
 #define MSG_FILAMENT_RUNOUT_SENSOR          "filament"
200 202
 #define MSG_PROBE_OFFSET                    "Probe Offset"
@@ -220,6 +222,10 @@
220 222
 #define MSG_SOFT_MIN                        "  Min: "
221 223
 #define MSG_SOFT_MAX                        "  Max: "
222 224
 
225
+#define MSG_SAVED_POS                       "Position saved"
226
+#define MSG_RESTORING_POS                   "Restoring position"
227
+#define MSG_INVALID_POS_SLOT                "Invalid slot. Total: "
228
+
223 229
 #define MSG_SD_CANT_OPEN_SUBDIR             "Cannot open subdir "
224 230
 #define MSG_SD_INIT_FAIL                    "SD init fail"
225 231
 #define MSG_SD_VOL_INIT_FAIL                "volume.init failed"
@@ -333,6 +339,7 @@
333 339
 #define MSG_Y2 "Y2"
334 340
 #define MSG_Z2 "Z2"
335 341
 #define MSG_Z3 "Z3"
342
+#define MSG_Z4 "Z4"
336 343
 
337 344
 #define LCD_STR_A MSG_A
338 345
 #define LCD_STR_B MSG_B
@@ -356,6 +363,8 @@
356 363
   #define LCD_STR_N3 "3"
357 364
   #define LCD_STR_N4 "4"
358 365
   #define LCD_STR_N5 "5"
366
+  #define LCD_STR_N6 "6"
367
+  #define LCD_STR_N7 "7"
359 368
 #else
360 369
   #define LCD_FIRST_TOOL '1'
361 370
   #define LCD_STR_N0 "1"
@@ -364,6 +373,8 @@
364 373
   #define LCD_STR_N3 "4"
365 374
   #define LCD_STR_N4 "5"
366 375
   #define LCD_STR_N5 "6"
376
+  #define LCD_STR_N6 "7"
377
+  #define LCD_STR_N7 "8"
367 378
 #endif
368 379
 
369 380
 #define LCD_STR_E0 "E" LCD_STR_N0
@@ -372,6 +383,8 @@
372 383
 #define LCD_STR_E3 "E" LCD_STR_N3
373 384
 #define LCD_STR_E4 "E" LCD_STR_N4
374 385
 #define LCD_STR_E5 "E" LCD_STR_N5
386
+#define LCD_STR_E6 "E" LCD_STR_N6
387
+#define LCD_STR_E7 "E" LCD_STR_N7
375 388
 
376 389
 #include "multi_language.h"   // Allow multiple languages
377 390
 

+ 4
- 6
Marlin/src/core/serial.cpp Ver fichero

@@ -29,7 +29,7 @@ static const char errormagic[] PROGMEM = "Error:";
29 29
 static const char echomagic[]  PROGMEM = "echo:";
30 30
 
31 31
 #if NUM_SERIAL > 1
32
-  int8_t serial_port_index = SERIAL_PORT;
32
+  int8_t serial_port_index = 0;
33 33
 #endif
34 34
 
35 35
 void serialprintPGM(PGM_P str) {
@@ -58,12 +58,10 @@ void serialprint_onoff(const bool onoff) { serialprintPGM(onoff ? PSTR(MSG_ON) :
58 58
 void serialprintln_onoff(const bool onoff) { serialprint_onoff(onoff); SERIAL_EOL(); }
59 59
 void serialprint_truefalse(const bool tf) { serialprintPGM(tf ? PSTR("true") : PSTR("false")); }
60 60
 
61
-void print_bin(const uint16_t val) {
62
-  uint16_t mask = 0x8000;
61
+void print_bin(uint16_t val) {
63 62
   for (uint8_t i = 16; i--;) {
64
-    if (i && !(i % 4)) SERIAL_CHAR(' ');
65
-    SERIAL_CHAR((val & mask) ? '1' : '0');
66
-    mask >>= 1;
63
+    SERIAL_CHAR('0' + TEST(val, i));
64
+    if (!(i & 0x3) && i) SERIAL_CHAR(' ');
67 65
   }
68 66
 }
69 67
 

+ 16
- 1
Marlin/src/core/serial.h Ver fichero

@@ -66,7 +66,6 @@ extern uint8_t marlin_debug_flags;
66 66
 #define PORT_REDIRECT(p)        _PORT_REDIRECT(1,p)
67 67
 #define PORT_RESTORE()          _PORT_RESTORE(1)
68 68
 
69
-#define SERIAL_CHAR(x)          SERIAL_OUT(write, x)
70 69
 #define SERIAL_ECHO(x)          SERIAL_OUT(print, x)
71 70
 #define SERIAL_ECHO_F(V...)     SERIAL_OUT(print, V)
72 71
 #define SERIAL_ECHOLN(x)        SERIAL_OUT(println, x)
@@ -83,6 +82,22 @@ extern uint8_t marlin_debug_flags;
83 82
   #define SERIAL_FLUSHTX()
84 83
 #endif
85 84
 
85
+// Print up to 10 chars from a list
86
+#define __CHAR_N(N,V...)  _CHAR_##N(V)
87
+#define _CHAR_N(N,V...)   __CHAR_N(N,V)
88
+#define _CHAR_1(c)        SERIAL_OUT(write, c)
89
+#define _CHAR_2(a,b)      do{ _CHAR_1(a); _CHAR_1(b); }while(0)
90
+#define _CHAR_3(a,V...)   do{ _CHAR_1(a); _CHAR_2(V); }while(0)
91
+#define _CHAR_4(a,V...)   do{ _CHAR_1(a); _CHAR_3(V); }while(0)
92
+#define _CHAR_5(a,V...)   do{ _CHAR_1(a); _CHAR_4(V); }while(0)
93
+#define _CHAR_6(a,V...)   do{ _CHAR_1(a); _CHAR_5(V); }while(0)
94
+#define _CHAR_7(a,V...)   do{ _CHAR_1(a); _CHAR_6(V); }while(0)
95
+#define _CHAR_8(a,V...)   do{ _CHAR_1(a); _CHAR_7(V); }while(0)
96
+#define _CHAR_9(a,V...)   do{ _CHAR_1(a); _CHAR_8(V); }while(0)
97
+#define _CHAR_10(a,V...)  do{ _CHAR_1(a); _CHAR_9(V); }while(0)
98
+
99
+#define SERIAL_CHAR(V...) _CHAR_N(NUM_ARGS(V),V)
100
+
86 101
 // Print up to 12 pairs of values. Odd elements auto-wrapped in PSTR().
87 102
 #define __SEP_N(N,V...)   _SEP_##N(V)
88 103
 #define _SEP_N(N,V...)    __SEP_N(N,V)

+ 1
- 5
Marlin/src/core/types.h Ver fichero

@@ -43,11 +43,7 @@ enum AxisEnum : uint8_t {
43 43
   E_AXIS   = 3,
44 44
   X_HEAD   = 4, Y_HEAD = 5, Z_HEAD = 6,
45 45
   E0_AXIS  = 3,
46
-  E1_AXIS  = 4,
47
-  E2_AXIS  = 5,
48
-  E3_AXIS  = 6,
49
-  E4_AXIS  = 7,
50
-  E5_AXIS  = 8,
46
+  E1_AXIS, E2_AXIS, E3_AXIS, E4_AXIS, E5_AXIS, E6_AXIS, E7_AXIS,
51 47
   ALL_AXES = 0xFE, NO_AXIS = 0xFF
52 48
 };
53 49
 

+ 39
- 31
Marlin/src/core/utility.cpp Ver fichero

@@ -22,7 +22,7 @@
22 22
 
23 23
 #include "utility.h"
24 24
 
25
-#include "../Marlin.h"
25
+#include "../MarlinCore.h"
26 26
 #include "../module/temperature.h"
27 27
 
28 28
 void safe_delay(millis_t ms) {
@@ -81,40 +81,49 @@ void safe_delay(millis_t ms) {
81 81
     );
82 82
 
83 83
     #if HAS_BED_PROBE
84
-      SERIAL_ECHOPAIR_P(PSTR("Probe Offset X"), probe_offset.x, SP_Y_STR, probe_offset.y, SP_Z_STR, probe_offset.z);
85
-      if (probe_offset.x > 0)
86
-        SERIAL_ECHOPGM(" (Right");
87
-      else if (probe_offset.x < 0)
88
-        SERIAL_ECHOPGM(" (Left");
89
-      else if (probe_offset.y != 0)
90
-        SERIAL_ECHOPGM(" (Middle");
91
-      else
92
-        SERIAL_ECHOPGM(" (Aligned With");
93 84
 
94
-      if (probe_offset.y > 0) {
95
-        #if IS_SCARA
96
-          SERIAL_ECHOPGM("-Distal");
97
-        #else
98
-          SERIAL_ECHOPGM("-Back");
99
-        #endif
100
-      }
101
-      else if (probe_offset.y < 0) {
102
-        #if IS_SCARA
103
-          SERIAL_ECHOPGM("-Proximal");
104
-        #else
105
-          SERIAL_ECHOPGM("-Front");
106
-        #endif
107
-      }
108
-      else if (probe_offset.x != 0)
109
-        SERIAL_ECHOPGM("-Center");
85
+      #if !HAS_PROBE_XY_OFFSET
86
+        SERIAL_ECHOPAIR("Probe Offset X0 Y0 Z", probe_offset.z, " (");
87
+      #else
88
+        SERIAL_ECHOPAIR_P(PSTR("Probe Offset X"), probe_offset.x, SP_Y_STR, probe_offset.y, SP_Z_STR, probe_offset.z);
89
+        if (probe_offset.x > 0)
90
+          SERIAL_ECHOPGM(" (Right");
91
+        else if (probe_offset.x < 0)
92
+          SERIAL_ECHOPGM(" (Left");
93
+        else if (probe_offset.y != 0)
94
+          SERIAL_ECHOPGM(" (Middle");
95
+        else
96
+          SERIAL_ECHOPGM(" (Aligned With");
97
+
98
+        if (probe_offset.y > 0) {
99
+          #if IS_SCARA
100
+            SERIAL_ECHOPGM("-Distal");
101
+          #else
102
+            SERIAL_ECHOPGM("-Back");
103
+          #endif
104
+        }
105
+        else if (probe_offset.y < 0) {
106
+          #if IS_SCARA
107
+            SERIAL_ECHOPGM("-Proximal");
108
+          #else
109
+            SERIAL_ECHOPGM("-Front");
110
+          #endif
111
+        }
112
+        else if (probe_offset.x != 0)
113
+          SERIAL_ECHOPGM("-Center");
114
+
115
+        SERIAL_ECHOPGM(" & ");
116
+
117
+      #endif
110 118
 
111 119
       if (probe_offset.z < 0)
112
-        SERIAL_ECHOPGM(" & Below");
120
+        SERIAL_ECHOPGM("Below");
113 121
       else if (probe_offset.z > 0)
114
-        SERIAL_ECHOPGM(" & Above");
122
+        SERIAL_ECHOPGM("Above");
115 123
       else
116
-        SERIAL_ECHOPGM(" & Same Z as");
124
+        SERIAL_ECHOPGM("Same Z as");
117 125
       SERIAL_ECHOLNPGM(" Nozzle)");
126
+
118 127
     #endif
119 128
 
120 129
     #if HAS_ABL_OR_UBL
@@ -139,8 +148,7 @@ void safe_delay(millis_t ms) {
139 148
           SERIAL_ECHOPGM("ABL Adjustment X");
140 149
           LOOP_XYZ(a) {
141 150
             float v = planner.get_axis_position_mm(AxisEnum(a)) - current_position[a];
142
-            SERIAL_CHAR(' ');
143
-            SERIAL_CHAR('X' + char(a));
151
+            SERIAL_CHAR(' ', 'X' + char(a));
144 152
             if (v > 0) SERIAL_CHAR('+');
145 153
             SERIAL_ECHO(v);
146 154
           }

+ 10
- 6
Marlin/src/feature/Max7219_Debug_LEDs.cpp Ver fichero

@@ -45,7 +45,7 @@
45 45
 
46 46
 #include "../module/planner.h"
47 47
 #include "../module/stepper.h"
48
-#include "../Marlin.h"
48
+#include "../MarlinCore.h"
49 49
 #include "../HAL/shared/Delay.h"
50 50
 
51 51
 #define HAS_SIDE_BY_SIDE (ENABLED(MAX7219_SIDE_BY_SIDE) && MAX7219_NUMBER_UNITS > 1)
@@ -455,15 +455,19 @@ void Max7219::register_setup() {
455 455
 #ifdef MAX7219_INIT_TEST
456 456
 #if MAX7219_INIT_TEST == 2
457 457
 
458
+  #define MAX7219_LEDS (MAX7219_X_LEDS * MAX7219_Y_LEDS)
459
+
458 460
   void Max7219::spiral(const bool on, const uint16_t del) {
459
-    constexpr int8_t way[] = { 1, 0, 0, 1, -1, 0, 0, -1 };
461
+    constexpr int8_t way[][2] = { { 1, 0 }, { 0, 1 }, { -1, 0 }, { 0, -1 } };
460 462
     int8_t px = 0, py = 0, dir = 0;
461
-    for (uint8_t i = MAX7219_X_LEDS * MAX7219_Y_LEDS; i--;) {
463
+    for (IF<(MAX7219_LEDS > 255), uint16_t, uint8_t>::type i = MAX7219_LEDS; i--;) {
462 464
       led_set(px, py, on);
463 465
       delay(del);
464
-      const int8_t x = px + way[dir], y = py + way[dir + 1];
465
-      if (!WITHIN(x, 0, MAX7219_X_LEDS - 1) || !WITHIN(y, 0, MAX7219_Y_LEDS - 1) || BIT_7219(x, y) == on) dir = (dir + 2) & 0x7;
466
-      px += way[dir]; py += way[dir + 1];
466
+      const int8_t x = px + way[dir][0], y = py + way[dir][1];
467
+      if (!WITHIN(x, 0, MAX7219_X_LEDS - 1) || !WITHIN(y, 0, MAX7219_Y_LEDS - 1) || BIT_7219(x, y) == on)
468
+        dir = (dir + 1) & 0x3;
469
+      px += way[dir][0];
470
+      py += way[dir][1];
467 471
     }
468 472
   }
469 473
 

+ 1
- 1
Marlin/src/feature/babystep.cpp Ver fichero

@@ -25,7 +25,7 @@
25 25
 #if ENABLED(BABYSTEPPING)
26 26
 
27 27
 #include "babystep.h"
28
-#include "../Marlin.h"
28
+#include "../MarlinCore.h"
29 29
 #include "../module/planner.h"
30 30
 #include "../module/stepper.h"
31 31
 

+ 8
- 5
Marlin/src/feature/bedlevel/bedlevel.cpp Ver fichero

@@ -86,14 +86,18 @@ void set_bed_leveling_enabled(const bool enable/*=true*/) {
86 86
     #endif
87 87
 
88 88
     if (planner.leveling_active) {      // leveling from on to off
89
+      if (DEBUGGING(LEVELING)) DEBUG_POS("Leveling ON", current_position);
89 90
       // change unleveled current_position to physical current_position without moving steppers.
90 91
       planner.apply_leveling(current_position);
91 92
       planner.leveling_active = false;  // disable only AFTER calling apply_leveling
93
+      if (DEBUGGING(LEVELING)) DEBUG_POS("...Now OFF", current_position);
92 94
     }
93 95
     else {                              // leveling from off to on
96
+      if (DEBUGGING(LEVELING)) DEBUG_POS("Leveling OFF", current_position);
94 97
       planner.leveling_active = true;   // enable BEFORE calling unapply_leveling, otherwise ignored
95 98
       // change physical current_position to unleveled current_position without moving steppers.
96 99
       planner.unapply_leveling(current_position);
100
+      if (DEBUGGING(LEVELING)) DEBUG_POS("...Now ON", current_position);
97 101
     }
98 102
 
99 103
     sync_plan_position();
@@ -180,7 +184,7 @@ void reset_bed_level() {
180 184
     #endif
181 185
     for (uint8_t y = 0; y < sy; y++) {
182 186
       #ifdef SCAD_MESH_OUTPUT
183
-        SERIAL_ECHOPGM(" [");           // open sub-array
187
+        SERIAL_ECHOPGM(" [");             // open sub-array
184 188
       #else
185 189
         if (y < 10) SERIAL_CHAR(' ');
186 190
         SERIAL_ECHO(int(y));
@@ -207,14 +211,13 @@ void reset_bed_level() {
207 211
         #endif
208 212
       }
209 213
       #ifdef SCAD_MESH_OUTPUT
210
-        SERIAL_CHAR(' ');
211
-        SERIAL_CHAR(']');                     // close sub-array
214
+        SERIAL_CHAR(' ', ']');            // close sub-array
212 215
         if (y < sy - 1) SERIAL_CHAR(',');
213 216
       #endif
214 217
       SERIAL_EOL();
215 218
     }
216 219
     #ifdef SCAD_MESH_OUTPUT
217
-      SERIAL_ECHOPGM("];");                       // close 2D array
220
+      SERIAL_ECHOPGM("];");               // close 2D array
218 221
     #endif
219 222
     SERIAL_EOL();
220 223
   }
@@ -244,7 +247,7 @@ void reset_bed_level() {
244 247
     current_position = pos;
245 248
 
246 249
     #if ENABLED(LCD_BED_LEVELING)
247
-      ui.wait_for_bl_move = false;
250
+      ui.wait_for_move = false;
248 251
     #endif
249 252
   }
250 253
 

+ 1
- 1
Marlin/src/feature/bedlevel/ubl/ubl.cpp Ver fichero

@@ -176,7 +176,7 @@
176 176
     // Add XY probe offset from extruder because probe_at_point() subtracts them when
177 177
     // moving to the XY position to be measured. This ensures better agreement between
178 178
     // the current Z position after G28 and the mesh values.
179
-    const xy_int8_t curr = closest_indexes(xy_pos_t(current_position) + xy_pos_t(probe_offset));
179
+    const xy_int8_t curr = closest_indexes(xy_pos_t(current_position) + probe_offset_xy);
180 180
 
181 181
     if (!lcd) SERIAL_EOL();
182 182
     for (int8_t j = GRID_MAX_POINTS_Y - 1; j >= 0; j--) {

+ 8
- 7
Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp Ver fichero

@@ -26,7 +26,7 @@
26 26
 
27 27
   #include "../bedlevel.h"
28 28
 
29
-  #include "../../../Marlin.h"
29
+  #include "../../../MarlinCore.h"
30 30
   #include "../../../HAL/shared/persistent_store_api.h"
31 31
   #include "../../../libs/hex_print_routines.h"
32 32
   #include "../../../module/configuration_store.h"
@@ -450,7 +450,7 @@
450 450
               SERIAL_ECHO(g29_pos.y);
451 451
               SERIAL_ECHOLNPGM(").\n");
452 452
             }
453
-            const xy_pos_t near = g29_pos + probe_offset;
453
+            const xy_pos_t near = g29_pos + probe_offset_xy;
454 454
             probe_entire_mesh(near, parser.seen('T'), parser.seen('E'), parser.seen('U'));
455 455
 
456 456
             report_current_position();
@@ -468,6 +468,7 @@
468 468
             do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
469 469
 
470 470
             if (parser.seen('C') && !xy_seen) {
471
+
471 472
               /**
472 473
                * Use a good default location for the path.
473 474
                * The flipped > and < operators in these comparisons is intentional.
@@ -479,8 +480,8 @@
479 480
                 #if IS_KINEMATIC
480 481
                   X_HOME_POS, Y_HOME_POS
481 482
                 #else
482
-                  probe_offset.x > 0 ? X_BED_SIZE : 0,
483
-                  probe_offset.y < 0 ? Y_BED_SIZE : 0
483
+                  probe_offset_xy.x > 0 ? X_BED_SIZE : 0,
484
+                  probe_offset_xy.y < 0 ? Y_BED_SIZE : 0
484 485
                 #endif
485 486
               );
486 487
             }
@@ -805,8 +806,8 @@
805 806
       restore_ubl_active_state_and_leave();
806 807
 
807 808
       do_blocking_move_to_xy(
808
-        constrain(near.x - probe_offset.x, MESH_MIN_X, MESH_MAX_X),
809
-        constrain(near.y - probe_offset.y, MESH_MIN_Y, MESH_MAX_Y)
809
+        constrain(near.x - probe_offset_xy.x, MESH_MIN_X, MESH_MAX_X),
810
+        constrain(near.y - probe_offset_xy.y, MESH_MIN_Y, MESH_MAX_Y)
810 811
       );
811 812
     }
812 813
 
@@ -1293,7 +1294,7 @@
1293 1294
     closest.distance = -99999.9f;
1294 1295
 
1295 1296
     // Get the reference position, either nozzle or probe
1296
-    const xy_pos_t ref = probe_relative ? pos + probe_offset : pos;
1297
+    const xy_pos_t ref = probe_relative ? pos + probe_offset_xy : pos;
1297 1298
 
1298 1299
     float best_so_far = 99999.99f;
1299 1300
 

+ 1
- 1
Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp Ver fichero

@@ -32,7 +32,7 @@
32 32
   #include "../../../module/delta.h"
33 33
 #endif
34 34
 
35
-#include "../../../Marlin.h"
35
+#include "../../../MarlinCore.h"
36 36
 #include <math.h>
37 37
 
38 38
 #if !UBL_SEGMENTED

+ 5
- 3
Marlin/src/feature/caselight.cpp Ver fichero

@@ -58,7 +58,9 @@ void update_case_light() {
58 58
   if (case_light_arg_flag && case_light_on)
59 59
     case_light_brightness = case_light_brightness_sav;  // restore last brightens if this is an S1 argument
60 60
 
61
-  const uint8_t i = case_light_on ? case_light_brightness : 0, n10ct = INVERT_CASE_LIGHT ? 255 - i : i;
61
+  #if ENABLED(CASE_LIGHT_USE_NEOPIXEL) || NONE(CASE_LIGHT_USE_NEOPIXEL, CASE_LIGHT_NO_BRIGHTNESS)
62
+    const uint8_t i = case_light_on ? case_light_brightness : 0, n10ct = INVERT_CASE_LIGHT ? 255 - i : i;
63
+  #endif
62 64
 
63 65
   #if ENABLED(CASE_LIGHT_USE_NEOPIXEL)
64 66
 
@@ -71,13 +73,13 @@ void update_case_light() {
71 73
 
72 74
     #if DISABLED(CASE_LIGHT_NO_BRIGHTNESS)
73 75
       if (PWM_PIN(CASE_LIGHT_PIN))
74
-        analogWrite(pin_t(CASE_LIGHT_PIN),
76
+        analogWrite(pin_t(CASE_LIGHT_PIN), (
75 77
           #if CASE_LIGHT_MAX_PWM == 255
76 78
             n10ct
77 79
           #else
78 80
             map(n10ct, 0, 255, 0, CASE_LIGHT_MAX_PWM)
79 81
           #endif
80
-        );
82
+        ));
81 83
       else
82 84
     #endif
83 85
       {

+ 21
- 18
Marlin/src/feature/controllerfan.cpp Ver fichero

@@ -36,29 +36,32 @@ void controllerfan_update() {
36 36
   if (ELAPSED(ms, nextMotorCheck)) {
37 37
     nextMotorCheck = ms + 2500UL; // Not a time critical function, so only check every 2.5s
38 38
 
39
-    const bool xory = X_ENABLE_READ() == X_ENABLE_ON || Y_ENABLE_READ() == Y_ENABLE_ON;
39
+    const bool xory = X_ENABLE_READ() == bool(X_ENABLE_ON) || Y_ENABLE_READ() == bool(Y_ENABLE_ON);
40 40
 
41 41
     // If any of the drivers or the bed are enabled...
42
-    if (xory || Z_ENABLE_READ() == Z_ENABLE_ON
42
+    if (xory || Z_ENABLE_READ() == bool(Z_ENABLE_ON)
43 43
       #if HAS_HEATED_BED
44 44
         || thermalManager.temp_bed.soft_pwm_amount > 0
45 45
       #endif
46
-        #if HAS_X2_ENABLE
47
-          || X2_ENABLE_READ() == X_ENABLE_ON
48
-        #endif
49
-        #if HAS_Y2_ENABLE
50
-          || Y2_ENABLE_READ() == Y_ENABLE_ON
51
-        #endif
52
-        #if HAS_Z2_ENABLE
53
-          || Z2_ENABLE_READ() == Z_ENABLE_ON
54
-        #endif
55
-        #if HAS_Z3_ENABLE
56
-          || Z3_ENABLE_READ() == Z_ENABLE_ON
57
-        #endif
58
-        #if E_STEPPERS
59
-          #define _OR_ENABLED_E(N) || E##N##_ENABLE_READ() == E_ENABLE_ON
60
-          REPEAT(E_STEPPERS, _OR_ENABLED_E)
61
-        #endif
46
+      #if HAS_X2_ENABLE
47
+        || X2_ENABLE_READ() == bool(X_ENABLE_ON)
48
+      #endif
49
+      #if HAS_Y2_ENABLE
50
+        || Y2_ENABLE_READ() == bool(Y_ENABLE_ON)
51
+      #endif
52
+      #if HAS_Z2_ENABLE
53
+        || Z2_ENABLE_READ() == bool(Z_ENABLE_ON)
54
+      #endif
55
+      #if HAS_Z3_ENABLE
56
+        || Z3_ENABLE_READ() == bool(Z_ENABLE_ON)
57
+      #endif
58
+      #if HAS_Z4_ENABLE
59
+        || Z4_ENABLE_READ() == bool(Z_ENABLE_ON)
60
+      #endif
61
+      #if E_STEPPERS
62
+        #define _OR_ENABLED_E(N) || E##N##_ENABLE_READ() == bool(E_ENABLE_ON)
63
+        REPEAT(E_STEPPERS, _OR_ENABLED_E)
64
+      #endif
62 65
     ) {
63 66
       lastMotorOn = ms; //... set time to NOW so the fan will turn on
64 67
     }

+ 1
- 1
Marlin/src/feature/dac/dac_dac084s085.cpp Ver fichero

@@ -10,7 +10,7 @@
10 10
 
11 11
 #include "dac_dac084s085.h"
12 12
 
13
-#include "../../Marlin.h"
13
+#include "../../MarlinCore.h"
14 14
 #include "../../module/stepper.h"
15 15
 #include "../../HAL/shared/Delay.h"
16 16
 

+ 1
- 1
Marlin/src/feature/dac/dac_mcp4728.cpp Ver fichero

@@ -43,7 +43,7 @@ xyze_uint_t mcp4728_values;
43 43
  */
44 44
 void mcp4728_init() {
45 45
   Wire.begin();
46
-  Wire.requestFrom(int(DAC_DEV_ADDRESS), 24);
46
+  Wire.requestFrom(I2C_ADDRESS(DAC_DEV_ADDRESS), 24);
47 47
   while (Wire.available()) {
48 48
     char deviceID = Wire.read(),
49 49
          hiByte = Wire.read(),

+ 18
- 0
Marlin/src/feature/dac/dac_mcp4728.h Ver fichero

@@ -29,6 +29,24 @@
29 29
 
30 30
 #include <Wire.h>
31 31
 
32
+/**
33
+ * The following three macros are only used in this piece of code related to mcp4728.
34
+ * They are defined in the standard Arduino framework but could be undefined in 32 bits Arduino frameworks.
35
+ * (For instance not defined in Arduino lpc176x framework)
36
+ * So we have to define them if needed.
37
+ */
38
+#ifndef word
39
+  #define word(h, l)  ((uint8_t) ((h << 8) | l))
40
+#endif
41
+
42
+#ifndef lowByte
43
+  #define lowByte(w)  ((uint8_t) ((w) & 0xff))
44
+#endif
45
+
46
+#ifndef highByte
47
+  #define highByte(w) ((uint8_t) ((w) >> 8))
48
+#endif
49
+
32 50
 #define defaultVDD     DAC_STEPPER_MAX //was 5000 but differs with internal Vref
33 51
 #define BASE_ADDR      0x60
34 52
 #define RESET          0b00000110

+ 1
- 1
Marlin/src/feature/dac/stepper_dac.cpp Ver fichero

@@ -68,7 +68,7 @@ void dac_current_percent(uint8_t channel, float val) {
68 68
 void dac_current_raw(uint8_t channel, uint16_t val) {
69 69
   if (!dac_present) return;
70 70
 
71
-  NOMORE(val, DAC_STEPPER_MAX);
71
+  NOMORE(val, uint16_t(DAC_STEPPER_MAX));
72 72
 
73 73
   mcp4728_analogWrite(dac_order[channel], val);
74 74
   mcp4728_simpleCommand(UPDATE);

+ 5
- 5
Marlin/src/feature/digipot/digipot_mcp4451.cpp Ver fichero

@@ -47,7 +47,7 @@ static byte current_to_wiper(const float current) {
47 47
   return byte(CEIL(float((DIGIPOT_I2C_FACTOR * current))));
48 48
 }
49 49
 
50
-static void i2c_send(const byte addr, const byte a, const byte b) {
50
+static void digipot_i2c_send(const byte addr, const byte a, const byte b) {
51 51
   #if MB(MKS_SBASE)
52 52
     digipot_mcp4451_start(addr);
53 53
     digipot_mcp4451_send_byte(a);
@@ -67,17 +67,17 @@ void digipot_i2c_set_current(const uint8_t channel, const float current) {
67 67
   const byte addr = channel < 4 ? DIGIPOT_I2C_ADDRESS_A : DIGIPOT_I2C_ADDRESS_B; // channel 0-3 vs 4-7
68 68
 
69 69
   // Initial setup
70
-  i2c_send(addr, 0x40, 0xFF);
71
-  i2c_send(addr, 0xA0, 0xFF);
70
+  digipot_i2c_send(addr, 0x40, 0xFF);
71
+  digipot_i2c_send(addr, 0xA0, 0xFF);
72 72
 
73 73
   // Set actual wiper value
74 74
   byte addresses[4] = { 0x00, 0x10, 0x60, 0x70 };
75
-  i2c_send(addr, addresses[channel & 0x3], current_to_wiper(_MIN(float(_MAX(current, 0)), DIGIPOT_I2C_MAX_CURRENT)));
75
+  digipot_i2c_send(addr, addresses[channel & 0x3], current_to_wiper(_MIN(float(_MAX(current, 0)), DIGIPOT_I2C_MAX_CURRENT)));
76 76
 }
77 77
 
78 78
 void digipot_i2c_init() {
79 79
   #if MB(MKS_SBASE)
80
-    digipot_mcp4451_init();
80
+    configure_i2c(16); // Setting clock_option to 16 ensure the I2C bus is initialized at 400kHz
81 81
   #else
82 82
     Wire.begin();
83 83
   #endif

+ 21
- 6
Marlin/src/feature/joystick.cpp Ver fichero

@@ -42,25 +42,40 @@ Joystick joystick;
42 42
 
43 43
 #if HAS_JOY_ADC_X
44 44
   temp_info_t Joystick::x; // = { 0 }
45
+  #if ENABLED(INVERT_JOY_X)
46
+    #define JOY_X(N) (16383 - (N))
47
+  #else
48
+    #define JOY_X(N) (N)
49
+  #endif
45 50
 #endif
46 51
 #if HAS_JOY_ADC_Y
47 52
   temp_info_t Joystick::y; // = { 0 }
53
+  #if ENABLED(INVERT_JOY_Y)
54
+    #define JOY_Y(N) (16383 - (N))
55
+  #else
56
+    #define JOY_Y(N) (N)
57
+  #endif
48 58
 #endif
49 59
 #if HAS_JOY_ADC_Z
50 60
   temp_info_t Joystick::z; // = { 0 }
61
+  #if ENABLED(INVERT_JOY_Z)
62
+    #define JOY_Z(N) (16383 - (N))
63
+  #else
64
+    #define JOY_Z(N) (N)
65
+  #endif
51 66
 #endif
52 67
 
53 68
 #if ENABLED(JOYSTICK_DEBUG)
54 69
   void Joystick::report() {
55 70
     SERIAL_ECHOPGM("Joystick");
56 71
     #if HAS_JOY_ADC_X
57
-      SERIAL_ECHOPAIR_P(SP_X_STR, x.raw);
72
+      SERIAL_ECHOPAIR_P(SP_X_STR, JOY_X(x.raw));
58 73
     #endif
59 74
     #if HAS_JOY_ADC_Y
60
-      SERIAL_ECHOPAIR_P(SP_Y_STR, y.raw);
75
+      SERIAL_ECHOPAIR_P(SP_Y_STR, JOY_Y(y.raw));
61 76
     #endif
62 77
     #if HAS_JOY_ADC_Z
63
-      SERIAL_ECHOPAIR_P(SP_Z_STR, z.raw);
78
+      SERIAL_ECHOPAIR_P(SP_Z_STR, JOY_Z(z.raw));
64 79
     #endif
65 80
     #if HAS_JOY_ADC_EN
66 81
       SERIAL_ECHO_TERNARY(READ(JOY_EN_PIN), " EN=", "HIGH (dis", "LOW (en", "abled)");
@@ -91,15 +106,15 @@ Joystick joystick;
91 106
 
92 107
     #if HAS_JOY_ADC_X
93 108
       static constexpr int16_t joy_x_limits[4] = JOY_X_LIMITS;
94
-      _normalize_joy(norm_jog.x, x.raw, joy_x_limits);
109
+      _normalize_joy(norm_jog.x, JOY_X(x.raw), joy_x_limits);
95 110
     #endif
96 111
     #if HAS_JOY_ADC_Y
97 112
       static constexpr int16_t joy_y_limits[4] = JOY_Y_LIMITS;
98
-      _normalize_joy(norm_jog.y, y.raw, joy_y_limits);
113
+      _normalize_joy(norm_jog.y, JOY_Y(y.raw), joy_y_limits);
99 114
     #endif
100 115
     #if HAS_JOY_ADC_Z
101 116
       static constexpr int16_t joy_z_limits[4] = JOY_Z_LIMITS;
102
-      _normalize_joy(norm_jog.z, z.raw, joy_z_limits);
117
+      _normalize_joy(norm_jog.z, JOY_Z(z.raw), joy_z_limits);
103 118
     #endif
104 119
   }
105 120
 

+ 0
- 0
Marlin/src/feature/pause.cpp Ver fichero


Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio

Loading…
Cancelar
Guardar