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

int main(void)
{
   const struct device *pwm;

   pwm = device_get_binding("PWM_0");
   if (!pwm) {
		printk("Error\n");
		return;
	}

  pwm_pin_set_usec(pwm,13,100,50,0);
  //pwm_pin_set_usec(pwm,14,100000,50,0);
   
}*/

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

#define PWM_DEVICE_NAME DT_PROP(DT_NODELABEL(pwm0), label)
#define PWM_CH0_PIN DT_PROP(DT_NODELABEL(pwm0), ch0_pin)
#define PWM_CH1_PIN DT_PROP(DT_NODELABEL(pwm0), ch1_pin)


#define PWM_PERIOD 253

void main(void)
{
	printk("PWM Application has started!\r\n");
	u8_t pulse = 0;
	struct device *pwm_dev = device_get_binding(PWM_DEVICE_NAME);
	if (!pwm_dev) {
		printk("Cannot find %s!\n", PWM_DEVICE_NAME);
		return;
	}
    while (1)
    {                
      pulse = pulse +10;
      if (pulse > PWM_PERIOD) {
        pulse = 0;
      }
      pwm_pin_set_usec(pwm_dev, PWM_CH1_PIN, PWM_PERIOD, pulse, 0);
      pwm_pin_set_usec(pwm_dev, PWM_CH0_PIN, PWM_PERIOD, pulse, 0);
      k_sleep(K_MSEC(30));
    }
}