2016-08-09 10:28:01 +00:00
|
|
|
/*
|
|
|
|
* pwm.h
|
|
|
|
*
|
|
|
|
* Created on: Aug 9, 2016
|
|
|
|
* Author: tkl
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SOURCE_FIRMWARE_KERNEL_DRIVER_INCLUDE_PWM_H_
|
|
|
|
#define SOURCE_FIRMWARE_KERNEL_DRIVER_INCLUDE_PWM_H_
|
|
|
|
|
|
|
|
//! \brief Function pointer to the open function.
|
|
|
|
typedef int (*pwm_fp_open_t)(const void*);
|
|
|
|
|
|
|
|
//! \brief Function pointer to the close function.
|
|
|
|
typedef int (*pwm_fp_close_t)(const void*);
|
|
|
|
|
|
|
|
typedef int (*pwm_fp_set_duty_cycle_t)(const void*, unsigned int duty_cycle_percent);
|
|
|
|
|
2016-08-29 14:12:51 +00:00
|
|
|
typedef int (*pwm_fp_get_period_ns_t)(const void*);
|
|
|
|
typedef int (*pwm_fp_get_pulse_width_ns_t)(const void*);
|
|
|
|
|
2016-08-09 10:28:01 +00:00
|
|
|
struct pwm_fp {
|
|
|
|
const pwm_fp_open_t open;
|
|
|
|
const pwm_fp_close_t close;
|
|
|
|
const pwm_fp_set_duty_cycle_t set_duty_cycle;
|
2016-08-29 14:12:51 +00:00
|
|
|
const pwm_fp_get_period_ns_t get_period;
|
|
|
|
const pwm_fp_get_pulse_width_ns_t get_pulse_width;
|
2016-08-09 10:28:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct pwm {
|
|
|
|
const void *arch_dep_device; //!< Architecture depended pwm device (i.e. stm32f10x_pwm_t).
|
2016-08-29 14:12:51 +00:00
|
|
|
const struct pwm_fp *fp; //!< Function pointer for the pwm driver access.
|
2016-08-09 10:28:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
int pwm_open(const struct pwm *device);
|
|
|
|
int pwm_close(const struct pwm *device);
|
|
|
|
int pwm_set_duty_cycle(const struct pwm *device, unsigned int duty_cycle_percent);
|
2016-08-29 14:12:51 +00:00
|
|
|
int pwm_get_period_ns(const struct pwm *device);
|
|
|
|
int pwm_get_pulse_width_ns(const struct pwm *device);
|
2016-08-09 10:28:01 +00:00
|
|
|
|
|
|
|
#endif /* SOURCE_FIRMWARE_KERNEL_DRIVER_INCLUDE_PWM_H_ */
|