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
 #include "../shared/math_32bit.h"
29
 #include "../shared/math_32bit.h"
30
 #include "../shared/HAL_SPI.h"
30
 #include "../shared/HAL_SPI.h"
31
 #include "fastio.h"
31
 #include "fastio.h"
32
+#include "Servo.h"
32
 #include "watchdog.h"
33
 #include "watchdog.h"
33
 #include "MarlinSerial.h"
34
 #include "MarlinSerial.h"
34
 
35
 
110
 typedef int16_t pin_t;
111
 typedef int16_t pin_t;
111
 
112
 
112
 #define HAL_SERVO_LIB libServo
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
 // Public Variables
118
 // Public Variables

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

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

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

105
   }
105
   }
106
 
106
 
107
   static inline void show() {
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
     adaneo1.show();
110
     adaneo1.show();
109
     #if PIN_EXISTS(NEOPIXEL2)
111
     #if PIN_EXISTS(NEOPIXEL2)
110
       #if CONJOINED_NEOPIXEL
112
       #if CONJOINED_NEOPIXEL
115
         adaneo1.setPin(NEOPIXEL_PIN);
117
         adaneo1.setPin(NEOPIXEL_PIN);
116
       #endif
118
       #endif
117
     #endif
119
     #endif
120
+    TERN_(HAS_PAUSE_SERVO_OUTPUT, RESUME_SERVO_OUTPUT());
118
   }
121
   }
119
 
122
 
120
   #if 0
123
   #if 0

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

1997
 #if NUM_SERVOS > 0
1997
 #if NUM_SERVOS > 0
1998
   #define HAS_SERVOS 1
1998
   #define HAS_SERVOS 1
1999
 #endif
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
 // Sensors
2004
 // Sensors
2002
 #if PIN_EXISTS(FILWIDTH)
2005
 #if PIN_EXISTS(FILWIDTH)

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

23
 opt_set E2_AUTO_FAN_PIN PC12
23
 opt_set E2_AUTO_FAN_PIN PC12
24
 opt_set X_DRIVER_TYPE TMC2208
24
 opt_set X_DRIVER_TYPE TMC2208
25
 opt_set Y_DRIVER_TYPE TMC2130
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
 opt_enable FILAMENT_RUNOUT_SENSOR NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE
28
 opt_enable FILAMENT_RUNOUT_SENSOR NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE
28
 opt_set FIL_RUNOUT_PIN 3
29
 opt_set FIL_RUNOUT_PIN 3
29
 opt_set FIL_RUNOUT2_PIN 4
30
 opt_set FIL_RUNOUT2_PIN 4

Loading…
Cancel
Save