Private
Public Access
2
0

pwm.c: cache period

There is an issue that  mraa_pwm_write would fail, because mraa_pwm_read
would fail and return 0.  When the read fails, journalctl shows an
error:
Dec 28 18:01:38 Edison libmraa[365]: pwm: Error in reading period

So now trying version, where the pwm object caches the period, that is
updated whenever you do a read or write of the period.  Side benefit is
that the write should be sped up.

Signed-off-by: Kurt Eckhardt <kurte@rockisland.com>
Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
This commit is contained in:
Kurt Eckhardt
2014-12-29 07:18:16 -08:00
committed by Thomas Ingleby
parent 3eb0a8dbf7
commit 41956b07d6
2 changed files with 19 additions and 6 deletions

View File

@@ -71,6 +71,7 @@ struct _pwm {
int pin; /**< the pin number, as known to the os. */
int chipid; /**< the chip id, which the pwm resides */
int duty_fp; /**< File pointer to duty file */
int period; /**< Cache the period to speed up setting duty */
mraa_boolean_t owner; /**< Owner of pwm context*/
/*@}*/
};