Browse Source

Minor stepper cleanup

Scott Lahteine 8 years ago
parent
commit
98600e1433
3 changed files with 10 additions and 13 deletions
  1. 1
    4
      Marlin/Marlin_main.cpp
  2. 7
    7
      Marlin/stepper.cpp
  3. 2
    2
      Marlin/stepper.h

+ 1
- 4
Marlin/Marlin_main.cpp View File

2017
     // When deploying make sure BLTOUCH is not already triggered
2017
     // When deploying make sure BLTOUCH is not already triggered
2018
     #if ENABLED(BLTOUCH)
2018
     #if ENABLED(BLTOUCH)
2019
       if (deploy && TEST_BLTOUCH()) { stop(); return true; }
2019
       if (deploy && TEST_BLTOUCH()) { stop(); return true; }
2020
-    #endif
2021
-
2022
-    #if ENABLED(Z_PROBE_SLED)
2020
+    #elif ENABLED(Z_PROBE_SLED)
2023
       if (axis_unhomed_error(true, false, false)) { stop(); return true; }
2021
       if (axis_unhomed_error(true, false, false)) { stop(); return true; }
2024
     #elif ENABLED(Z_PROBE_ALLEN_KEY)
2022
     #elif ENABLED(Z_PROBE_ALLEN_KEY)
2025
       if (axis_unhomed_error(true, true,  true )) { stop(); return true; }
2023
       if (axis_unhomed_error(true, true,  true )) { stop(); return true; }
2103
     // Tell the planner where we actually are
2101
     // Tell the planner where we actually are
2104
     SYNC_PLAN_POSITION_KINEMATIC();
2102
     SYNC_PLAN_POSITION_KINEMATIC();
2105
 
2103
 
2106
-
2107
     #if ENABLED(DEBUG_LEVELING_FEATURE)
2104
     #if ENABLED(DEBUG_LEVELING_FEATURE)
2108
       if (DEBUGGING(LEVELING)) DEBUG_POS("<<< do_probe_move", current_position);
2105
       if (DEBUGGING(LEVELING)) DEBUG_POS("<<< do_probe_move", current_position);
2109
     #endif
2106
     #endif

+ 7
- 7
Marlin/stepper.cpp View File

91
 
91
 
92
 #if ENABLED(ADVANCE) || ENABLED(LIN_ADVANCE)
92
 #if ENABLED(ADVANCE) || ENABLED(LIN_ADVANCE)
93
 
93
 
94
-  unsigned char Stepper::old_OCR0A = 0;
95
-  volatile unsigned char Stepper::eISR_Rate = 200; // Keep the ISR at a low rate until needed
94
+  uint8_t Stepper::old_OCR0A = 0;
95
+  volatile uint8_t Stepper::eISR_Rate = 200; // Keep the ISR at a low rate until needed
96
 
96
 
97
   #if ENABLED(LIN_ADVANCE)
97
   #if ENABLED(LIN_ADVANCE)
98
     volatile int Stepper::e_steps[E_STEPPERS];
98
     volatile int Stepper::e_steps[E_STEPPERS];
328
 
328
 
329
 void Stepper::isr() {
329
 void Stepper::isr() {
330
   if (cleaning_buffer_counter) {
330
   if (cleaning_buffer_counter) {
331
+    --cleaning_buffer_counter;
331
     current_block = NULL;
332
     current_block = NULL;
332
     planner.discard_current_block();
333
     planner.discard_current_block();
333
     #ifdef SD_FINISHED_RELEASECOMMAND
334
     #ifdef SD_FINISHED_RELEASECOMMAND
334
-      if ((cleaning_buffer_counter == 1) && (SD_FINISHED_STEPPERRELEASE)) enqueue_and_echo_commands_P(PSTR(SD_FINISHED_RELEASECOMMAND));
335
+      if (!cleaning_buffer_counter && (SD_FINISHED_STEPPERRELEASE)) enqueue_and_echo_commands_P(PSTR(SD_FINISHED_RELEASECOMMAND));
335
     #endif
336
     #endif
336
-    cleaning_buffer_counter--;
337
     OCR1A = 200; // Run at max speed - 10 KHz
337
     OCR1A = 200; // Run at max speed - 10 KHz
338
     return;
338
     return;
339
   }
339
   }
551
   #endif
551
   #endif
552
 
552
 
553
   // Calculate new timer value
553
   // Calculate new timer value
554
-  uint16_t timer, step_rate;
555
   if (step_events_completed <= (uint32_t)current_block->accelerate_until) {
554
   if (step_events_completed <= (uint32_t)current_block->accelerate_until) {
556
 
555
 
557
     MultiU24X32toH16(acc_step_rate, acceleration_time, current_block->acceleration_rate);
556
     MultiU24X32toH16(acc_step_rate, acceleration_time, current_block->acceleration_rate);
561
     NOMORE(acc_step_rate, current_block->nominal_rate);
560
     NOMORE(acc_step_rate, current_block->nominal_rate);
562
 
561
 
563
     // step_rate to timer interval
562
     // step_rate to timer interval
564
-    timer = calc_timer(acc_step_rate);
563
+    uint16_t timer = calc_timer(acc_step_rate);
565
     OCR1A = timer;
564
     OCR1A = timer;
566
     acceleration_time += timer;
565
     acceleration_time += timer;
567
 
566
 
603
     #endif
602
     #endif
604
   }
603
   }
605
   else if (step_events_completed > (uint32_t)current_block->decelerate_after) {
604
   else if (step_events_completed > (uint32_t)current_block->decelerate_after) {
605
+    uint16_t step_rate;
606
     MultiU24X32toH16(step_rate, deceleration_time, current_block->acceleration_rate);
606
     MultiU24X32toH16(step_rate, deceleration_time, current_block->acceleration_rate);
607
 
607
 
608
     if (step_rate < acc_step_rate) { // Still decelerating?
608
     if (step_rate < acc_step_rate) { // Still decelerating?
613
       step_rate = current_block->final_rate;
613
       step_rate = current_block->final_rate;
614
 
614
 
615
     // step_rate to timer interval
615
     // step_rate to timer interval
616
-    timer = calc_timer(step_rate);
616
+    uint16_t timer = calc_timer(step_rate);
617
     OCR1A = timer;
617
     OCR1A = timer;
618
     deceleration_time += timer;
618
     deceleration_time += timer;
619
 
619
 

+ 2
- 2
Marlin/stepper.h View File

105
     static volatile uint32_t step_events_completed; // The number of step events executed in the current block
105
     static volatile uint32_t step_events_completed; // The number of step events executed in the current block
106
 
106
 
107
     #if ENABLED(ADVANCE) || ENABLED(LIN_ADVANCE)
107
     #if ENABLED(ADVANCE) || ENABLED(LIN_ADVANCE)
108
-      static unsigned char old_OCR0A;
109
-      static volatile unsigned char eISR_Rate;
108
+      static uint8_t old_OCR0A;
109
+      static volatile uint8_t eISR_Rate;
110
       #if ENABLED(LIN_ADVANCE)
110
       #if ENABLED(LIN_ADVANCE)
111
         static volatile int e_steps[E_STEPPERS];
111
         static volatile int e_steps[E_STEPPERS];
112
         static int final_estep_rate;
112
         static int final_estep_rate;

Loading…
Cancel
Save