/*
 * Copyright (c) 2016 Intel Corporation
 * Copyright (c) 2020 Nordic Semiconductor ASA
 *
 * SPDX-License-Identifier: Apache-2.0
 */

/**
 * @file Sample app to demonstrate PWM.
 */

#include <zephyr/kernel.h>
#include <zephyr/sys/printk.h>
#include <zephyr/device.h>
#include <zephyr/drivers/pwm.h>

static const struct pwm_dt_spec pwm_led0 = PWM_DT_SPEC_GET(DT_ALIAS(pwm_led0));
static const struct pwm_dt_spec pwm_led1 = PWM_DT_SPEC_GET(DT_ALIAS(pwm_led1));
static const struct pwm_dt_spec pwm_led2 = PWM_DT_SPEC_GET(DT_ALIAS(pwm_led2));
static const struct pwm_dt_spec pwm_led3 = PWM_DT_SPEC_GET(DT_ALIAS(pwm_led3));

int main(void)
{
	printk("LED control: LED1=ON, LED2=OFF, LED3=ON, LED4=OFF\n");

	/* LED1 (P1.14) - ON: 100% duty cycle */
	pwm_set_dt(&pwm_led0, PWM_MSEC(20U), PWM_MSEC(20U));
	/* LED2 (P1.13) - ON: 100% duty cycle */
	pwm_set_dt(&pwm_led1, PWM_MSEC(20U), PWM_MSEC(20U));
	/* LED3 (P1.12) - ON: 100% duty cycle */
	pwm_set_dt(&pwm_led2, PWM_MSEC(20U), PWM_MSEC(20U));
	/* LED4 (P1.11) - ON: 100% duty cycle */
	pwm_set_dt(&pwm_led3, PWM_MSEC(20U), PWM_MSEC(20U));

	while (1) {
		k_sleep(K_FOREVER);
	}
	return 0;
}
