From: jino.cho Date: Thu, 18 May 2017 06:47:53 +0000 (+0900) Subject: Add pwm set_polarity & get_polarity functions X-Git-Tag: submit/tizen/20170602.034029~16 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dedd27d82ae980ad39cbce270ac40d7ada4979a3;p=platform%2Fcore%2Fapi%2Fperipheral-io.git Add pwm set_polarity & get_polarity functions Change-Id: Ia68fab71850f2ef0b68e6c3f22310dbb13484e8f Signed-off-by: jino.cho --- diff --git a/include/peripheral_gdbus_pwm.h b/include/peripheral_gdbus_pwm.h index 59f9d38..3fc3cab 100644 --- a/include/peripheral_gdbus_pwm.h +++ b/include/peripheral_gdbus_pwm.h @@ -26,6 +26,8 @@ int peripheral_gdbus_pwm_set_period(peripheral_pwm_h pwm, int period); int peripheral_gdbus_pwm_get_period(peripheral_pwm_h pwm, int *period); int peripheral_gdbus_pwm_set_duty_cycle(peripheral_pwm_h pwm, int duty_cycle); int peripheral_gdbus_pwm_get_duty_cycle(peripheral_pwm_h pwm, int *duty_cycle); +int peripheral_gdbus_pwm_set_polarity(peripheral_pwm_h pwm, peripheral_pwm_polarity_e polarity); +int peripheral_gdbus_pwm_get_polarity(peripheral_pwm_h pwm, peripheral_pwm_polarity_e *polarity); int peripheral_gdbus_pwm_set_enable(peripheral_pwm_h pwm, bool enable); int peripheral_gdbus_pwm_get_enable(peripheral_pwm_h pwm, bool *enable); diff --git a/include/peripheral_io.h b/include/peripheral_io.h index f5bb401..1000993 100644 --- a/include/peripheral_io.h +++ b/include/peripheral_io.h @@ -375,6 +375,14 @@ int peripheral_i2c_write(peripheral_i2c_h i2c, uint8_t *data, int length); */ typedef struct _peripheral_pwm_s *peripheral_pwm_h; +/** + * @brief Enumeration for Polarity. + */ +typedef enum { + PERIPHERAL_PWM_POLARITY_NORMAL = 0, + PERIPHERAL_PWM_POLARITY_INVERSED, +} peripheral_pwm_polarity_e; + int peripheral_pwm_open(int device, int channel, peripheral_pwm_h *pwm); int peripheral_pwm_close(peripheral_pwm_h pwm); @@ -388,6 +396,10 @@ int peripheral_pwm_set_duty_cycle(peripheral_pwm_h pwm, int duty_cycle); int peripheral_pwm_get_duty_cycle(peripheral_pwm_h pwm, int *duty_cycle); +int peripheral_pwm_set_polarity(peripheral_pwm_h pwm, peripheral_pwm_polarity_e polarity); + +int peripheral_pwm_get_polarity(peripheral_pwm_h pwm, peripheral_pwm_polarity_e *polarity); + int peripheral_pwm_set_enable(peripheral_pwm_h pwm, bool enable); int peripheral_pwm_get_enable(peripheral_pwm_h pwm, bool *enable); diff --git a/src/peripheral_gdbus_pwm.c b/src/peripheral_gdbus_pwm.c index 4d1e396..1467c8f 100644 --- a/src/peripheral_gdbus_pwm.c +++ b/src/peripheral_gdbus_pwm.c @@ -181,6 +181,50 @@ int peripheral_gdbus_pwm_get_duty_cycle(peripheral_pwm_h pwm, int *duty_cycle) return ret; } +int peripheral_gdbus_pwm_set_polarity(peripheral_pwm_h pwm, peripheral_pwm_polarity_e polarity) +{ + GError *error = NULL; + peripheral_error_e ret = PERIPHERAL_ERROR_NONE; + + if (pwm_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN; + + if (peripheral_io_gdbus_pwm_call_set_polarity_sync( + pwm_proxy, + pwm->handle, + polarity, + &ret, + NULL, + &error) == FALSE) { + _E("%s", error->message); + g_error_free(error); + return PERIPHERAL_ERROR_UNKNOWN; + } + + return ret; +} + +int peripheral_gdbus_pwm_get_polarity(peripheral_pwm_h pwm, peripheral_pwm_polarity_e *polarity) +{ + GError *error = NULL; + peripheral_error_e ret = PERIPHERAL_ERROR_NONE; + + if (pwm_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN; + + if (peripheral_io_gdbus_pwm_call_get_polarity_sync( + pwm_proxy, + pwm->handle, + (gint*)polarity, + &ret, + NULL, + &error) == FALSE) { + _E("%s", error->message); + g_error_free(error); + return PERIPHERAL_ERROR_UNKNOWN; + } + + return ret; +} + int peripheral_gdbus_pwm_set_enable(peripheral_pwm_h pwm, bool enable) { GError *error = NULL; diff --git a/src/peripheral_io.xml b/src/peripheral_io.xml index 57ad78d..abc3679 100644 --- a/src/peripheral_io.xml +++ b/src/peripheral_io.xml @@ -113,6 +113,16 @@ + + + + + + + + + + diff --git a/src/peripheral_pwm.c b/src/peripheral_pwm.c index ecb9b4a..354ad80 100644 --- a/src/peripheral_pwm.c +++ b/src/peripheral_pwm.c @@ -99,6 +99,20 @@ int peripheral_pwm_get_duty_cycle(peripheral_pwm_h pwm, int *duty_cycle) return peripheral_gdbus_pwm_get_duty_cycle(pwm, duty_cycle); } +int peripheral_pwm_set_polarity(peripheral_pwm_h pwm, peripheral_pwm_polarity_e polarity) +{ + if (pwm == NULL) return PERIPHERAL_ERROR_INVALID_PARAMETER; + + return peripheral_gdbus_pwm_set_polarity(pwm, polarity); +} + +int peripheral_pwm_get_polarity(peripheral_pwm_h pwm, peripheral_pwm_polarity_e *polarity) +{ + if (pwm == NULL) return PERIPHERAL_ERROR_INVALID_PARAMETER; + + return peripheral_gdbus_pwm_get_polarity(pwm, polarity); +} + int peripheral_pwm_set_enable(peripheral_pwm_h pwm, bool enable) { if (pwm == NULL) return PERIPHERAL_ERROR_INVALID_PARAMETER;