Browse Source

Suspend Servos for STM32+NeoPixel (#19963)

Jason Smith 4 years ago
parent
commit
2c8f566231
No account linked to committer's email address

+ 3
- 0
Marlin/src/HAL/STM32/HAL.h View File

@@ -29,6 +29,7 @@
29 29
 #include "../shared/math_32bit.h"
30 30
 #include "../shared/HAL_SPI.h"
31 31
 #include "fastio.h"
32
+#include "Servo.h"
32 33
 #include "watchdog.h"
33 34
 #include "MarlinSerial.h"
34 35
 
@@ -110,6 +111,8 @@
110 111
 typedef int16_t pin_t;
111 112
 
112 113
 #define HAL_SERVO_LIB libServo
114
+#define PAUSE_SERVO_OUTPUT() libServo::pause_all_servos()
115
+#define RESUME_SERVO_OUTPUT() libServo::resume_all_servos()
113 116
 
114 117
 // ------------------------
115 118
 // Public Variables

+ 4
- 13
Marlin/src/HAL/STM32/eeprom_flash.cpp View File

@@ -28,15 +28,6 @@
28 28
 
29 29
 #include "../shared/eeprom_api.h"
30 30
 
31
-#if HAS_SERVOS
32
-  #include "Servo.h"
33
-  #define PAUSE_SERVO_OUTPUT() libServo::pause_all_servos()
34
-  #define RESUME_SERVO_OUTPUT() libServo::resume_all_servos()
35
-#else
36
-  #define PAUSE_SERVO_OUTPUT()
37
-  #define RESUME_SERVO_OUTPUT()
38
-#endif
39
-
40 31
 /**
41 32
  * The STM32 HAL supports chips that deal with "pages" and some with "sectors" and some that
42 33
  * even have multiple "banks" of flash.
@@ -172,11 +163,11 @@ bool PersistentStore::access_finish() {
172 163
         current_slot = EEPROM_SLOTS - 1;
173 164
         UNLOCK_FLASH();
174 165
 
175
-        PAUSE_SERVO_OUTPUT();
166
+        TERN_(HAS_PAUSE_SERVO_OUTPUT, PAUSE_SERVO_OUTPUT());
176 167
         DISABLE_ISRS();
177 168
         status = HAL_FLASHEx_Erase(&EraseInitStruct, &SectorError);
178 169
         ENABLE_ISRS();
179
-        RESUME_SERVO_OUTPUT();
170
+        TERN_(HAS_PAUSE_SERVO_OUTPUT, RESUME_SERVO_OUTPUT());
180 171
         if (status != HAL_OK) {
181 172
           DEBUG_ECHOLNPAIR("HAL_FLASHEx_Erase=", status);
182 173
           DEBUG_ECHOLNPAIR("GetError=", HAL_FLASH_GetError());
@@ -227,11 +218,11 @@ bool PersistentStore::access_finish() {
227 218
       // Interrupts during this time can have unpredictable results, such as killing Servo
228 219
       // output. Servo output still glitches with interrupts disabled, but recovers after the
229 220
       // erase.
230
-      PAUSE_SERVO_OUTPUT();
221
+      TERN_(HAS_PAUSE_SERVO_OUTPUT, PAUSE_SERVO_OUTPUT());
231 222
       DISABLE_ISRS();
232 223
       eeprom_buffer_flush();
233 224
       ENABLE_ISRS();
234
-      RESUME_SERVO_OUTPUT();
225
+      TERN_(HAS_PAUSE_SERVO_OUTPUT, RESUME_SERVO_OUTPUT());
235 226
 
236 227
       eeprom_data_written = false;
237 228
     #endif

+ 3
- 0
Marlin/src/feature/leds/neopixel.h View File

@@ -105,6 +105,8 @@ public:
105 105
   }
106 106
 
107 107
   static inline void show() {
108
+    // Some platforms cannot maintain PWM output when NeoPixel disables interrupts for long durations.
109
+    TERN_(HAS_PAUSE_SERVO_OUTPUT, PAUSE_SERVO_OUTPUT());
108 110
     adaneo1.show();
109 111
     #if PIN_EXISTS(NEOPIXEL2)
110 112
       #if CONJOINED_NEOPIXEL
@@ -115,6 +117,7 @@ public:
115 117
         adaneo1.setPin(NEOPIXEL_PIN);
116 118
       #endif
117 119
     #endif
120
+    TERN_(HAS_PAUSE_SERVO_OUTPUT, RESUME_SERVO_OUTPUT());
118 121
   }
119 122
 
120 123
   #if 0

+ 3
- 0
Marlin/src/inc/Conditionals_post.h View File

@@ -1997,6 +1997,9 @@
1997 1997
 #if NUM_SERVOS > 0
1998 1998
   #define HAS_SERVOS 1
1999 1999
 #endif
2000
+#if HAS_SERVOS && defined(PAUSE_SERVO_OUTPUT) && defined(RESUME_SERVO_OUTPUT)
2001
+  #define HAS_PAUSE_SERVO_OUTPUT 1
2002
+#endif
2000 2003
 
2001 2004
 // Sensors
2002 2005
 #if PIN_EXISTS(FILWIDTH)

+ 2
- 1
buildroot/tests/BIGTREE_GTR_V1_0-tests View File

@@ -23,7 +23,8 @@ opt_set E1_AUTO_FAN_PIN PC11
23 23
 opt_set E2_AUTO_FAN_PIN PC12
24 24
 opt_set X_DRIVER_TYPE TMC2208
25 25
 opt_set Y_DRIVER_TYPE TMC2130
26
-opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
26
+opt_set NEOPIXEL_PIN PF13
27
+opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER BLTOUCH NEOPIXEL_LED Z_SAFE_HOMING
27 28
 opt_enable FILAMENT_RUNOUT_SENSOR NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE
28 29
 opt_set FIL_RUNOUT_PIN 3
29 30
 opt_set FIL_RUNOUT2_PIN 4

Loading…
Cancel
Save