Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STM32F1: secure the servo code + M280 detach #14085

Merged
merged 3 commits into from
May 22, 2019

Conversation

tpruvot
Copy link
Contributor

@tpruvot tpruvot commented May 22, 2019

  • A pin without timer would crash with tdev = nullptr
  • Allow M280 P0 S-1 to stop the pwm timer
  • ServoCount is not static, so it should be initialised to 0

- A pin without timer would crash with tdev = nullptr
- Allow M280 P0 S-1 to stop the pwm timer
@@ -68,23 +68,25 @@ libServo::libServo() {

bool libServo::attach(const int32_t pin, const int32_t minAngle, const int32_t maxAngle) {
if (this->servoIndex >= MAX_SERVOS) return false;
if (!PWM_PIN(pin)) return false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like something we should catch at compile time. Is that not possible?

Copy link
Contributor Author

@tpruvot tpruvot May 22, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually i changed that to do tpruvot@2ec402e

Copy link
Member

@thinkyhead thinkyhead May 22, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the pin is constant at compile time, it may be able to evaluate PWM_PIN at compile time. Note that HALs are free to define PWM_PIN as a function call, and then it would (perhaps) never be evaluated at compile time. Some HALs already define it with a bit of logic, in which cases it will probably not be evaluated at compile time.

@thinkyhead thinkyhead merged commit 24b1818 into MarlinFirmware:bugfix-2.0.x May 22, 2019
@tpruvot tpruvot deleted the stm32f1-servo branch May 23, 2019 07:39
ozgunawesome pushed a commit to ozgunawesome/Marlin that referenced this pull request May 29, 2019
@thinkyhead thinkyhead mentioned this pull request Sep 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants