Update Motion for the new TMC2130/pins definitions
parent
531f60ed27
commit
ef7c776461
|
|
@ -1,5 +1,4 @@
|
|||
#include "motion.h"
|
||||
#include "../hal/shr16.h"
|
||||
|
||||
namespace modules {
|
||||
namespace motion {
|
||||
|
|
@ -22,7 +21,7 @@ uint16_t Motion::CurrentPos(Axis axis) const { return 0; }
|
|||
|
||||
void Motion::Home(Axis axis, bool direction) {}
|
||||
|
||||
void Motion::SetMode(MotorMode mode) {}
|
||||
void Motion::SetMode(hal::tmc2130::MotorMode mode) {}
|
||||
|
||||
void Motion::Step() {}
|
||||
|
||||
|
|
@ -32,40 +31,5 @@ void Motion::AbortPlannedMoves() {}
|
|||
|
||||
void ISR() {}
|
||||
|
||||
//@@TODO check the directions
|
||||
void StepDirPins::SetIdlerDirUp() {
|
||||
hal::shr16::shr16.SetTMCDir(Axis::Idler, true);
|
||||
}
|
||||
|
||||
void StepDirPins::SetIdlerDirDown() {
|
||||
hal::shr16::shr16.SetTMCDir(Axis::Idler, false);
|
||||
}
|
||||
|
||||
void StepDirPins::SetSelectorDirLeft() {
|
||||
hal::shr16::shr16.SetTMCDir(Axis::Selector, true);
|
||||
}
|
||||
void StepDirPins::SetSelectorDirRight() {
|
||||
hal::shr16::shr16.SetTMCDir(Axis::Selector, false);
|
||||
}
|
||||
|
||||
void StepDirPins::SetPulleyDirPull() {
|
||||
hal::shr16::shr16.SetTMCDir(Axis::Pulley, true);
|
||||
}
|
||||
void StepDirPins::SetPulleyDirPush() {
|
||||
hal::shr16::shr16.SetTMCDir(Axis::Pulley, false);
|
||||
}
|
||||
|
||||
void StepDirPins::StepIdler(uint8_t on) {
|
||||
// PORTD |= idler_step_pin;
|
||||
}
|
||||
|
||||
void StepDirPins::StepSelector(uint8_t on) {
|
||||
// PORTD |= selector_step_pin;
|
||||
}
|
||||
|
||||
void StepDirPins::StepPulley(uint8_t on) {
|
||||
// PORTB |= pulley_step_pin;
|
||||
}
|
||||
|
||||
} // namespace motion
|
||||
} // namespace modules
|
||||
|
|
|
|||
|
|
@ -1,5 +1,10 @@
|
|||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include "../config/config.h"
|
||||
#include "../hal/tmc2130.h"
|
||||
#include "../pins.h"
|
||||
|
||||
namespace modules {
|
||||
|
||||
/// @@TODO
|
||||
/// Logic of motor handling
|
||||
|
|
@ -20,8 +25,6 @@
|
|||
/// rotate(speed)
|
||||
/// rotate(speed, angle/steps)
|
||||
/// home?
|
||||
|
||||
namespace modules {
|
||||
namespace motion {
|
||||
|
||||
enum Axis {
|
||||
|
|
@ -30,35 +33,11 @@ enum Axis {
|
|||
Idler,
|
||||
};
|
||||
|
||||
enum MotorMode {
|
||||
Stealth,
|
||||
Normal
|
||||
};
|
||||
|
||||
enum IdlerMode {
|
||||
Engage,
|
||||
Disengage
|
||||
};
|
||||
|
||||
/// As step and dir pins are randomly scattered on the board for each of the axes/motors
|
||||
/// it is convenient to make a common interface for them
|
||||
class StepDirPins {
|
||||
public:
|
||||
static void SetIdlerDirUp();
|
||||
static void SetIdlerDirDown();
|
||||
|
||||
static void SetSelectorDirLeft();
|
||||
static void SetSelectorDirRight();
|
||||
|
||||
static void SetPulleyDirPull();
|
||||
static void SetPulleyDirPush();
|
||||
|
||||
static void StepIdler(uint8_t on);
|
||||
static void StepSelector(uint8_t on);
|
||||
static void StepPulley(uint8_t on);
|
||||
};
|
||||
|
||||
/// @@TODO this is subject of discussion and change in the future
|
||||
class Motion {
|
||||
public:
|
||||
inline constexpr Motion() = default;
|
||||
|
|
@ -96,7 +75,7 @@ public:
|
|||
|
||||
/// Set mode of TMC/motors operation
|
||||
/// Common for all axes/motors
|
||||
void SetMode(MotorMode mode);
|
||||
void SetMode(hal::tmc2130::MotorMode mode);
|
||||
|
||||
/// State machine doing all the planning and stepping preparation based on received commands
|
||||
void Step();
|
||||
|
|
|
|||
12
src/pins.h
12
src/pins.h
|
|
@ -13,3 +13,15 @@ static constexpr hal::gpio::GPIO_pin SHR16_CLOCK = { GPIOC, 7 }; ///SHCP
|
|||
|
||||
static constexpr hal::gpio::GPIO_pin USART_RX = { GPIOD, 2 };
|
||||
static constexpr hal::gpio::GPIO_pin USART_TX = { GPIOD, 3 };
|
||||
|
||||
static constexpr hal::gpio::GPIO_pin IDLER_CS_PIN = { GPIOB, 0 }; // TODO
|
||||
static constexpr hal::gpio::GPIO_pin IDLER_SG_PIN = { GPIOB, 0 }; // TODO
|
||||
static constexpr hal::gpio::GPIO_pin IDLER_STEP_PIN = { GPIOB, 0 }; // TODO
|
||||
|
||||
static constexpr hal::gpio::GPIO_pin PULLEY_CS_PIN = { GPIOB, 0 }; // TODO
|
||||
static constexpr hal::gpio::GPIO_pin PULLEY_SG_PIN = { GPIOB, 0 }; // TODO
|
||||
static constexpr hal::gpio::GPIO_pin PULLEY_STEP_PIN = { GPIOB, 0 }; // TODO
|
||||
|
||||
static constexpr hal::gpio::GPIO_pin SELECTOR_CS_PIN = { GPIOB, 0 }; // TODO
|
||||
static constexpr hal::gpio::GPIO_pin SELECTOR_SG_PIN = { GPIOB, 0 }; // TODO
|
||||
static constexpr hal::gpio::GPIO_pin SELECTOR_STEP_PIN = { GPIOB, 0 }; // TODO
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ void Motion::Home(Axis axis, bool direction) {
|
|||
axes[Pulley].homed = true;
|
||||
}
|
||||
|
||||
void Motion::SetMode(MotorMode mode) {
|
||||
void Motion::SetMode(hal::tmc2130::MotorMode mode) {
|
||||
}
|
||||
|
||||
void Motion::Step() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue