Implemented Stop on Zero Step
This commit is contained in:
@@ -18,7 +18,8 @@ counter:
|
||||
; SM 3 + 2 -> IRQ 1
|
||||
PULL
|
||||
MOV X, OSR
|
||||
IRQ WAIT 2 REL
|
||||
JMP !X l1_end
|
||||
JMP X-- l1
|
||||
l1:
|
||||
PULL NOBLOCK
|
||||
IRQ WAIT 2 REL
|
||||
@@ -29,6 +30,7 @@ l1:
|
||||
MOV X, OSR
|
||||
JMP X-- l1
|
||||
|
||||
l1_end:
|
||||
IRQ SET 0 REL
|
||||
; SM 2 + 0 -> IRQ 2
|
||||
; SM 3 + 0 -> IRQ 3
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include "hardware/irq.h"
|
||||
#include <pico/time.h>
|
||||
|
||||
#include <math.h>
|
||||
|
||||
TMC2209_step_dual * g_step_driver_instance;
|
||||
|
||||
void step_irq0_handler() {
|
||||
@@ -164,14 +166,40 @@ void TMC2209_step_dual::set_conf1(uint frequency, bool dir) {
|
||||
};
|
||||
|
||||
void TMC2209_step_dual::pulse0(uint n) {
|
||||
this->done_flag0_arm = true;
|
||||
pio_sm_put_blocking(
|
||||
this->pio_core, this->sm_num_counter0, n-1
|
||||
this->pio_core, this->sm_num_counter0, n
|
||||
);
|
||||
};
|
||||
|
||||
void TMC2209_step_dual::pulse1(uint n) {
|
||||
this->done_flag1_arm = true;
|
||||
pio_sm_put_blocking(
|
||||
this->pio_core, this->sm_num_counter1, n-1
|
||||
this->pio_core, this->sm_num_counter1, n
|
||||
);
|
||||
};
|
||||
|
||||
void TMC2209_step_dual::pulse0_int(int n) {
|
||||
this->done_flag0_arm = true;
|
||||
if(n < 0) {
|
||||
n = abs(n);
|
||||
gpio_put(this->dir1_pin, gpio_get(this->dir1_pin) ^ 1);
|
||||
}
|
||||
|
||||
pio_sm_put_blocking(
|
||||
this->pio_core, this->sm_num_counter0, n
|
||||
);
|
||||
};
|
||||
|
||||
void TMC2209_step_dual::pulse1_int(int n) {
|
||||
this->done_flag1_arm = true;
|
||||
if(n < 0) {
|
||||
n = abs(n);
|
||||
gpio_put(this->dir1_pin, gpio_get(this->dir1_pin) ^ 1);
|
||||
}
|
||||
|
||||
pio_sm_put_blocking(
|
||||
this->pio_core, this->sm_num_counter1, n
|
||||
);
|
||||
};
|
||||
|
||||
@@ -196,7 +224,9 @@ void TMC2209_step_dual::irq_handler1() {
|
||||
bool TMC2209_step_dual::wait0(int timeout_ms) {
|
||||
int t = timeout_ms*1000;
|
||||
bool continues = timeout_ms <= 0;
|
||||
this->done_flag0_arm = true;
|
||||
|
||||
if(!this->done_flag0_arm)
|
||||
return true;
|
||||
|
||||
while(t > 0 || continues) {
|
||||
|
||||
@@ -218,13 +248,15 @@ bool TMC2209_step_dual::wait0(int timeout_ms) {
|
||||
bool TMC2209_step_dual::wait1(int timeout_ms) {
|
||||
int t = timeout_ms*1000;
|
||||
bool continues = timeout_ms <= 0;
|
||||
this->done_flag1_arm = true;
|
||||
|
||||
if(!this->done_flag1_arm)
|
||||
return true;
|
||||
|
||||
while(t > 0 || continues) {
|
||||
|
||||
if(done_flag0) {
|
||||
if(done_flag1) {
|
||||
this->done_flag1_arm = false;
|
||||
done_flag0 = false;
|
||||
done_flag1 = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user