drivers: pwm: always use nanoseconds for set

In order to be consistent with what is possible in Devicetree, always
take a period in nanoseconds. Other scales or units may be specified by
using, e.g., the PWM_MSEC() macros (all of them converting down to
nanoseconds). This change then deletes the "_nsec" and "_usec" versions
of the pwm_set call.

Note that this change limits the period to UINT32_MAX nanoseconds,
~4.3s. PWM is, in generali, used with periods below the second so it
should not be a problem.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
Gerard Marull-Paretas 2022-04-27 13:02:27 +02:00 committed by Carles Cufí
commit ae91933c4a
12 changed files with 53 additions and 150 deletions

View file

@ -49,7 +49,7 @@ static int led_pwm_blink(const struct device *dev, uint32_t led,
dt_led = &config->led[led];
return pwm_set_usec_dt(dt_led, period_usec, pulse_usec);
return pwm_set_dt(dt_led, PWM_USEC(period_usec), PWM_USEC(pulse_usec));
}
static int led_pwm_set_brightness(const struct device *dev,
@ -64,8 +64,8 @@ static int led_pwm_set_brightness(const struct device *dev,
dt_led = &config->led[led];
return pwm_set_nsec_pulse_dt(&config->led[led],
dt_led->period * value / 100);
return pwm_set_pulse_dt(&config->led[led],
dt_led->period * value / 100);
}
static int led_pwm_on(const struct device *dev, uint32_t led)