From 6b081a0e2716e7168170725770067202d94b1a2d Mon Sep 17 00:00:00 2001 From: "jino.cho" Date: Tue, 16 May 2017 19:29:20 +0900 Subject: [PATCH] Rearrange the order of pwm API functions Change-Id: I2adeabd3eb2b085fc2e672e9f4c66436b9acbe30 Signed-off-by: jino.cho --- include/peripheral_gdbus_pwm.h | 6 ++--- include/peripheral_io.h | 8 +++--- src/peripheral_gdbus_pwm.c | 25 +++++++++--------- src/peripheral_pwm.c | 46 +++++++++++++++++----------------- 4 files changed, 43 insertions(+), 42 deletions(-) diff --git a/include/peripheral_gdbus_pwm.h b/include/peripheral_gdbus_pwm.h index 9a302ef..2f0be40 100644 --- a/include/peripheral_gdbus_pwm.h +++ b/include/peripheral_gdbus_pwm.h @@ -22,10 +22,10 @@ void pwm_proxy_deinit(void); int peripheral_gdbus_pwm_open(peripheral_pwm_h dev, int device, int channel); int peripheral_gdbus_pwm_close(peripheral_pwm_h dev); -int peripheral_gdbus_pwm_get_duty_cycle(peripheral_pwm_h dev, int *duty_cycle); -int peripheral_gdbus_pwm_set_duty_cycle(peripheral_pwm_h dev, int duty_cycle); -int peripheral_gdbus_pwm_get_period(peripheral_pwm_h dev, int *period); int peripheral_gdbus_pwm_set_period(peripheral_pwm_h dev, int period); +int peripheral_gdbus_pwm_get_period(peripheral_pwm_h dev, int *period); +int peripheral_gdbus_pwm_set_duty_cycle(peripheral_pwm_h dev, int duty_cycle); +int peripheral_gdbus_pwm_get_duty_cycle(peripheral_pwm_h dev, int *duty_cycle); int peripheral_gdbus_pwm_set_enable(peripheral_pwm_h dev, peripheral_pwm_state_e enable); #endif /* __PERIPHERAL_GDBUS_PWM_H__ */ diff --git a/include/peripheral_io.h b/include/peripheral_io.h index 95bc38a..e9ee0ea 100644 --- a/include/peripheral_io.h +++ b/include/peripheral_io.h @@ -392,18 +392,18 @@ int peripheral_pwm_open(int device, int channel, peripheral_pwm_h *pwm); int peripheral_pwm_close(peripheral_pwm_h pwm); -int peripheral_pwm_set_duty_cycle(peripheral_pwm_h pwm, int duty_cycle); int peripheral_pwm_set_period(peripheral_pwm_h pwm, int period); -int peripheral_pwm_set_enabled(peripheral_pwm_h pwm, peripheral_pwm_state_e enable); +int peripheral_pwm_get_period(peripheral_pwm_h pwm, int *period); -int peripheral_pwm_is_enabled(peripheral_pwm_h pwm); +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_get_period(peripheral_pwm_h pwm, int *period); +int peripheral_pwm_set_enabled(peripheral_pwm_h pwm, peripheral_pwm_state_e enable); +int peripheral_pwm_is_enabled(peripheral_pwm_h pwm); /** * @} diff --git a/src/peripheral_gdbus_pwm.c b/src/peripheral_gdbus_pwm.c index 66883a2..86962a6 100644 --- a/src/peripheral_gdbus_pwm.c +++ b/src/peripheral_gdbus_pwm.c @@ -95,7 +95,7 @@ int peripheral_gdbus_pwm_close(peripheral_pwm_h dev) return ret; } -int peripheral_gdbus_pwm_get_duty_cycle(peripheral_pwm_h dev, int *duty_cycle) +int peripheral_gdbus_pwm_set_period(peripheral_pwm_h dev, int period) { GError *error = NULL; gint32 ret = PERIPHERAL_ERROR_NONE; @@ -103,11 +103,11 @@ int peripheral_gdbus_pwm_get_duty_cycle(peripheral_pwm_h dev, int *duty_cycle) if (pwm_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN; /* TODO: Need to reorganize arguments */ - if (peripheral_io_gdbus_pwm_call_get_duty_cycle_sync( + if (peripheral_io_gdbus_pwm_call_set_period_sync( pwm_proxy, dev->device, dev->channel, - duty_cycle, + period, &ret, NULL, &error) == FALSE) { @@ -118,7 +118,8 @@ int peripheral_gdbus_pwm_get_duty_cycle(peripheral_pwm_h dev, int *duty_cycle) return ret; } -int peripheral_gdbus_pwm_set_duty_cycle(peripheral_pwm_h dev, int duty_cycle) + +int peripheral_gdbus_pwm_get_period(peripheral_pwm_h dev, int *period) { GError *error = NULL; gint32 ret = PERIPHERAL_ERROR_NONE; @@ -126,11 +127,11 @@ int peripheral_gdbus_pwm_set_duty_cycle(peripheral_pwm_h dev, int duty_cycle) if (pwm_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN; /* TODO: Need to reorganize arguments */ - if (peripheral_io_gdbus_pwm_call_set_duty_cycle_sync( + if (peripheral_io_gdbus_pwm_call_get_period_sync( pwm_proxy, dev->device, dev->channel, - duty_cycle, + period, &ret, NULL, &error) == FALSE) { @@ -142,7 +143,7 @@ int peripheral_gdbus_pwm_set_duty_cycle(peripheral_pwm_h dev, int duty_cycle) return ret; } -int peripheral_gdbus_pwm_get_period(peripheral_pwm_h dev, int *period) +int peripheral_gdbus_pwm_set_duty_cycle(peripheral_pwm_h dev, int duty_cycle) { GError *error = NULL; gint32 ret = PERIPHERAL_ERROR_NONE; @@ -150,11 +151,11 @@ int peripheral_gdbus_pwm_get_period(peripheral_pwm_h dev, int *period) if (pwm_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN; /* TODO: Need to reorganize arguments */ - if (peripheral_io_gdbus_pwm_call_get_period_sync( + if (peripheral_io_gdbus_pwm_call_set_duty_cycle_sync( pwm_proxy, dev->device, dev->channel, - period, + duty_cycle, &ret, NULL, &error) == FALSE) { @@ -166,7 +167,7 @@ int peripheral_gdbus_pwm_get_period(peripheral_pwm_h dev, int *period) return ret; } -int peripheral_gdbus_pwm_set_period(peripheral_pwm_h dev, int period) +int peripheral_gdbus_pwm_get_duty_cycle(peripheral_pwm_h dev, int *duty_cycle) { GError *error = NULL; gint32 ret = PERIPHERAL_ERROR_NONE; @@ -174,11 +175,11 @@ int peripheral_gdbus_pwm_set_period(peripheral_pwm_h dev, int period) if (pwm_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN; /* TODO: Need to reorganize arguments */ - if (peripheral_io_gdbus_pwm_call_set_period_sync( + if (peripheral_io_gdbus_pwm_call_get_duty_cycle_sync( pwm_proxy, dev->device, dev->channel, - period, + duty_cycle, &ret, NULL, &error) == FALSE) { diff --git a/src/peripheral_pwm.c b/src/peripheral_pwm.c index 9c291b0..a7c4206 100644 --- a/src/peripheral_pwm.c +++ b/src/peripheral_pwm.c @@ -74,49 +74,40 @@ int peripheral_pwm_close(peripheral_pwm_h pwm) return ret; } - -int peripheral_pwm_set_duty_cycle(peripheral_pwm_h pwm, int duty_cycle) +int peripheral_pwm_set_period(peripheral_pwm_h pwm, int period) { int ret = PERIPHERAL_ERROR_NONE; - ret = peripheral_gdbus_pwm_set_duty_cycle(pwm, duty_cycle); + ret = peripheral_gdbus_pwm_set_period(pwm, period); if (ret != PERIPHERAL_ERROR_NONE) - pwm->duty_cycle = duty_cycle; + pwm->period = period; return ret; } -int peripheral_pwm_set_period(peripheral_pwm_h pwm, int period) +int peripheral_pwm_get_period(peripheral_pwm_h pwm, int *period) { int ret = PERIPHERAL_ERROR_NONE; - ret = peripheral_gdbus_pwm_set_period(pwm, period); + ret = peripheral_gdbus_pwm_get_period(pwm, period); if (ret != PERIPHERAL_ERROR_NONE) - pwm->period = period; + pwm->period = *period; return ret; } -int peripheral_pwm_set_enabled(peripheral_pwm_h pwm, peripheral_pwm_state_e enable) +int peripheral_pwm_set_duty_cycle(peripheral_pwm_h pwm, int duty_cycle) { int ret = PERIPHERAL_ERROR_NONE; - ret = peripheral_gdbus_pwm_set_enable(pwm, enable); + ret = peripheral_gdbus_pwm_set_duty_cycle(pwm, duty_cycle); if (ret != PERIPHERAL_ERROR_NONE) - pwm->enabled = enable; - - return PERIPHERAL_ERROR_NONE; -} + pwm->duty_cycle = duty_cycle; -int peripheral_pwm_is_enabled(peripheral_pwm_h pwm) -{ - if (pwm->enabled == PWM_ENABLE) - return PWM_ENABLE; - else - return PWM_DISABLE; + return ret; } int peripheral_pwm_get_duty_cycle(peripheral_pwm_h pwm, int *duty_cycle) @@ -131,14 +122,23 @@ int peripheral_pwm_get_duty_cycle(peripheral_pwm_h pwm, int *duty_cycle) return ret; } -int peripheral_pwm_get_period(peripheral_pwm_h pwm, int *period) +int peripheral_pwm_set_enabled(peripheral_pwm_h pwm, peripheral_pwm_state_e enable) { int ret = PERIPHERAL_ERROR_NONE; - ret = peripheral_gdbus_pwm_get_period(pwm, period); + ret = peripheral_gdbus_pwm_set_enable(pwm, enable); if (ret != PERIPHERAL_ERROR_NONE) - pwm->period = *period; + pwm->enabled = enable; - return ret; + return PERIPHERAL_ERROR_NONE; +} + +int peripheral_pwm_is_enabled(peripheral_pwm_h pwm) +{ + if (pwm->enabled == PWM_ENABLE) + return PWM_ENABLE; + else + return PWM_DISABLE; } + -- 2.34.1