kosmos/source/test/pwm/main.c

47 lines
1.1 KiB
C

/*
* main.c
*
* Created on: Aug 2, 2016
* Author: tkl
*/
#include <stdbool.h>
#include "driver.h"
#include "board.h"
#include "stack.h"
#include "queue.h"
#include "kernel.h"
#include "driver.h"
#include "list.h"
#include "shell.h"
int main(void)
{
drv_open(&pwm_1);
drv_open(&pwm_2);
drv_open(&pwm_3);
drv_open(&pwm_4);
drv_open(&pwm5_c2);
while(1) {
for(unsigned int duty = 0; duty < 100; duty++) {
drv_ioctl(&pwm_1, IOCTL_PWM_SET_DUTY_CYCLE, (const void *)&duty);
drv_ioctl(&pwm_2, IOCTL_PWM_SET_DUTY_CYCLE, (const void *)&duty);
drv_ioctl(&pwm_3, IOCTL_PWM_SET_DUTY_CYCLE, (const void *)&duty);
drv_ioctl(&pwm_4, IOCTL_PWM_SET_DUTY_CYCLE, (const void *)&duty);
sleep_ms(10);
}
for(unsigned int duty = 98; duty > 0; duty--) {
drv_ioctl(&pwm_1, IOCTL_PWM_SET_DUTY_CYCLE, (const void *)&duty);
drv_ioctl(&pwm_2, IOCTL_PWM_SET_DUTY_CYCLE, (const void *)&duty);
drv_ioctl(&pwm_3, IOCTL_PWM_SET_DUTY_CYCLE, (const void *)&duty);
drv_ioctl(&pwm_4, IOCTL_PWM_SET_DUTY_CYCLE, (const void *)&duty);
sleep_ms(10);
}
}
return 0;
}