Split peripheral_dbus.c into separate files per low-level interface.
Change-Id: Ifdc6bba7d3d4628693e041882ee88b39c763629f
Signed-off-by: Hyeongsik Min <hyeongsik.min@samsung.com>
SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=%{_libdir}")
-SET(SOURCES src/peripheral_adc.c
- src/peripheral_gpio.c
+SET(SOURCES src/peripheral_gpio.c
+ src/peripheral_i2c.c
src/peripheral_pwm.c
+ src/peripheral_adc.c
src/peripheral_uart.c
- src/peripheral_dbus.c
+ src/peripheral_gdbus_gpio.c
+ src/peripheral_gdbus_i2c.c
+ src/peripheral_gdbus_pwm.c
src/peripheral_io_gdbus.c
- src/peripheral_i2c.c
src/peripheral_spi.c)
ADD_LIBRARY(${fw_name} SHARED ${SOURCES})
if (expr) { \
_E("(%s)", #expr); \
return; \
- }\
- } while(0)
+ } \
+ } while (0)
#define RETV_IF(expr, val) \
do {\
if (expr) { \
_E("(%s)", #expr); \
return (val); \
} \
- } while(0)
+ } while (0)
#define RETM_IF(expr, fmt, arg...) \
do {\
if (expr) { \
_E(fmt, ##arg); \
return; \
- }\
- } while(0)
+ } \
+ } while (0)
#define RETVM_IF(expr, val, fmt, arg...) \
do {\
if (expr) { \
_E(fmt, ##arg); \
return (val); \
} \
- } while(0)
+ } while (0)
#endif /* __PERIPHERAL_COMMON_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2016-2017 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef __PERIPHERAL_DBUS_H_
-#define __PERIPHERAL_DBUS_H_
-
-#include <gio/gio.h>
-
-#define PERIPHERAL_DBUS_INTERFACE "org.tizen.peripheral_io"
-#define PERIPHERAL_DBUS_PATH "/Org/Tizen/Peripheral_io"
-#define PERIPHERAL_DBUS_GPIO_PATH "/Org/Tizen/Peripheral_io/Gpio"
-#define PERIPHERAL_DBUS_I2C_PATH "/Org/Tizen/Peripheral_io/I2c"
-#define PERIPHERAL_DBUS_PWM_PATH "/Org/Tizen/Peripheral_io/Pwm"
-#define PERIPHERAL_DBUS_NAME "org.tizen.peripheral_io"
-
-#define PERIPHERAL_METHOD_GPIO "gpio"
-#define PERIPHERAL_METHOD_I2C "i2c"
-#define PERIPHERAL_METHOD_PWM "pwm"
-#define PERIPHERAL_METHOD_SPI "spi"
-#define PERIPHERAL_METHOD_UART "uart"
-
-void gpio_proxy_init(void);
-void i2c_proxy_init(void);
-void pwm_proxy_init(void);
-
-void gpio_proxy_deinit();
-void i2c_proxy_deinit();
-void pwm_proxy_deinit();
-
-int peripheral_dbus_gpio_open(peripheral_gpio_h gpio);
-int peripheral_dbus_gpio_close(peripheral_gpio_h gpio);
-int peripheral_dbus_gpio_get_direction(peripheral_gpio_h gpio, peripheral_gpio_direction_e *direction);
-int peripheral_dbus_gpio_set_direction(peripheral_gpio_h gpio, peripheral_gpio_direction_e direction);
-int peripheral_dbus_gpio_read(peripheral_gpio_h gpio, int *value);
-int peripheral_dbus_gpio_write(peripheral_gpio_h gpio, int value);
-int peripheral_dbus_gpio_get_edge_mode(peripheral_gpio_h gpio, peripheral_gpio_edge_e *edge);
-int peripheral_dbus_gpio_set_edge_mode(peripheral_gpio_h gpio, peripheral_gpio_edge_e edge);
-int peripheral_dbus_gpio_register_cb(peripheral_gpio_h gpio, gpio_isr_cb callback, void *user_data);
-int peripheral_dbus_gpio_unregister_cb(peripheral_gpio_h gpio);
-
-int peripheral_dbus_i2c_open(peripheral_i2c_h i2c, int bus, int address);
-int peripheral_dbus_i2c_close(peripheral_i2c_h i2c);
-int peripheral_dbus_i2c_read(peripheral_i2c_h i2c, uint8_t *data, int length);
-int peripheral_dbus_i2c_write(peripheral_i2c_h i2c, uint8_t *data, int length);
-
-int peripheral_dbus_pwm_open(peripheral_pwm_context_h dev, int device, int channel);
-int peripheral_dbus_pwm_close(peripheral_pwm_context_h dev);
-int peripheral_dbus_pwm_get_duty_cycle(peripheral_pwm_context_h dev, int *duty_cycle);
-int peripheral_dbus_pwm_set_duty_cycle(peripheral_pwm_context_h dev, int duty_cycle);
-int peripheral_dbus_pwm_get_period(peripheral_pwm_context_h dev, int *period);
-int peripheral_dbus_pwm_set_period(peripheral_pwm_context_h dev, int period);
-int peripheral_dbus_pwm_set_enable(peripheral_pwm_context_h dev, peripheral_pwm_state_e enable);
-
-#endif /* __PERIPHERAL_DBUS_H_ */
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef __PERIPHERAL_GDBUS_H__
+#define __PERIPHERAL_GDBUS_H__
+
+#include <gio/gio.h>
+
+#define PERIPHERAL_GDBUS_INTERFACE "org.tizen.peripheral_io"
+#define PERIPHERAL_GDBUS_GPIO_PATH "/Org/Tizen/Peripheral_io/Gpio"
+#define PERIPHERAL_GDBUS_I2C_PATH "/Org/Tizen/Peripheral_io/I2c"
+#define PERIPHERAL_GDBUS_PWM_PATH "/Org/Tizen/Peripheral_io/Pwm"
+#define PERIPHERAL_GDBUS_NAME "org.tizen.peripheral_io"
+
+#endif /* __PERIPHERAL_GDBUS_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2016-2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __PERIPHERAL_GDBUS_GPIO_H__
+#define __PERIPHERAL_GDBUS_GPIO_H__
+
+void gpio_proxy_init(void);
+void gpio_proxy_deinit(void);
+
+int peripheral_gdbus_gpio_open(peripheral_gpio_h gpio);
+int peripheral_gdbus_gpio_close(peripheral_gpio_h gpio);
+int peripheral_gdbus_gpio_get_direction(peripheral_gpio_h gpio, peripheral_gpio_direction_e *direction);
+int peripheral_gdbus_gpio_set_direction(peripheral_gpio_h gpio, peripheral_gpio_direction_e direction);
+int peripheral_gdbus_gpio_read(peripheral_gpio_h gpio, int *value);
+int peripheral_gdbus_gpio_write(peripheral_gpio_h gpio, int value);
+int peripheral_gdbus_gpio_get_edge_mode(peripheral_gpio_h gpio, peripheral_gpio_edge_e *edge);
+int peripheral_gdbus_gpio_set_edge_mode(peripheral_gpio_h gpio, peripheral_gpio_edge_e edge);
+int peripheral_gdbus_gpio_register_cb(peripheral_gpio_h gpio, gpio_isr_cb callback, void *user_data);
+int peripheral_gdbus_gpio_unregister_cb(peripheral_gpio_h gpio);
+
+#endif /* __PERIPHERAL_GDBUS_GPIO_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2016-2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __PERIPHERAL_GDBUS_I2C_H__
+#define __PERIPHERAL_GDBUS_I2C_H__
+
+void i2c_proxy_init(void);
+void i2c_proxy_deinit(void);
+
+int peripheral_gdbus_i2c_open(peripheral_i2c_h i2c, int bus, int address);
+int peripheral_gdbus_i2c_close(peripheral_i2c_h i2c);
+int peripheral_gdbus_i2c_read(peripheral_i2c_h i2c, uint8_t *data, int length);
+int peripheral_gdbus_i2c_write(peripheral_i2c_h i2c, uint8_t *data, int length);
+
+#endif /* __PERIPHERAL_GDBUS_I2C_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2016-2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __PERIPHERAL_GDBUS_PWM_H__
+#define __PERIPHERAL_GDBUS_PWM_H__
+
+void pwm_proxy_init(void);
+void pwm_proxy_deinit(void);
+
+int peripheral_gdbus_pwm_open(peripheral_pwm_context_h dev, int device, int channel);
+int peripheral_gdbus_pwm_close(peripheral_pwm_context_h dev);
+int peripheral_gdbus_pwm_get_duty_cycle(peripheral_pwm_context_h dev, int *duty_cycle);
+int peripheral_gdbus_pwm_set_duty_cycle(peripheral_pwm_context_h dev, int duty_cycle);
+int peripheral_gdbus_pwm_get_period(peripheral_pwm_context_h dev, int *period);
+int peripheral_gdbus_pwm_set_period(peripheral_pwm_context_h dev, int period);
+int peripheral_gdbus_pwm_set_enable(peripheral_pwm_context_h dev, peripheral_pwm_state_e enable);
+
+#endif /* __PERIPHERAL_GDBUS_PWM_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2016-2017 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <gio/gio.h>
-
-#include "peripheral_io.h"
-#include "peripheral_dbus.h"
-#include "peripheral_common.h"
-#include "peripheral_internal.h"
-#include "peripheral_io_gdbus.h"
-
-extern int peripheral_gpio_isr_callback(int pin);
-void handle_gpio_changed(PeripheralIoGdbusGpio *gpio, gint pin, gint state, gpointer user_data);
-
-PeripheralIoGdbusGpio *gpio_proxy = NULL;
-PeripheralIoGdbusI2c *i2c_proxy = NULL;
-PeripheralIoGdbusPwm *pwm_proxy = NULL;
-
-void gpio_proxy_init(void)
-{
- GError *error = NULL;
-
- if (gpio_proxy != NULL)
- return;
-
- gpio_proxy = peripheral_io_gdbus_gpio_proxy_new_for_bus_sync(
- G_BUS_TYPE_SYSTEM,
- G_DBUS_PROXY_FLAGS_NONE,
- PERIPHERAL_DBUS_NAME,
- PERIPHERAL_DBUS_GPIO_PATH,
- NULL,
- &error);
- if (gpio_proxy == NULL) {
- _E("Can not create gpio proxy : %s", error->message);
- g_error_free(error);
- return;
- }
-
- g_signal_connect(gpio_proxy,
- "gpio-changed",
- G_CALLBACK(handle_gpio_changed),
- NULL);
-}
-
-void i2c_proxy_init(void)
-{
- GError *error = NULL;
-
- if (i2c_proxy != NULL)
- return;
-
- i2c_proxy = peripheral_io_gdbus_i2c_proxy_new_for_bus_sync(
- G_BUS_TYPE_SYSTEM,
- G_DBUS_PROXY_FLAGS_NONE,
- PERIPHERAL_DBUS_NAME,
- PERIPHERAL_DBUS_I2C_PATH,
- NULL,
- &error);
-}
-
-void pwm_proxy_init(void)
-{
- GError *error = NULL;
-
- if (pwm_proxy != NULL)
- return;
-
- pwm_proxy = peripheral_io_gdbus_pwm_proxy_new_for_bus_sync(
- G_BUS_TYPE_SYSTEM,
- G_DBUS_PROXY_FLAGS_NONE,
- PERIPHERAL_DBUS_NAME,
- PERIPHERAL_DBUS_PWM_PATH,
- NULL,
- &error);
-}
-
-void gpio_proxy_deinit()
-{
- if (gpio_proxy) {
- g_object_unref(gpio_proxy);
- gpio_proxy = NULL;
- }
-}
-
-void i2c_proxy_deinit()
-{
- if (i2c_proxy) {
- g_object_unref(i2c_proxy);
- i2c_proxy = NULL;
- }
-}
-
-void pwm_proxy_deinit()
-{
- if (pwm_proxy) {
- g_object_unref(pwm_proxy);
- pwm_proxy = NULL;
- }
-}
-
-void handle_gpio_changed(
- PeripheralIoGdbusGpio *gpio,
- gint pin,
- gint state,
- gpointer user_data)
-{
- if (!gpio)
- return;
-
- _D("gpio=%d state=%d", pin, state);
-
- peripheral_gpio_isr_callback(pin);
-}
-
-int peripheral_dbus_gpio_open(peripheral_gpio_h gpio)
-{
- GError *error = NULL;
- gint32 ret = PERIPHERAL_ERROR_NONE;
-
- if (gpio_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
-
- if (peripheral_io_gdbus_gpio_call_open_sync(
- gpio_proxy,
- gpio->pin,
- (gint*)&gpio->edge,
- (gint*)&gpio->direction,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("Error in %s() : %s\n", __func__, error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- return ret;
-}
-
-int peripheral_dbus_gpio_close(peripheral_gpio_h gpio)
-{
- GError *error = NULL;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
-
- if (gpio_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
-
- if (peripheral_io_gdbus_gpio_call_close_sync(
- gpio_proxy,
- gpio->pin,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("Error in %s() : %s\n", __func__, error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- return ret;
-}
-
-int peripheral_dbus_gpio_get_direction(peripheral_gpio_h gpio, peripheral_gpio_direction_e *direction)
-{
- GError *error = NULL;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
-
- if (gpio_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
-
- if (peripheral_io_gdbus_gpio_call_get_direction_sync(
- gpio_proxy,
- gpio->pin,
- (gint*)direction,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("Error in %s() : %s\n", __func__, error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
- gpio->direction = *direction;
-
- return ret;
-}
-
-int peripheral_dbus_gpio_set_direction(peripheral_gpio_h gpio, peripheral_gpio_direction_e direction)
-{
- GError *error = NULL;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
-
- if (gpio_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
-
- if (peripheral_io_gdbus_gpio_call_set_direction_sync(
- gpio_proxy,
- gpio->pin,
- direction,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("Error in %s() : %s\n", __func__, error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
- gpio->direction = direction;
-
- return ret;
-}
-
-int peripheral_dbus_gpio_read(peripheral_gpio_h gpio, int *value)
-{
- GError *error = NULL;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
-
- if (gpio_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
-
- if (peripheral_io_gdbus_gpio_call_read_sync(
- gpio_proxy,
- gpio->pin,
- value,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("Error in %s() : %s\n", __func__, error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- return ret;
-}
-
-int peripheral_dbus_gpio_write(peripheral_gpio_h gpio, int value)
-{
- GError *error = NULL;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
-
- if (gpio_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
-
- if (peripheral_io_gdbus_gpio_call_write_sync(
- gpio_proxy,
- gpio->pin,
- value,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("Error in %s() : %s\n", __func__, error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- return ret;
-}
-
-int peripheral_dbus_gpio_get_edge_mode(peripheral_gpio_h gpio, peripheral_gpio_edge_e *edge)
-{
- GError *error = NULL;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
-
- if (gpio_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
-
- if (peripheral_io_gdbus_gpio_call_get_edge_mode_sync(
- gpio_proxy,
- gpio->pin,
- (int*)edge,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("Error in %s() : %s\n", __func__, error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
- gpio->edge = *edge;
-
- return ret;
-}
-
-int peripheral_dbus_gpio_set_edge_mode(peripheral_gpio_h gpio, peripheral_gpio_edge_e edge)
-{
- GError *error = NULL;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
-
- if (gpio_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
-
- if (peripheral_io_gdbus_gpio_call_set_edge_mode_sync(
- gpio_proxy,
- gpio->pin,
- edge,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("Error in %s() : %s\n", __func__, error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
- gpio->edge = edge;
-
- return ret;
-}
-
-int peripheral_dbus_gpio_register_cb(peripheral_gpio_h gpio, gpio_isr_cb callback, void *user_data)
-{
- GError *error = NULL;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
-
- if (gpio_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
-
- if (peripheral_io_gdbus_gpio_call_register_irq_sync(
- gpio_proxy,
- gpio->pin,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("Error in %s() : %s\n", __func__, error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- return ret;
-}
-
-int peripheral_dbus_gpio_unregister_cb(peripheral_gpio_h gpio)
-{
- GError *error = NULL;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
-
- if (gpio_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
-
- if (peripheral_io_gdbus_gpio_call_unregister_irq_sync(
- gpio_proxy,
- gpio->pin,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("Error in %s() : %s\n", __func__, error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- return ret;
-}
-
-int peripheral_dbus_i2c_open(peripheral_i2c_h i2c, int bus, int address)
-{
- GError *error = NULL;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
-
- if (i2c_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
-
- if (peripheral_io_gdbus_i2c_call_open_sync(
- i2c_proxy,
- bus,
- address,
- &i2c->handle,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("Error in %s() : %s\n", __func__, error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- return ret;
-}
-
-int peripheral_dbus_i2c_close(peripheral_i2c_h i2c)
-{
- GError *error = NULL;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
-
- if (i2c_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
-
- if (peripheral_io_gdbus_i2c_call_close_sync(
- i2c_proxy,
- i2c->handle,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("Error in %s() : %s\n", __func__, error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- return ret;
-}
-
-int peripheral_dbus_i2c_read(peripheral_i2c_h i2c, uint8_t *data, int length)
-{
- GError *error = NULL;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
- GVariant *data_array;
- GVariantIter *iter;
- guint8 str;
- int i = 0;
-
- if (i2c_proxy == NULL || data == NULL) return PERIPHERAL_ERROR_UNKNOWN;
-
- if (peripheral_io_gdbus_i2c_call_read_sync(
- i2c_proxy,
- i2c->handle,
- length,
- &data_array,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("Error in %s() : %s\n", __func__, error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- g_variant_get(data_array, "a(y)", &iter);
- while (g_variant_iter_loop(iter, "(y)", &str)) {
- data[i] = str;
- if (i++ == length) break;
- }
- g_variant_iter_free(iter);
-
- return ret;
-}
-
-int peripheral_dbus_i2c_write(peripheral_i2c_h i2c, uint8_t *data, int length)
-{
- GError *error = NULL;
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
- GVariantBuilder *builder;
- GVariant *g_data;
- int i = 0;
-
- if (i2c_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
-
- builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)"));
-
- for (i = 0; i < length; i++)
- g_variant_builder_add(builder, "(y)", data[i]);
- g_variant_builder_add(builder, "(y)", 0x00);
-
- g_data = g_variant_new("a(y)", builder);
- g_variant_builder_unref(builder);
-
- if (peripheral_io_gdbus_i2c_call_write_sync(
- i2c_proxy,
- i2c->handle,
- length,
- g_data,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("Error in %s() : %s\n", __func__, error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- return ret;
-}
-
-int peripheral_dbus_pwm_open(peripheral_pwm_context_h dev, int device, int channel)
-{
- GError *error = NULL;
- gint32 ret = PERIPHERAL_ERROR_NONE;
-
- if (pwm_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
-
- /* TODO: Need to reorganize arguments */
- if (peripheral_io_gdbus_pwm_call_open_sync(
- pwm_proxy,
- device,
- channel,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("Error in %s() : %s\n", __func__, error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- return ret;
-}
-
-int peripheral_dbus_pwm_close(peripheral_pwm_context_h dev)
-{
- GError *error = NULL;
- gint32 ret = PERIPHERAL_ERROR_NONE;
-
- if (pwm_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
-
- /* TODO: Need to reorganize arguments */
- if (peripheral_io_gdbus_pwm_call_close_sync(
- pwm_proxy,
- dev->device,
- dev->channel,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("Error in %s() : %s\n", __func__, error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- return ret;
-}
-
-int peripheral_dbus_pwm_get_duty_cycle(peripheral_pwm_context_h dev, int *duty_cycle)
-{
- GError *error = NULL;
- gint32 ret = PERIPHERAL_ERROR_NONE;
-
- if (pwm_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
-
- /* TODO: Need to reorganize arguments */
- if (peripheral_io_gdbus_pwm_call_get_duty_cycle_sync(
- pwm_proxy,
- dev->device,
- dev->channel,
- duty_cycle,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("Error in %s() : %s\n", __func__, error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- return ret;
-}
-int peripheral_dbus_pwm_set_duty_cycle(peripheral_pwm_context_h dev, int duty_cycle)
-{
- GError *error = NULL;
- gint32 ret = PERIPHERAL_ERROR_NONE;
-
- if (pwm_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
-
- /* TODO: Need to reorganize arguments */
- if (peripheral_io_gdbus_pwm_call_set_duty_cycle_sync(
- pwm_proxy,
- dev->device,
- dev->channel,
- duty_cycle,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("Error in %s() : %s\n", __func__, error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- return ret;
-}
-
-int peripheral_dbus_pwm_get_period(peripheral_pwm_context_h dev, int *period)
-{
- GError *error = NULL;
- gint32 ret = PERIPHERAL_ERROR_NONE;
-
- if (pwm_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
-
- /* TODO: Need to reorganize arguments */
- if (peripheral_io_gdbus_pwm_call_get_period_sync(
- pwm_proxy,
- dev->device,
- dev->channel,
- period,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("Error in %s() : %s\n", __func__, error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- return ret;
-}
-
-int peripheral_dbus_pwm_set_period(peripheral_pwm_context_h dev, int period)
-{
- GError *error = NULL;
- gint32 ret = PERIPHERAL_ERROR_NONE;
-
- if (pwm_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
-
- /* TODO: Need to reorganize arguments */
- if (peripheral_io_gdbus_pwm_call_set_period_sync(
- pwm_proxy,
- dev->device,
- dev->channel,
- period,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("Error in %s() : %s\n", __func__, error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- return ret;
-}
-
-int peripheral_dbus_pwm_set_enable(peripheral_pwm_context_h dev, peripheral_pwm_state_e enable)
-{
- GError *error = NULL;
- gint32 ret = PERIPHERAL_ERROR_NONE;
-
- if (pwm_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
-
- /* TODO: Need to reorganize arguments */
- if (peripheral_io_gdbus_pwm_call_set_enable_sync(
- pwm_proxy,
- dev->device,
- dev->channel,
- enable,
- &ret,
- NULL,
- &error) == FALSE) {
- _E("Error in %s() : %s\n", __func__, error->message);
- g_error_free(error);
- return PERIPHERAL_ERROR_UNKNOWN;
- }
-
- return ret;
-}
--- /dev/null
+/*
+ * Copyright (c) 2016-2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "peripheral_io.h"
+#include "peripheral_gdbus.h"
+#include "peripheral_common.h"
+#include "peripheral_internal.h"
+#include "peripheral_io_gdbus.h"
+
+extern int peripheral_gpio_isr_callback(int pin);
+void handle_gpio_changed(PeripheralIoGdbusGpio *gpio, gint pin, gint state, gpointer user_data);
+
+PeripheralIoGdbusGpio *gpio_proxy = NULL;
+
+void gpio_proxy_init(void)
+{
+ GError *error = NULL;
+
+ if (gpio_proxy != NULL)
+ return;
+
+ gpio_proxy = peripheral_io_gdbus_gpio_proxy_new_for_bus_sync(
+ G_BUS_TYPE_SYSTEM,
+ G_DBUS_PROXY_FLAGS_NONE,
+ PERIPHERAL_GDBUS_NAME,
+ PERIPHERAL_GDBUS_GPIO_PATH,
+ NULL,
+ &error);
+ if (gpio_proxy == NULL) {
+ _E("Can not create gpio proxy : %s", error->message);
+ g_error_free(error);
+ return;
+ }
+
+ g_signal_connect(gpio_proxy,
+ "gpio-changed",
+ G_CALLBACK(handle_gpio_changed),
+ NULL);
+}
+
+void gpio_proxy_deinit()
+{
+ if (gpio_proxy) {
+ g_object_unref(gpio_proxy);
+ gpio_proxy = NULL;
+ }
+}
+
+void handle_gpio_changed(
+ PeripheralIoGdbusGpio *gpio,
+ gint pin,
+ gint state,
+ gpointer user_data)
+{
+ if (!gpio)
+ return;
+
+ _D("gpio=%d state=%d", pin, state);
+
+ peripheral_gpio_isr_callback(pin);
+}
+
+int peripheral_gdbus_gpio_open(peripheral_gpio_h gpio)
+{
+ GError *error = NULL;
+ gint32 ret = PERIPHERAL_ERROR_NONE;
+
+ if (gpio_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
+
+ if (peripheral_io_gdbus_gpio_call_open_sync(
+ gpio_proxy,
+ gpio->pin,
+ (gint*)&gpio->edge,
+ (gint*)&gpio->direction,
+ &ret,
+ NULL,
+ &error) == FALSE) {
+ _E("Error in %s() : %s\n", __func__, error->message);
+ g_error_free(error);
+ return PERIPHERAL_ERROR_UNKNOWN;
+ }
+
+ return ret;
+}
+
+int peripheral_gdbus_gpio_close(peripheral_gpio_h gpio)
+{
+ GError *error = NULL;
+ peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
+
+ if (gpio_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
+
+ if (peripheral_io_gdbus_gpio_call_close_sync(
+ gpio_proxy,
+ gpio->pin,
+ &ret,
+ NULL,
+ &error) == FALSE) {
+ _E("Error in %s() : %s\n", __func__, error->message);
+ g_error_free(error);
+ return PERIPHERAL_ERROR_UNKNOWN;
+ }
+
+ return ret;
+}
+
+int peripheral_gdbus_gpio_get_direction(peripheral_gpio_h gpio, peripheral_gpio_direction_e *direction)
+{
+ GError *error = NULL;
+ peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
+
+ if (gpio_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
+
+ if (peripheral_io_gdbus_gpio_call_get_direction_sync(
+ gpio_proxy,
+ gpio->pin,
+ (gint*)direction,
+ &ret,
+ NULL,
+ &error) == FALSE) {
+ _E("Error in %s() : %s\n", __func__, error->message);
+ g_error_free(error);
+ return PERIPHERAL_ERROR_UNKNOWN;
+ }
+ gpio->direction = *direction;
+
+ return ret;
+}
+
+int peripheral_gdbus_gpio_set_direction(peripheral_gpio_h gpio, peripheral_gpio_direction_e direction)
+{
+ GError *error = NULL;
+ peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
+
+ if (gpio_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
+
+ if (peripheral_io_gdbus_gpio_call_set_direction_sync(
+ gpio_proxy,
+ gpio->pin,
+ direction,
+ &ret,
+ NULL,
+ &error) == FALSE) {
+ _E("Error in %s() : %s\n", __func__, error->message);
+ g_error_free(error);
+ return PERIPHERAL_ERROR_UNKNOWN;
+ }
+ gpio->direction = direction;
+
+ return ret;
+}
+
+int peripheral_gdbus_gpio_read(peripheral_gpio_h gpio, int *value)
+{
+ GError *error = NULL;
+ peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
+
+ if (gpio_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
+
+ if (peripheral_io_gdbus_gpio_call_read_sync(
+ gpio_proxy,
+ gpio->pin,
+ value,
+ &ret,
+ NULL,
+ &error) == FALSE) {
+ _E("Error in %s() : %s\n", __func__, error->message);
+ g_error_free(error);
+ return PERIPHERAL_ERROR_UNKNOWN;
+ }
+
+ return ret;
+}
+
+int peripheral_gdbus_gpio_write(peripheral_gpio_h gpio, int value)
+{
+ GError *error = NULL;
+ peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
+
+ if (gpio_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
+
+ if (peripheral_io_gdbus_gpio_call_write_sync(
+ gpio_proxy,
+ gpio->pin,
+ value,
+ &ret,
+ NULL,
+ &error) == FALSE) {
+ _E("Error in %s() : %s\n", __func__, error->message);
+ g_error_free(error);
+ return PERIPHERAL_ERROR_UNKNOWN;
+ }
+
+ return ret;
+}
+
+int peripheral_gdbus_gpio_get_edge_mode(peripheral_gpio_h gpio, peripheral_gpio_edge_e *edge)
+{
+ GError *error = NULL;
+ peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
+
+ if (gpio_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
+
+ if (peripheral_io_gdbus_gpio_call_get_edge_mode_sync(
+ gpio_proxy,
+ gpio->pin,
+ (int*)edge,
+ &ret,
+ NULL,
+ &error) == FALSE) {
+ _E("Error in %s() : %s\n", __func__, error->message);
+ g_error_free(error);
+ return PERIPHERAL_ERROR_UNKNOWN;
+ }
+ gpio->edge = *edge;
+
+ return ret;
+}
+
+int peripheral_gdbus_gpio_set_edge_mode(peripheral_gpio_h gpio, peripheral_gpio_edge_e edge)
+{
+ GError *error = NULL;
+ peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
+
+ if (gpio_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
+
+ if (peripheral_io_gdbus_gpio_call_set_edge_mode_sync(
+ gpio_proxy,
+ gpio->pin,
+ edge,
+ &ret,
+ NULL,
+ &error) == FALSE) {
+ _E("Error in %s() : %s\n", __func__, error->message);
+ g_error_free(error);
+ return PERIPHERAL_ERROR_UNKNOWN;
+ }
+ gpio->edge = edge;
+
+ return ret;
+}
+
+int peripheral_gdbus_gpio_register_cb(peripheral_gpio_h gpio, gpio_isr_cb callback, void *user_data)
+{
+ GError *error = NULL;
+ peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
+
+ if (gpio_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
+
+ if (peripheral_io_gdbus_gpio_call_register_irq_sync(
+ gpio_proxy,
+ gpio->pin,
+ &ret,
+ NULL,
+ &error) == FALSE) {
+ _E("Error in %s() : %s\n", __func__, error->message);
+ g_error_free(error);
+ return PERIPHERAL_ERROR_UNKNOWN;
+ }
+
+ return ret;
+}
+
+int peripheral_gdbus_gpio_unregister_cb(peripheral_gpio_h gpio)
+{
+ GError *error = NULL;
+ peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
+
+ if (gpio_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
+
+ if (peripheral_io_gdbus_gpio_call_unregister_irq_sync(
+ gpio_proxy,
+ gpio->pin,
+ &ret,
+ NULL,
+ &error) == FALSE) {
+ _E("Error in %s() : %s\n", __func__, error->message);
+ g_error_free(error);
+ return PERIPHERAL_ERROR_UNKNOWN;
+ }
+
+ return ret;
+}
--- /dev/null
+/*
+ * Copyright (c) 2016-2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "peripheral_io.h"
+#include "peripheral_gdbus.h"
+#include "peripheral_common.h"
+#include "peripheral_internal.h"
+#include "peripheral_io_gdbus.h"
+
+PeripheralIoGdbusI2c *i2c_proxy = NULL;
+
+void i2c_proxy_init(void)
+{
+ GError *error = NULL;
+
+ if (i2c_proxy != NULL)
+ return;
+
+ i2c_proxy = peripheral_io_gdbus_i2c_proxy_new_for_bus_sync(
+ G_BUS_TYPE_SYSTEM,
+ G_DBUS_PROXY_FLAGS_NONE,
+ PERIPHERAL_GDBUS_NAME,
+ PERIPHERAL_GDBUS_I2C_PATH,
+ NULL,
+ &error);
+}
+
+void i2c_proxy_deinit()
+{
+ if (i2c_proxy) {
+ g_object_unref(i2c_proxy);
+ i2c_proxy = NULL;
+ }
+}
+
+int peripheral_gdbus_i2c_open(peripheral_i2c_h i2c, int bus, int address)
+{
+ GError *error = NULL;
+ peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
+
+ if (i2c_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
+
+ if (peripheral_io_gdbus_i2c_call_open_sync(
+ i2c_proxy,
+ bus,
+ address,
+ &i2c->handle,
+ &ret,
+ NULL,
+ &error) == FALSE) {
+ _E("Error in %s() : %s\n", __func__, error->message);
+ g_error_free(error);
+ return PERIPHERAL_ERROR_UNKNOWN;
+ }
+
+ return ret;
+}
+
+int peripheral_gdbus_i2c_close(peripheral_i2c_h i2c)
+{
+ GError *error = NULL;
+ peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
+
+ if (i2c_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
+
+ if (peripheral_io_gdbus_i2c_call_close_sync(
+ i2c_proxy,
+ i2c->handle,
+ &ret,
+ NULL,
+ &error) == FALSE) {
+ _E("Error in %s() : %s\n", __func__, error->message);
+ g_error_free(error);
+ return PERIPHERAL_ERROR_UNKNOWN;
+ }
+
+ return ret;
+}
+
+int peripheral_gdbus_i2c_read(peripheral_i2c_h i2c, uint8_t *data, int length)
+{
+ GError *error = NULL;
+ peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
+ GVariant *data_array;
+ GVariantIter *iter;
+ guint8 str;
+ int i = 0;
+
+ if (i2c_proxy == NULL || data == NULL) return PERIPHERAL_ERROR_UNKNOWN;
+
+ if (peripheral_io_gdbus_i2c_call_read_sync(
+ i2c_proxy,
+ i2c->handle,
+ length,
+ &data_array,
+ &ret,
+ NULL,
+ &error) == FALSE) {
+ _E("Error in %s() : %s\n", __func__, error->message);
+ g_error_free(error);
+ return PERIPHERAL_ERROR_UNKNOWN;
+ }
+
+ g_variant_get(data_array, "a(y)", &iter);
+ while (g_variant_iter_loop(iter, "(y)", &str)) {
+ data[i] = str;
+ if (i++ == length) break;
+ }
+ g_variant_iter_free(iter);
+
+ return ret;
+}
+
+int peripheral_gdbus_i2c_write(peripheral_i2c_h i2c, uint8_t *data, int length)
+{
+ GError *error = NULL;
+ peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
+ GVariantBuilder *builder;
+ GVariant *g_data;
+ int i = 0;
+
+ if (i2c_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
+
+ builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)"));
+
+ for (i = 0; i < length; i++)
+ g_variant_builder_add(builder, "(y)", data[i]);
+ g_variant_builder_add(builder, "(y)", 0x00);
+
+ g_data = g_variant_new("a(y)", builder);
+ g_variant_builder_unref(builder);
+
+ if (peripheral_io_gdbus_i2c_call_write_sync(
+ i2c_proxy,
+ i2c->handle,
+ length,
+ g_data,
+ &ret,
+ NULL,
+ &error) == FALSE) {
+ _E("Error in %s() : %s\n", __func__, error->message);
+ g_error_free(error);
+ return PERIPHERAL_ERROR_UNKNOWN;
+ }
+
+ return ret;
+}
--- /dev/null
+/*
+ * Copyright (c) 2016-2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "peripheral_io.h"
+#include "peripheral_gdbus.h"
+#include "peripheral_common.h"
+#include "peripheral_internal.h"
+#include "peripheral_io_gdbus.h"
+
+PeripheralIoGdbusPwm *pwm_proxy = NULL;
+
+void pwm_proxy_init(void)
+{
+ GError *error = NULL;
+
+ if (pwm_proxy != NULL)
+ return;
+
+ pwm_proxy = peripheral_io_gdbus_pwm_proxy_new_for_bus_sync(
+ G_BUS_TYPE_SYSTEM,
+ G_DBUS_PROXY_FLAGS_NONE,
+ PERIPHERAL_GDBUS_NAME,
+ PERIPHERAL_GDBUS_PWM_PATH,
+ NULL,
+ &error);
+}
+
+void pwm_proxy_deinit()
+{
+ if (pwm_proxy) {
+ g_object_unref(pwm_proxy);
+ pwm_proxy = NULL;
+ }
+}
+
+int peripheral_gdbus_pwm_open(peripheral_pwm_context_h dev, int device, int channel)
+{
+ GError *error = NULL;
+ gint32 ret = PERIPHERAL_ERROR_NONE;
+
+ if (pwm_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
+
+ /* TODO: Need to reorganize arguments */
+ if (peripheral_io_gdbus_pwm_call_open_sync(
+ pwm_proxy,
+ device,
+ channel,
+ &ret,
+ NULL,
+ &error) == FALSE) {
+ _E("Error in %s() : %s\n", __func__, error->message);
+ g_error_free(error);
+ return PERIPHERAL_ERROR_UNKNOWN;
+ }
+
+ return ret;
+}
+
+int peripheral_gdbus_pwm_close(peripheral_pwm_context_h dev)
+{
+ GError *error = NULL;
+ gint32 ret = PERIPHERAL_ERROR_NONE;
+
+ if (pwm_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
+
+ /* TODO: Need to reorganize arguments */
+ if (peripheral_io_gdbus_pwm_call_close_sync(
+ pwm_proxy,
+ dev->device,
+ dev->channel,
+ &ret,
+ NULL,
+ &error) == FALSE) {
+ _E("Error in %s() : %s\n", __func__, error->message);
+ g_error_free(error);
+ return PERIPHERAL_ERROR_UNKNOWN;
+ }
+
+ return ret;
+}
+
+int peripheral_gdbus_pwm_get_duty_cycle(peripheral_pwm_context_h dev, int *duty_cycle)
+{
+ GError *error = NULL;
+ gint32 ret = PERIPHERAL_ERROR_NONE;
+
+ if (pwm_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
+
+ /* TODO: Need to reorganize arguments */
+ if (peripheral_io_gdbus_pwm_call_get_duty_cycle_sync(
+ pwm_proxy,
+ dev->device,
+ dev->channel,
+ duty_cycle,
+ &ret,
+ NULL,
+ &error) == FALSE) {
+ _E("Error in %s() : %s\n", __func__, error->message);
+ g_error_free(error);
+ return PERIPHERAL_ERROR_UNKNOWN;
+ }
+
+ return ret;
+}
+int peripheral_gdbus_pwm_set_duty_cycle(peripheral_pwm_context_h dev, int duty_cycle)
+{
+ GError *error = NULL;
+ gint32 ret = PERIPHERAL_ERROR_NONE;
+
+ if (pwm_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
+
+ /* TODO: Need to reorganize arguments */
+ if (peripheral_io_gdbus_pwm_call_set_duty_cycle_sync(
+ pwm_proxy,
+ dev->device,
+ dev->channel,
+ duty_cycle,
+ &ret,
+ NULL,
+ &error) == FALSE) {
+ _E("Error in %s() : %s\n", __func__, error->message);
+ g_error_free(error);
+ return PERIPHERAL_ERROR_UNKNOWN;
+ }
+
+ return ret;
+}
+
+int peripheral_gdbus_pwm_get_period(peripheral_pwm_context_h dev, int *period)
+{
+ GError *error = NULL;
+ gint32 ret = PERIPHERAL_ERROR_NONE;
+
+ if (pwm_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
+
+ /* TODO: Need to reorganize arguments */
+ if (peripheral_io_gdbus_pwm_call_get_period_sync(
+ pwm_proxy,
+ dev->device,
+ dev->channel,
+ period,
+ &ret,
+ NULL,
+ &error) == FALSE) {
+ _E("Error in %s() : %s\n", __func__, error->message);
+ g_error_free(error);
+ return PERIPHERAL_ERROR_UNKNOWN;
+ }
+
+ return ret;
+}
+
+int peripheral_gdbus_pwm_set_period(peripheral_pwm_context_h dev, int period)
+{
+ GError *error = NULL;
+ gint32 ret = PERIPHERAL_ERROR_NONE;
+
+ if (pwm_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
+
+ /* TODO: Need to reorganize arguments */
+ if (peripheral_io_gdbus_pwm_call_set_period_sync(
+ pwm_proxy,
+ dev->device,
+ dev->channel,
+ period,
+ &ret,
+ NULL,
+ &error) == FALSE) {
+ _E("Error in %s() : %s\n", __func__, error->message);
+ g_error_free(error);
+ return PERIPHERAL_ERROR_UNKNOWN;
+ }
+
+ return ret;
+}
+
+int peripheral_gdbus_pwm_set_enable(peripheral_pwm_context_h dev, peripheral_pwm_state_e enable)
+{
+ GError *error = NULL;
+ gint32 ret = PERIPHERAL_ERROR_NONE;
+
+ if (pwm_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
+
+ /* TODO: Need to reorganize arguments */
+ if (peripheral_io_gdbus_pwm_call_set_enable_sync(
+ pwm_proxy,
+ dev->device,
+ dev->channel,
+ enable,
+ &ret,
+ NULL,
+ &error) == FALSE) {
+ _E("Error in %s() : %s\n", __func__, error->message);
+ g_error_free(error);
+ return PERIPHERAL_ERROR_UNKNOWN;
+ }
+
+ return ret;
+}
#include <assert.h>
#include "peripheral_io.h"
-#include "peripheral_dbus.h"
+#include "peripheral_gdbus_gpio.h"
#include "peripheral_common.h"
#include "peripheral_internal.h"
#include "peripheral_io_gdbus.h"
gpio_proxy_init();
- ret = peripheral_dbus_gpio_open(handle);
+ ret = peripheral_gdbus_gpio_open(handle);
if (ret != PERIPHERAL_ERROR_NONE) {
free(handle);
return PERIPHERAL_ERROR_INVALID_PARAMETER;
/* call gpio_close */
- ret = peripheral_dbus_gpio_close(gpio);
+ ret = peripheral_gdbus_gpio_close(gpio);
if (ret)
ret = TIZEN_ERROR_IO_ERROR;
gpio_proxy_deinit();
if (gpio == NULL)
return PERIPHERAL_ERROR_INVALID_PARAMETER;
- ret = peripheral_dbus_gpio_get_direction(gpio, direction);
+ ret = peripheral_gdbus_gpio_get_direction(gpio, direction);
if (ret == PERIPHERAL_ERROR_NONE)
gpio->direction = (*direction);
return PERIPHERAL_ERROR_INVALID_PARAMETER;
/* call gpio_set_direction */
- ret = peripheral_dbus_gpio_set_direction(gpio, direction);
+ ret = peripheral_gdbus_gpio_set_direction(gpio, direction);
if (ret == PERIPHERAL_ERROR_NONE)
gpio->direction = direction;
return PERIPHERAL_ERROR_INVALID_PARAMETER;
/* call gpio_read */
- ret = peripheral_dbus_gpio_read(gpio, value);
+ ret = peripheral_gdbus_gpio_read(gpio, value);
return ret;
}
return PERIPHERAL_ERROR_INVALID_PARAMETER;
/* call gpio_write */
- ret = peripheral_dbus_gpio_write(gpio, value);
+ ret = peripheral_gdbus_gpio_write(gpio, value);
return ret;
}
if (gpio == NULL)
return PERIPHERAL_ERROR_INVALID_PARAMETER;
- ret = peripheral_dbus_gpio_get_edge_mode(gpio, edge);
+ ret = peripheral_gdbus_gpio_get_edge_mode(gpio, edge);
if (ret == PERIPHERAL_ERROR_NONE)
gpio->edge = (*edge);
return PERIPHERAL_ERROR_INVALID_PARAMETER;
/* call gpio_set_edge_mode */
- ret = peripheral_dbus_gpio_set_edge_mode(gpio, edge);
+ ret = peripheral_gdbus_gpio_set_edge_mode(gpio, edge);
if (ret == PERIPHERAL_ERROR_NONE)
gpio->edge = edge;
if (gpio == NULL)
return PERIPHERAL_ERROR_INVALID_PARAMETER;
- ret = peripheral_dbus_gpio_register_cb(gpio, callback, user_data);
+ ret = peripheral_gdbus_gpio_register_cb(gpio, callback, user_data);
if (ret != PERIPHERAL_ERROR_NONE)
return ret;
if (gpio == NULL)
return PERIPHERAL_ERROR_INVALID_PARAMETER;
- ret = peripheral_dbus_gpio_unregister_cb(gpio);
+ ret = peripheral_gdbus_gpio_unregister_cb(gpio);
if (ret != PERIPHERAL_ERROR_NONE)
return ret;
#include <assert.h>
#include "peripheral_io.h"
-#include "peripheral_dbus.h"
+#include "peripheral_gdbus_i2c.h"
#include "peripheral_common.h"
#include "peripheral_internal.h"
i2c_proxy_init();
- ret = peripheral_dbus_i2c_open(handle, bus, address);
+ ret = peripheral_gdbus_i2c_open(handle, bus, address);
if (ret != PERIPHERAL_ERROR_NONE) {
_E("[PERIPHERAL] I2C init error\n");
if (i2c == NULL) return PERIPHERAL_ERROR_INVALID_PARAMETER;
- ret = peripheral_dbus_i2c_close(i2c);
+ ret = peripheral_gdbus_i2c_close(i2c);
i2c_proxy_deinit();
free(i2c);
if (i2c == NULL) return PERIPHERAL_ERROR_INVALID_PARAMETER;
- ret = peripheral_dbus_i2c_read(i2c, data, length);
+ ret = peripheral_gdbus_i2c_read(i2c, data, length);
/*
_D("I2C read data : ");
for (int i = 0 ; i < length ; i++)
{
if (i2c == NULL) return PERIPHERAL_ERROR_INVALID_PARAMETER;
- return peripheral_dbus_i2c_write(i2c, data, length);
+ return peripheral_gdbus_i2c_write(i2c, data, length);
}
#include <assert.h>
#include "peripheral_io.h"
-#include "peripheral_dbus.h"
+#include "peripheral_gdbus_pwm.h"
#include "peripheral_common.h"
#define PWM_ENABLE 1
dev->device = device;
dev->channel = channel;
- ret = peripheral_dbus_pwm_open(dev, device, channel);
+ ret = peripheral_gdbus_pwm_open(dev, device, channel);
if (ret != PERIPHERAL_ERROR_NONE) {
free(dev);
{
int ret = PERIPHERAL_ERROR_NONE;
- ret = peripheral_dbus_pwm_close(pwm);
+ ret = peripheral_gdbus_pwm_close(pwm);
pwm_proxy_deinit();
if (ret == PERIPHERAL_ERROR_NONE) {
{
int ret = PERIPHERAL_ERROR_NONE;
- ret = peripheral_dbus_pwm_set_duty_cycle(pwm, duty_cycle);
+ ret = peripheral_gdbus_pwm_set_duty_cycle(pwm, duty_cycle);
if (ret != PERIPHERAL_ERROR_NONE)
pwm->duty_cycle = duty_cycle;
{
int ret = PERIPHERAL_ERROR_NONE;
- ret = peripheral_dbus_pwm_set_period(pwm, period);
+ ret = peripheral_gdbus_pwm_set_period(pwm, period);
if (ret != PERIPHERAL_ERROR_NONE)
pwm->period = period;
{
int ret = PERIPHERAL_ERROR_NONE;
- ret = peripheral_dbus_pwm_set_enable(pwm, enable);
+ ret = peripheral_gdbus_pwm_set_enable(pwm, enable);
if (ret != PERIPHERAL_ERROR_NONE)
pwm->enabled = enable;
{
int ret = PERIPHERAL_ERROR_NONE;
- ret = peripheral_dbus_pwm_get_duty_cycle(pwm, duty_cycle);
+ ret = peripheral_gdbus_pwm_get_duty_cycle(pwm, duty_cycle);
if (ret != PERIPHERAL_ERROR_NONE)
pwm->duty_cycle = *duty_cycle;
{
int ret = PERIPHERAL_ERROR_NONE;
- ret = peripheral_dbus_pwm_get_period(pwm, period);
+ ret = peripheral_gdbus_pwm_get_period(pwm, period);
if (ret != PERIPHERAL_ERROR_NONE)
pwm->period = *period;