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 59f9d383a552e641503e93be3e283a9ef0cdc7d7..3fc3cab6a9a7677a8c8e9f7c09503f9a23d80770 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 f5bb401013310ed27659fc94ba47a3237cb0a5c1..1000993f384528b92af4c49d9fb3e28727302ac7 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 4d1e396d62a1afb4b25660be273d81cd20ad835b..1467c8f6efa06cb4099e4a23e452aa4abc00a17a 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 57ad78d8f6a8a22cd19dfce524ecf36469d9206d..abc367982738da87851ae1dd222fad3ad8e67cbe 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 ecb9b4aed2d69f3936f34a52663e176e35ade6dd..354ad80ca69702936d5edfcbe24178058ad1126a 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;