Skip to content

Commit

Permalink
🐛 [LCP1768] Init PWM in set_pwm_duty (#23110)
Browse files Browse the repository at this point in the history
  • Loading branch information
descipher authored Nov 12, 2021
1 parent 4a840e1 commit 649c768
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Marlin/src/HAL/LPC1768/fast_pwm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
#include <pwm.h>

void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) {
LPC176x::pwm_write_ratio(pin, invert ? 1.0f - (float)v / v_size : (float)v / v_size);
if (!LPC176x::pin_is_valid(pin)) return;
if (LPC176x::pwm_attach_pin(pin))
LPC176x::pwm_write_ratio(pin, invert ? 1.0f - (float)v / v_size : (float)v / v_size); // map 1-254 onto PWM range
}

#if NEEDS_HARDWARE_PWM // Specific meta-flag for features that mandate PWM
Expand Down

0 comments on commit 649c768

Please sign in to comment.