Leave only public header in include/.
Remove peripheral_handle.h by moving struct definitions into
respective source files.
Change-Id: I7a5042fbf68667499a1247bc8efcf704447e1d4d
+++ /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_INTERFACE_COMMON_H__
-#define __PERIPHERAL_INTERFACE_COMMON_H__
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include "peripheral_io.h"
-#include "peripheral_handle.h"
-#include "peripheral_log.h"
-
-#define MAX_ERR_LEN 255
-
-#define CHECK_ERROR(expr) \
- do { \
- if (expr) { \
- if (errno == EAGAIN) \
- return PERIPHERAL_ERROR_TRY_AGAIN; \
- if (errno == EINVAL) \
- return PERIPHERAL_ERROR_INVALID_PARAMETER; \
- char errmsg[MAX_ERR_LEN]; \
- strerror_r(errno, errmsg, sizeof(errmsg)); \
- _E("Failed the %s(%d) function. errmsg: %s", __FUNCTION__, __LINE__, errmsg); \
- return PERIPHERAL_ERROR_IO_ERROR; \
- } \
- } while (0)
-
-typedef struct predefined_type {
- char *type;
- int len;
-} predefined_type_s;
-
-#endif /*__PERIPHERAL_INTERFACE_COMMON_H__*/
+++ /dev/null
-/*
- * Copyright (c) 2017-2018 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_HANDLE_H__
-#define __PERIPHERAL_HANDLE_H__
-
-#include <gio/gio.h>
-#include "peripheral_io.h"
-
-typedef struct _peripheral_gpio_interrupted_cb_info_s {
- // vermagic value is used to verify structure inside csapi
- // do not move it and value field to different place inside structure
- // otherwise update csapi accordingly
- int vermagic;
- int value;
- GThread *thread;
- peripheral_gpio_interrupted_cb cb;
- peripheral_error_e error;
- void *user_data;
- gint status;
-} interrupted_cb_info_s;
-
-/**
- * @brief Internal struct for gpio context
- */
-struct _peripheral_gpio_s {
- // vermagic value is used to verify structure inside csapi
- // do not move it and callback info field to different place inside structure
- // otherwise update csapi accordingly
- int vermagic;
- interrupted_cb_info_s cb_info;
- int pin;
- int fd_direction;
- int fd_edge;
- int fd_value;
- peripheral_gpio_direction_e direction;
- peripheral_gpio_edge_e edge;
-};
-
-/**
- * @brief Internal struct for i2c context
- */
-struct _peripheral_i2c_s {
- int fd;
-};
-
-/**
- * @brief Internal struct for pwm context
- */
-struct _peripheral_pwm_s {
- int chip;
- int pin;
- int fd_period;
- int fd_duty_cycle;
- int fd_polarity;
- int fd_enable;
-};
-
-/**
- * @brief Internal struct for adc context
- */
-struct _peripheral_adc_s {
- int fd;
-};
-
-/**
- * @brief Internal struct for uart context
- */
-struct _peripheral_uart_s {
- int fd;
-};
-
-/**
- * @brief Internal struct for spi context
- */
-struct _peripheral_spi_s {
- int fd;
-};
-
-#endif /* __PERIPHERAL_HANDLE_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_COMMON_H__
-#define __PERIPHERAL_COMMON_H__
-
-#include <dlog.h>
-
-#undef LOG_TAG
-#define LOG_TAG "PERIPHERAL-IO"
-
-#define _E(fmt, arg...) LOGE(fmt, ##arg)
-#define _D(fmt, arg...) LOGD(fmt, ##arg)
-#define _W(fmt, arg...) LOGW(fmt, ##arg)
-
-#define RET_IF(expr) \
- do { \
- if (expr) { \
- _E("(%s)", #expr); \
- return; \
- } \
- } while (0)
-#define RETV_IF(expr, val) \
- do {\
- if (expr) { \
- _E("(%s)", #expr); \
- return (val); \
- } \
- } while (0)
-#define RETM_IF(expr, fmt, arg...) \
- do {\
- if (expr) { \
- _E(fmt, ##arg); \
- return; \
- } \
- } while (0)
-#define RETVM_IF(expr, val, fmt, arg...) \
- do {\
- if (expr) { \
- _E(fmt, ##arg); \
- return (val); \
- } \
- } 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_INTERFACE_COMMON_H__
+#define __PERIPHERAL_INTERFACE_COMMON_H__
+
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+
+#include "log.h"
+
+#define MAX_ERR_LEN 255
+
+#define CHECK_ERROR(expr) \
+ do { \
+ if (expr) { \
+ if (errno == EAGAIN) \
+ return PERIPHERAL_ERROR_TRY_AGAIN; \
+ if (errno == EINVAL) \
+ return PERIPHERAL_ERROR_INVALID_PARAMETER; \
+ char errmsg[MAX_ERR_LEN]; \
+ strerror_r(errno, errmsg, sizeof(errmsg)); \
+ _E("Failed the %s(%d) function. errmsg: %s", __FUNCTION__, __LINE__, errmsg); \
+ return PERIPHERAL_ERROR_IO_ERROR; \
+ } \
+ } while (0)
+
+typedef struct predefined_type {
+ char *type;
+ int len;
+} predefined_type_s;
+
+#endif /*__PERIPHERAL_INTERFACE_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_COMMON_H__
+#define __PERIPHERAL_COMMON_H__
+
+#include <dlog.h>
+
+#undef LOG_TAG
+#define LOG_TAG "PERIPHERAL-IO"
+
+#define _E(fmt, arg...) LOGE(fmt, ##arg)
+#define _D(fmt, arg...) LOGD(fmt, ##arg)
+#define _W(fmt, arg...) LOGW(fmt, ##arg)
+
+#define RET_IF(expr) \
+ do { \
+ if (expr) { \
+ _E("(%s)", #expr); \
+ return; \
+ } \
+ } while (0)
+#define RETV_IF(expr, val) \
+ do {\
+ if (expr) { \
+ _E("(%s)", #expr); \
+ return (val); \
+ } \
+ } while (0)
+#define RETM_IF(expr, fmt, arg...) \
+ do {\
+ if (expr) { \
+ _E(fmt, ##arg); \
+ return; \
+ } \
+ } while (0)
+#define RETVM_IF(expr, val, fmt, arg...) \
+ do {\
+ if (expr) { \
+ _E(fmt, ##arg); \
+ return (val); \
+ } \
+ } while (0)
+
+#endif /* __PERIPHERAL_COMMON_H__ */
#include <fcntl.h>
#include <inttypes.h>
+#include <stdio.h>
#include <stdlib.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <system_info.h>
#include "peripheral_io.h"
-#include "peripheral_interface_common.h"
-#include "peripheral_log.h"
+#include "common.h"
+#include "log.h"
#define PERIPHERAL_IO_ADC_FEATURE "http://tizen.org/feature/peripheral_io.adc"
#define ADC_BUFFER_MAX 64
+/**
+ * @brief Internal struct for adc context
+ */
+struct _peripheral_adc_s {
+ int fd;
+};
+
static int adc_feature = ADC_FEATURE_UNKNOWN;
static bool __is_feature_supported(void)
* limitations under the License.
*/
+#include <gio/gio.h>
#include <libudev.h>
#include <poll.h>
+#include <stdio.h>
#include <stdlib.h>
#include <sys/file.h>
#include <system_info.h>
#include "peripheral_io.h"
-#include "peripheral_interface_common.h"
-#include "peripheral_log.h"
+#include "common.h"
+#include "log.h"
#define PERIPHERAL_IO_GPIO_FEATURE "http://tizen.org/feature/peripheral_io.gpio"
#define GPIO_BUFFER_MAX 64
+typedef struct _peripheral_gpio_interrupted_cb_info_s {
+ // vermagic value is used to verify structure inside csapi
+ // do not move it and value field to different place inside structure
+ // otherwise update csapi accordingly
+ int vermagic;
+ int value;
+ GThread *thread;
+ peripheral_gpio_interrupted_cb cb;
+ peripheral_error_e error;
+ void *user_data;
+ gint status;
+} interrupted_cb_info_s;
+
+/**
+ * @brief Internal struct for gpio context
+ */
+struct _peripheral_gpio_s {
+ // vermagic value is used to verify structure inside csapi
+ // do not move it and callback info field to different place inside structure
+ // otherwise update csapi accordingly
+ int vermagic;
+ interrupted_cb_info_s cb_info;
+ int pin;
+ int fd_direction;
+ int fd_edge;
+ int fd_value;
+ peripheral_gpio_direction_e direction;
+ peripheral_gpio_edge_e edge;
+};
+
static int gpio_feature = GPIO_FEATURE_UNKNOWN;
static bool __is_feature_supported(void)
* limitations under the License.
*/
#include <errno.h>
+#include <stdio.h>
#include <stdlib.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <system_info.h>
#include "peripheral_io.h"
-#include "peripheral_interface_common.h"
-#include "peripheral_log.h"
+#include "common.h"
+#include "log.h"
#define PERIPHERAL_IO_I2C_FEATURE "http://tizen.org/feature/peripheral_io.i2c"
*/
#define I2C_SMBUS_BLOCK_MAX 32 /* As specified in SMBus standard */
+/**
+ * @brief Internal struct for i2c context
+ */
+struct _peripheral_i2c_s {
+ int fd;
+};
+
union i2c_smbus_data {
uint8_t byte;
uint16_t word;
#include <libudev.h>
#include <poll.h>
+#include <stdio.h>
#include <stdlib.h>
#include <sys/file.h>
#include <system_info.h>
#include "peripheral_io.h"
-#include "peripheral_interface_common.h"
-#include "peripheral_log.h"
+#include "common.h"
+#include "log.h"
#define PERIPHERAL_IO_PWM_FEATURE "http://tizen.org/feature/peripheral_io.pwm"
#define PWM_BUF_MAX 16
+/**
+ * @brief Internal struct for pwm context
+ */
+struct _peripheral_pwm_s {
+ int chip;
+ int pin;
+ int fd_period;
+ int fd_duty_cycle;
+ int fd_polarity;
+ int fd_enable;
+};
+
static int pwm_feature = PWM_FEATURE_UNKNOWN;
static bool __is_feature_supported(void)
#include <fcntl.h>
#include <linux/spi/spidev.h>
+#include <stdio.h>
#include <stdlib.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <system_info.h>
#include "peripheral_io.h"
-#include "peripheral_interface_common.h"
-#include "peripheral_log.h"
+#include "common.h"
+#include "log.h"
#define PERIPHERAL_IO_SPI_FEATURE "http://tizen.org/feature/peripheral_io.spi"
#define SPI_FEATURE_FALSE 0
#define SPI_FEATURE_TRUE 1
+/**
+ * @brief Internal struct for spi context
+ */
+struct _peripheral_spi_s {
+ int fd;
+};
+
static int spi_feature = SPI_FEATURE_UNKNOWN;
static bool __is_feature_supported(void)
*/
#include <fcntl.h>
+#include <limits.h>
+#include <stdio.h>
#include <stdlib.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <termios.h>
#include "peripheral_io.h"
-#include "peripheral_interface_common.h"
-#include "peripheral_log.h"
+#include "common.h"
+#include "log.h"
#define PERIPHERAL_IO_UART_FEATURE "http://tizen.org/feature/peripheral_io.uart"
#define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
#endif
+/**
+ * @brief Internal struct for uart context
+ */
+struct _peripheral_uart_s {
+ int fd;
+};
+
static const int peripheral_uart_br[] = {
B0, B50, B75, B110, B134,
B150, B200, B300, B600, B1200,