fix: 修改运动方向
This commit is contained in:
@@ -116,7 +116,7 @@ void by_stepper_init(void)
|
|||||||
DWT_Delay(40U * (uint16_t)by_stepper.speed);
|
DWT_Delay(40U * (uint16_t)by_stepper.speed);
|
||||||
}
|
}
|
||||||
|
|
||||||
by_stepper_set_speed(STEPPER_SPEED_DIV1);
|
by_stepper_set_speed(STEPPER_SPEED_DIV4);
|
||||||
|
|
||||||
while (gpio_input_data_bit_read(GPIOB, GPIO_PINS_10) == SET) {
|
while (gpio_input_data_bit_read(GPIOB, GPIO_PINS_10) == SET) {
|
||||||
gpio_bits_write(GPIOA, GPIO_PINS_8, by_stepper.dir ? TRUE : FALSE); // DIR
|
gpio_bits_write(GPIOA, GPIO_PINS_8, by_stepper.dir ? TRUE : FALSE); // DIR
|
||||||
@@ -135,7 +135,7 @@ void by_stepper_init(void)
|
|||||||
void by_stepper_loop(void)
|
void by_stepper_loop(void)
|
||||||
{
|
{
|
||||||
int16_t temp = (int16_t)tmr_counter_value_get(TMR3);
|
int16_t temp = (int16_t)tmr_counter_value_get(TMR3);
|
||||||
position += (int64_t)temp;
|
position -= (int64_t)temp;
|
||||||
tmr_counter_value_set(TMR3, 0);
|
tmr_counter_value_set(TMR3, 0);
|
||||||
|
|
||||||
if (running_flag) {
|
if (running_flag) {
|
||||||
@@ -148,10 +148,10 @@ void by_stepper_loop(void)
|
|||||||
} else // 正常模式
|
} else // 正常模式
|
||||||
{
|
{
|
||||||
if (position_offset > 0) {
|
if (position_offset > 0) {
|
||||||
by_stepper_set_dir(0);
|
by_stepper_set_dir(1);
|
||||||
by_stepper_run();
|
by_stepper_run();
|
||||||
} else if (position_offset < 0) {
|
} else if (position_offset < 0) {
|
||||||
by_stepper_set_dir(1);
|
by_stepper_set_dir(0);
|
||||||
by_stepper_run();
|
by_stepper_run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,7 +165,7 @@ void by_stepper_loop(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
by_stepper_stop(0);
|
by_stepper_stop(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (position_offset) {
|
// if (position_offset) {
|
||||||
|
|||||||
Reference in New Issue
Block a user