kosmos/source/test/pwm/main.c
2016-08-09 12:52:38 +02:00

49 lines
834 B
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"
#define TH_STACK_SIZE 256
stack_t th_stack[TH_STACK_SIZE];
struct thread_context th_ctx;
static void th_func(void *arg)
{
unsigned int duty = 0;
open(&pwm_4);
while(1) {
while(duty < 100) {
ioctl(&pwm_4, IOCTL_PWM_SET_DUTY_CYCLE, (const void *)&duty);
pwm_set_duty_cycle(&pwm_ch4, duty);
sleep_ms(10);
duty++;
}
while(duty > 0) {
ioctl(&pwm_4, IOCTL_PWM_SET_DUTY_CYCLE, (const void *)&duty);
sleep_ms(10);
duty--;
}
}
}
int main(void)
{
thread_create(&th_ctx, th_stack, TH_STACK_SIZE, th_func, NULL, THREAD_PRIO_LOW);
schedule_start();
return 0;
}