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:
parent
2bc6279866
commit
ae91933c4a
12 changed files with 53 additions and 150 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue