possibly saving some time in the step interrupt
authorArthur Wolf <wolf.arthur@gmail.com>
Thu, 21 Feb 2013 12:11:55 +0000 (13:11 +0100)
committerArthur Wolf <wolf.arthur@gmail.com>
Thu, 21 Feb 2013 12:11:55 +0000 (13:11 +0100)
src/libs/StepTicker.cpp
src/libs/StepTicker.h

index 38a372f..5a80538 100644 (file)
@@ -78,17 +78,14 @@ StepperMotor* StepTicker::add_stepper_motor(StepperMotor* stepper_motor){
 // Call tick() on each active motor
 inline void StepTicker::tick(){
     _isr_context = true;
-
     int i;
-    uint32_t bm;
-    for (i = 0, bm = 1; i < 12; i++, bm <<= 1)
-    {
-        if (this->active_motor_bm & bm)
-        {
+    uint32_t bm = 1;
+    // We iterate over each active motor 
+    for (i = 0; i < 12; i++, bm <<= 1){
+        if (this->active_motor_bm & bm){
             this->active_motors[i]->tick();
         }
     }
-
     _isr_context = false;
 }
 
@@ -169,11 +166,17 @@ extern "C" void TIMER0_IRQHandler (void){
     // Step pins
     global_step_ticker->tick();
 
+
     // We may have set a pin on in this tick, now we start the timer to set it off
     if( global_step_ticker->reset_step_pins ){
         LPC_TIM1->TCR = 3;
         LPC_TIM1->TCR = 1;
         global_step_ticker->reset_step_pins = false;
+    }else{
+        // Nothing happened, nothing after this really matters
+        // TODO : This could be a problem when we use Actuators instead of StepperMotors, because this flag is specific to step generation
+        LPC_GPIO1->FIOCLR = 1<<18;
+        return;
     }
 
     // If a move finished in this tick, we have to tell the actuator to act accordingly
index 911b8d2..642216b 100644 (file)
@@ -42,6 +42,8 @@ class StepTicker{
 
         StepperMotor* active_motors[12];
         uint32_t active_motor_bm;
+
+
 };