mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-28 10:43:58 -04:00
AP_HAL_Linux: reset duty cycle before setting period
On kernels 4.7+ duty_cycle should always be less than period. Otherways, we'll get a EINVAL. It makes sense to set duty_cycle to 0, as duty_cycle doesn't really make sense without a proper period. A proper way to handle these errors might be to call pwm_adjust_config in every pwmchip backend but it's unrealistic to hope that all vendors will do it quickly.
This commit is contained in:
parent
cc55e5a8fa
commit
d214a36e0a
@ -94,6 +94,8 @@ bool PWM_Sysfs_Base::is_enabled()
|
|||||||
|
|
||||||
void PWM_Sysfs_Base::set_period(uint32_t nsec_period)
|
void PWM_Sysfs_Base::set_period(uint32_t nsec_period)
|
||||||
{
|
{
|
||||||
|
set_duty_cycle(0);
|
||||||
|
|
||||||
if (Util::from(hal.util)->write_file(_period_path, "%u", nsec_period) < 0) {
|
if (Util::from(hal.util)->write_file(_period_path, "%u", nsec_period) < 0) {
|
||||||
hal.console->printf("LinuxPWM_Sysfs: %s Unable to set period\n",
|
hal.console->printf("LinuxPWM_Sysfs: %s Unable to set period\n",
|
||||||
_period_path);
|
_period_path);
|
||||||
|
Loading…
Reference in New Issue
Block a user