mirror of
https://github.com/odriverobotics/ODrive.git
synced 2026-09-23 09:03:40 +08:00
Optimize step/dir callback
This commit is contained in:
+3
-3
@@ -3,7 +3,7 @@
|
||||
{
|
||||
"name": "Win32",
|
||||
"includePath": [
|
||||
"${workspaceRoot}/**"
|
||||
"${workspaceFolder}/**"
|
||||
],
|
||||
"defines": [
|
||||
"STM32F405xx",
|
||||
@@ -24,7 +24,7 @@
|
||||
{
|
||||
"name": "Linux",
|
||||
"includePath": [
|
||||
"${workspaceRoot}/**"
|
||||
"${workspaceFolder}/**"
|
||||
],
|
||||
"defines": [
|
||||
"STM32F405xx",
|
||||
@@ -44,7 +44,7 @@
|
||||
{
|
||||
"name": "Mac",
|
||||
"includePath": [
|
||||
"${workspaceRoot}/**"
|
||||
"${workspaceFolder}/**"
|
||||
],
|
||||
"defines": [
|
||||
"STM32F405xx",
|
||||
|
||||
@@ -118,12 +118,10 @@ bool Axis::wait_for_current_meas() {
|
||||
|
||||
// step/direction interface
|
||||
void Axis::step_cb() {
|
||||
if (step_dir_active_) {
|
||||
GPIO_PinState dir_pin = HAL_GPIO_ReadPin(dir_port_, dir_pin_);
|
||||
float dir = (dir_pin == GPIO_PIN_SET) ? 1.0f : -1.0f;
|
||||
controller_.input_pos_ += dir * config_.counts_per_step;
|
||||
controller_.input_pos_updated();
|
||||
}
|
||||
const GPIO_PinState dir_pin = (GPIO_PinState)(dir_port_->IDR & dir_pin_);
|
||||
const int32_t dir = (1 - 2 * (int32_t)dir_pin) * step_dir_active_;
|
||||
controller_.input_pos_ += dir * config_.counts_per_step;
|
||||
controller_.input_pos_updated();
|
||||
};
|
||||
|
||||
void Axis::load_default_step_dir_pin_config(
|
||||
|
||||
@@ -26,9 +26,6 @@ void Controller::set_error(Error error) {
|
||||
// Command Handling
|
||||
//--------------------------------
|
||||
|
||||
void Controller::input_pos_updated() {
|
||||
input_pos_updated_ = true;
|
||||
}
|
||||
|
||||
bool Controller::select_encoder(size_t encoder_num) {
|
||||
if (encoder_num < AXIS_COUNT) {
|
||||
|
||||
@@ -52,7 +52,10 @@ public:
|
||||
void reset();
|
||||
void set_error(Error error);
|
||||
|
||||
void input_pos_updated();
|
||||
constexpr void input_pos_updated() {
|
||||
input_pos_updated_ = true;
|
||||
}
|
||||
|
||||
bool select_encoder(size_t encoder_num);
|
||||
|
||||
// Trajectory-Planned control
|
||||
|
||||
Reference in New Issue
Block a user