Browse Source

Merge pull request #5246 from thinkyhead/rc_some_cleanup

Minor stepper cleanup
Scott Lahteine 8 years ago
parent
commit
9b96a4a53b
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

2023
     // When deploying make sure BLTOUCH is not already triggered
2023
     // When deploying make sure BLTOUCH is not already triggered
2024
     #if ENABLED(BLTOUCH)
2024
     #if ENABLED(BLTOUCH)
2025
       if (deploy && TEST_BLTOUCH()) { stop(); return true; }
2025
       if (deploy && TEST_BLTOUCH()) { stop(); return true; }
2026
-    #endif
2027
-
2028
-    #if ENABLED(Z_PROBE_SLED)
2026
+    #elif ENABLED(Z_PROBE_SLED)
2029
       if (axis_unhomed_error(true, false, false)) { stop(); return true; }
2027
       if (axis_unhomed_error(true, false, false)) { stop(); return true; }
2030
     #elif ENABLED(Z_PROBE_ALLEN_KEY)
2028
     #elif ENABLED(Z_PROBE_ALLEN_KEY)
2031
       if (axis_unhomed_error(true, true,  true )) { stop(); return true; }
2029
       if (axis_unhomed_error(true, true,  true )) { stop(); return true; }
2109
     // Tell the planner where we actually are
2107
     // Tell the planner where we actually are
2110
     SYNC_PLAN_POSITION_KINEMATIC();
2108
     SYNC_PLAN_POSITION_KINEMATIC();
2111
 
2109
 
2112
-
2113
     #if ENABLED(DEBUG_LEVELING_FEATURE)
2110
     #if ENABLED(DEBUG_LEVELING_FEATURE)
2114
       if (DEBUGGING(LEVELING)) DEBUG_POS("<<< do_probe_move", current_position);
2111
       if (DEBUGGING(LEVELING)) DEBUG_POS("<<< do_probe_move", current_position);
2115
     #endif
2112
     #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];
332
 
332
 
333
 void Stepper::isr() {
333
 void Stepper::isr() {
334
   if (cleaning_buffer_counter) {
334
   if (cleaning_buffer_counter) {
335
+    --cleaning_buffer_counter;
335
     current_block = NULL;
336
     current_block = NULL;
336
     planner.discard_current_block();
337
     planner.discard_current_block();
337
     #ifdef SD_FINISHED_RELEASECOMMAND
338
     #ifdef SD_FINISHED_RELEASECOMMAND
338
-      if ((cleaning_buffer_counter == 1) && (SD_FINISHED_STEPPERRELEASE)) enqueue_and_echo_commands_P(PSTR(SD_FINISHED_RELEASECOMMAND));
339
+      if (!cleaning_buffer_counter && (SD_FINISHED_STEPPERRELEASE)) enqueue_and_echo_commands_P(PSTR(SD_FINISHED_RELEASECOMMAND));
339
     #endif
340
     #endif
340
-    cleaning_buffer_counter--;
341
     OCR1A = 200; // Run at max speed - 10 KHz
341
     OCR1A = 200; // Run at max speed - 10 KHz
342
     return;
342
     return;
343
   }
343
   }
570
   #endif
570
   #endif
571
 
571
 
572
   // Calculate new timer value
572
   // Calculate new timer value
573
-  uint16_t timer, step_rate;
574
   if (step_events_completed <= (uint32_t)current_block->accelerate_until) {
573
   if (step_events_completed <= (uint32_t)current_block->accelerate_until) {
575
 
574
 
576
     MultiU24X32toH16(acc_step_rate, acceleration_time, current_block->acceleration_rate);
575
     MultiU24X32toH16(acc_step_rate, acceleration_time, current_block->acceleration_rate);
580
     NOMORE(acc_step_rate, current_block->nominal_rate);
579
     NOMORE(acc_step_rate, current_block->nominal_rate);
581
 
580
 
582
     // step_rate to timer interval
581
     // step_rate to timer interval
583
-    timer = calc_timer(acc_step_rate);
582
+    uint16_t timer = calc_timer(acc_step_rate);
584
     OCR1A = timer;
583
     OCR1A = timer;
585
     acceleration_time += timer;
584
     acceleration_time += timer;
586
 
585
 
622
     #endif
621
     #endif
623
   }
622
   }
624
   else if (step_events_completed > (uint32_t)current_block->decelerate_after) {
623
   else if (step_events_completed > (uint32_t)current_block->decelerate_after) {
624
+    uint16_t step_rate;
625
     MultiU24X32toH16(step_rate, deceleration_time, current_block->acceleration_rate);
625
     MultiU24X32toH16(step_rate, deceleration_time, current_block->acceleration_rate);
626
 
626
 
627
     if (step_rate < acc_step_rate) { // Still decelerating?
627
     if (step_rate < acc_step_rate) { // Still decelerating?
632
       step_rate = current_block->final_rate;
632
       step_rate = current_block->final_rate;
633
 
633
 
634
     // step_rate to timer interval
634
     // step_rate to timer interval
635
-    timer = calc_timer(step_rate);
635
+    uint16_t timer = calc_timer(step_rate);
636
     OCR1A = timer;
636
     OCR1A = timer;
637
     deceleration_time += timer;
637
     deceleration_time += timer;
638
 
638
 

+ 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