pwm: add period write replace hook
authorThomas Ingleby <thomas.c.ingleby@intel.com>
Thu, 24 Jul 2014 13:20:01 +0000 (14:20 +0100)
committerThomas Ingleby <thomas.c.ingleby@intel.com>
Thu, 24 Jul 2014 13:20:01 +0000 (14:20 +0100)
Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
include/mraa_adv_func.h
src/pwm/pwm.c

index ab265af..98f21ab 100644 (file)
@@ -49,4 +49,6 @@ typedef struct {
 
     mraa_result_t (*i2c_init_pre) (unsigned int bus);
     mraa_result_t (*i2c_init_post) (mraa_i2c_context dev);
+
+    mraa_result_t (*pwm_period_replace) (mraa_pwm_context dev, int period);
 } mraa_adv_func_t;
index b590b8b..a0ffb4b 100644 (file)
@@ -60,6 +60,9 @@ mraa_pwm_setup_duty_fp(mraa_pwm_context dev)
 static mraa_result_t
 mraa_pwm_write_period(mraa_pwm_context dev, int period)
 {
+    if (advance_func->pwm_period_replace != NULL)
+        return advance_func->pwm_period_replace(dev,period);
+
     char bu[MAX_SIZE];
     snprintf(bu,MAX_SIZE ,"/sys/class/pwm/pwmchip%d/pwm%d/period", dev->chipid, dev->pin);