pwm driver hal'd

This commit is contained in:
tkl
2016-08-18 11:24:22 +02:00
parent bec6f26366
commit f2bfac4795
8 changed files with 253 additions and 192 deletions

53
source/test/pwm/main.c Normal file
View File

@@ -0,0 +1,53 @@
/*
* 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)
{
drv_open(&pwm_1);
drv_open(&pwm_2);
drv_open(&pwm_3);
drv_open(&pwm_4);
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);
}
}
}
int main(void)
{
board_init();
thread_create(&th_ctx, th_stack, TH_STACK_SIZE, th_func, NULL, THREAD_PRIO_LOW);
schedule_start();
return 0;
}

1
source/test/pwm/pwm.mk Normal file
View File

@@ -0,0 +1 @@
SRC_DIR += source/test/pwm