diff --git a/Firmware/MotorControl/endstop.cpp b/Firmware/MotorControl/endstop.cpp index 72bcae3a..f8fc4480 100644 --- a/Firmware/MotorControl/endstop.cpp +++ b/Firmware/MotorControl/endstop.cpp @@ -43,7 +43,7 @@ void Endstop::set_enabled(bool enable) { GPIO_InitTypeDef GPIO_InitStruct; GPIO_InitStruct.Pin = gpio_pin; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; - GPIO_InitStruct.Pull = config_.is_active_high ? GPIO_PULLDOWN : GPIO_PULLUP; + GPIO_InitStruct.Pull = config_.pullup ? GPIO_PULLUP : GPIO_PULLDOWN; HAL_GPIO_Init(gpio_port, &GPIO_InitStruct); } } diff --git a/Firmware/MotorControl/endstop.hpp b/Firmware/MotorControl/endstop.hpp index ad9ef5ef..eb1e3c8e 100644 --- a/Firmware/MotorControl/endstop.hpp +++ b/Firmware/MotorControl/endstop.hpp @@ -4,14 +4,15 @@ class Endstop { public: struct Config_t { - float offset = 0; + float offset = 0; float debounce_ms = 50.0f; uint16_t gpio_num = 0; - bool enabled = false; + bool enabled = false; bool is_active_high = false; + bool pullup = false; }; - Endstop(Endstop::Config_t& config); + explicit Endstop(Endstop::Config_t& config); Endstop::Config_t& config_; Axis* axis_ = nullptr; @@ -34,6 +35,7 @@ class Endstop { [](void* ctx) { static_cast(ctx)->update_config(); }, this), make_protocol_property("offset", &config_.offset), make_protocol_property("is_active_high", &config_.is_active_high), + make_protocol_property("pullup", &config_.pullup), make_protocol_property("debounce_ms", &config_.debounce_ms))); }