samples: blink_led: add support for PWM flags
Pass PWM flags set in the device tree, if any, to the pwm_pin_set_usec() functions. Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
This commit is contained in:
parent
3124cf8bff
commit
edd891adfd
1 changed files with 7 additions and 2 deletions
|
@ -19,6 +19,11 @@
|
|||
/* get the defines from dt (based on alias 'pwm-led0') */
|
||||
#define PWM_DRIVER DT_ALIAS_PWM_LED0_PWMS_CONTROLLER
|
||||
#define PWM_CHANNEL DT_ALIAS_PWM_LED0_PWMS_CHANNEL
|
||||
#ifdef DT_ALIAS_PWM_LED0_PWMS_FLAGS
|
||||
#define PWM_FLAGS DT_ALIAS_PWM_LED0_PWMS_FLAGS
|
||||
#else
|
||||
#define PWM_FLAGS 0
|
||||
#endif
|
||||
#else
|
||||
#error "Choose supported PWM driver"
|
||||
#endif
|
||||
|
@ -51,7 +56,7 @@ void main(void)
|
|||
*/
|
||||
max_period = MAX_PERIOD;
|
||||
while (pwm_pin_set_usec(pwm_dev, PWM_CHANNEL,
|
||||
max_period, max_period / 2U, 0)) {
|
||||
max_period, max_period / 2U, PWM_FLAGS)) {
|
||||
max_period /= 2U;
|
||||
if (max_period < (4U * MIN_PERIOD)) {
|
||||
printk("This sample needs to set a period that is "
|
||||
|
@ -63,7 +68,7 @@ void main(void)
|
|||
period = max_period;
|
||||
while (1) {
|
||||
if (pwm_pin_set_usec(pwm_dev, PWM_CHANNEL,
|
||||
period, period / 2U, 0)) {
|
||||
period, period / 2U, PWM_FLAGS)) {
|
||||
printk("pwm pin set fails\n");
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue