Add pwm set_polarity & get_polarity functions 98/129898/1
authorjino.cho <jino.cho@samsung.com>
Thu, 18 May 2017 06:47:53 +0000 (15:47 +0900)
committerjino.cho <jino.cho@samsung.com>
Thu, 18 May 2017 09:35:34 +0000 (18:35 +0900)
Change-Id: Ia68fab71850f2ef0b68e6c3f22310dbb13484e8f
Signed-off-by: jino.cho <jino.cho@samsung.com>
include/peripheral_gdbus_pwm.h
include/peripheral_io.h
src/peripheral_gdbus_pwm.c
src/peripheral_io.xml
src/peripheral_pwm.c

index 59f9d38..3fc3cab 100644 (file)
@@ -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);
 
index f5bb401..1000993 100644 (file)
@@ -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);
index 4d1e396..1467c8f 100644 (file)
@@ -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;
index 57ad78d..abc3679 100644 (file)
                        <arg type="i" name="duty_cycle" direction="out"/>
                        <arg type="i" name="result" direction="out"/>
                </method>
+               <method name="SetPolarity">
+                       <arg type="u" name="handle" direction="in"/>
+                       <arg type="i" name="polarity" direction="in"/>
+                       <arg type="i" name="result" direction="out"/>
+               </method>
+               <method name="GetPolarity">
+                       <arg type="u" name="handle" direction="in"/>
+                       <arg type="i" name="polarity" direction="out"/>
+                       <arg type="i" name="result" direction="out"/>
+               </method>
                <method name="SetEnable">
                        <arg type="u" name="handle" direction="in"/>
                        <arg type="b" name="enable" direction="in"/>
index ecb9b4a..354ad80 100644 (file)
@@ -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;