kosmos/source/firmware/kernel/driver/pwm.c

34 lines
659 B
C
Raw Normal View History

2016-08-09 10:28:01 +00:00
/*
* pwm.c
*
* Created on: Aug 9, 2016
* Author: tkl
*/
#include <stddef.h>
#include <pwm.h>
int pwm_open(const struct pwm *device)
{
if(NULL == device)
return -1;
pwm_fp_open_t open = device->fp->open;
return open(device->arch_dep_device);
}
int pwm_close(const struct pwm *device)
{
if(NULL == device)
return -1;
pwm_fp_close_t close = device->fp->close;
return close(device->arch_dep_device);
}
int pwm_set_duty_cycle(const struct pwm *device, unsigned int duty_cycle_percent)
{
if(NULL == device)
return -1;
pwm_fp_set_duty_cycle_t set = device->fp->set_duty_cycle;
return set(device->arch_dep_device, duty_cycle_percent);
}