34 lines
659 B
C
34 lines
659 B
C
|
/*
|
||
|
* 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);
|
||
|
}
|