// Default start values
this->a_move_finished = false;
- this->pending_sv = false;
+ this->do_move_finished = false;
this->reset_step_pins = false;
- this->set_frequency(0.001);
+ this->set_frequency(100000);
this->set_reset_delay(100);
this->set_acceleration_ticks_per_second(1000);
this->last_duration = 0;
this->num_motors= 0;
this->active_motor.reset();
this->acceleration_tick_cnt= 0;
+ this->do_acceleration_tick= false;
NVIC_EnableIRQ(TIMER0_IRQn); // Enable interrupt handler
NVIC_EnableIRQ(TIMER1_IRQn); // Enable interrupt handler
// }
}
}
- this->a_move_finished = false;
_isr_context = false;
}
// slightly lower priority than TIMER0, the whole end of block/start of block is done here allowing the timer to continue ticking
// also handles the acceleration tick
-void StepTicker::PendSV_IRQHandler (void){
- if(this->do_acceleration_tick) {
- this->do_acceleration_tick= false;
- // call registered acceleration handlers
- for (size_t i = 0; i < acceleration_tick_handlers.size(); ++i) {
- acceleration_tick_handlers[i]();
- }
- }
+void StepTicker::PendSV_IRQHandler (void) {
+
+ if(this->do_move_finished) {
+ this->do_move_finished= false;
- if(this->a_move_finished) {
#ifdef STEPTICKER_DEBUG_PIN
stepticker_debug_pin= 1;
#endif
#endif
}
- this->pending_sv= false;
+ if(this->do_acceleration_tick) {
+ this->do_acceleration_tick= false;
+ // call registered acceleration handlers
+ for (size_t i = 0; i < acceleration_tick_handlers.size(); ++i) {
+ acceleration_tick_handlers[i]();
+ }
+ }
}
void StepTicker::TIMER0_IRQHandler (void){
this->do_acceleration_tick= true;
}
+ if(this->a_move_finished) {
+ this->a_move_finished = false;
+ this->do_move_finished= 1;
+ }
+
// If a move finished in this tick, we have to tell the actuator to act accordingly
- if(!this->pending_sv && (this->a_move_finished || this->do_acceleration_tick)){
- this->pending_sv= true; // don't multiple trigger pendsv
+ if(this->do_move_finished || this->do_acceleration_tick){
// we delegate the slow stuff to the pendsv handler which will run as soon as this interrupt exits
//NVIC_SetPendingIRQ(PendSV_IRQn); this doesn't work
SCB->ICSR = 0x10000000; // SCB_ICSR_PENDSVSET_Msk;
# use c++11 features for the checksums and set default baud rate for serial uart
DEFINES += -DCHECKSUM_USE_CPP -DDEFAULT_SERIAL_BAUD_RATE=$(DEFAULT_SERIAL_BAUD_RATE)
-# Set a Pin here that toggles high on block begin and low on block end for debugging with logic analyzer
-#DEFINES += -DBLOCK_DEBUG_PIN=P4_29
-
-# Set a Pin here that toggles on Stepticker overrun for debugging with logic analyzer
-DEFINES += -DSTEPTICKER_DEBUG_PIN=P4_29
+ifneq "$(STEPTICKER_DEBUG_PIN)" ""
+# Set a Pin here that toggles on end of move
+DEFINES += -DSTEPTICKER_DEBUG_PIN=$(STEPTICKER_DEBUG_PIN)
+endif
# add any modules that you do not want included in the build
export EXCLUDED_MODULES = tools/touchprobe
using std::string;
#include <vector>
-#ifdef BLOCK_DEBUG_PIN
-#include "gpio.h"
-extern GPIO block_debug_pin;
-#endif
-
// A block represents a movement, it's length for each stepper motor, and the corresponding acceleration curves.
// It's stacked on a queue, and that queue is then executed in order, to move the motors.
// Most of the accel math is also done in this class
void Block::begin()
{
-#ifdef BLOCK_DEBUG_PIN
- block_debug_pin= 1;
-#endif
-
recalculate_flag = false;
if (!is_ready)
// Mark the block as no longer taken by one module, go to next block if this free's it
void Block::release()
{
- if (--this->times_taken <= 0)
- {
+ if (--this->times_taken <= 0) {
times_taken = 0;
- if (is_ready)
- {
-#ifdef BLOCK_DEBUG_PIN
- block_debug_pin= 0;
-#endif
+ if (is_ready) {
is_ready = false;
THEKERNEL->call_event(ON_BLOCK_END, this);
// ensure conveyor gets called last
THEKERNEL->conveyor->on_block_end(this);
-
}
}
}