Private
Public Access
2
0

pwm: added existing exposition logic

* Understands when pwm pin is already exported.
* Will not unexport if didnt export. Can be forced.

Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
Thomas Ingleby
2014-05-20 13:38:15 +01:00
committed by Brendan Le Foll
parent fa7180cb91
commit 5fa6f50edc
3 changed files with 66 additions and 17 deletions

View File

@@ -150,8 +150,24 @@ maa_result_t maa_pwm_enable(maa_pwm_context pwm, int enable);
*/
maa_result_t maa_pwm_unexport(maa_pwm_context pwm);
/** Unexport the PWM context (maa_pwm_close() will call this function)
* Forces operation regardless of ownership.
*
* @param dev The PWM context/
*
* @return maa result type.
*/
maa_result_t maa_pwm_unexport_force(maa_pwm_context pwm);
/** Change ownership of context
*
* @param pwm the context
* @param owner ownership , 1 to own
*/
maa_result_t maa_pwm_owner(maa_pwm_context pwm, maa_boolean_t owner);
/** Close and unexport the PWM pin.
*
*
* @param pwm The PWM context to use.
*
* @return maa_result_t the maa result.

View File

@@ -36,11 +36,13 @@ namespace maa {
class Pwm {
public:
Pwm(int pin, int chipid=-1) {
Pwm(int pin, int chipid=-1, bool owner = true) {
if (chipid == -1)
m_pwm = maa_pwm_init(pin);
else
m_pwm = maa_pwm_init_raw(pin, chipid);
if (!owner)
maa_pwm_owner(m_pwm, 0);
}
~Pwm() {
maa_pwm_close(m_pwm);