INCLUDE_DIRECTORIES(${INC_DIR})
INCLUDE_DIRECTORIES(${INC_DIR}/gdbus)
INCLUDE_DIRECTORIES(${INC_DIR}/interface)
-INCLUDE_DIRECTORIES(${INC_DIR}/direct)
SET(SRC_DIR src)
INCLUDE_DIRECTORIES(${SRC_DIR}/gdbus)
src/peripheral_adc.c
src/peripheral_uart.c
src/peripheral_spi.c
- src/direct/peripheral_i2c_direct.c
src/interface/peripheral_interface_gpio.c
src/interface/peripheral_interface_i2c.c
src/interface/peripheral_interface_pwm.c
+++ /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_DIRECT_COMMON_H__
-#define __PERIPHERAL_DIRECT_COMMON_H__
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <peripheral_io.h>
-
-#include "peripheral_log.h"
-
-#define MAX_ERR_LEN 255
-#define MAX_BUF_LEN 96
-
-#define IF_ERROR_RETURN(expr, func...) \
- do { \
- if (expr) { \
- int temp = errno; \
- func; \
- if (temp == EAGAIN) \
- return PERIPHERAL_ERROR_TRY_AGAIN; \
- char errmsg[MAX_ERR_LEN]; \
- strerror_r(temp, errmsg, sizeof(errmsg)); \
- _E("Failed the %s(%d) function. errmsg: %s", __FUNCTION__, __LINE__, errmsg); \
- return PERIPHERAL_ERROR_IO_ERROR; \
- } \
- } while (0)
-
-#endif /*__PERIPHERAL_DIRECT_COMMON_H__*/
+++ /dev/null
-int peripheral_direct_i2c_open(int bus, int address, int *fd_out);
#include "peripheral_log.h"
#define MAX_ERR_LEN 255
+#define MAX_BUF_LEN 96
#define CHECK_ERROR(expr) \
do { \
} \
} while (0)
+#define IF_ERROR_RETURN(expr, func...) \
+ do { \
+ if (expr) { \
+ int temp = errno; \
+ func; \
+ if (temp == EAGAIN) \
+ return PERIPHERAL_ERROR_TRY_AGAIN; \
+ char errmsg[MAX_ERR_LEN]; \
+ strerror_r(temp, 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__*/
\ No newline at end of file
+#endif /*__PERIPHERAL_INTERFACE_COMMON_H__*/
+++ /dev/null
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-
-#include "peripheral_io.h"
-#include "peripheral_log.h"
-#include "peripheral_interface_i2c.h"
-#include "peripheral_direct_common.h"
-
-
-int peripheral_direct_i2c_open(int bus, int address, int *fd_out)
-{
- RETVM_IF(bus < 0, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid i2c bus");
- RETVM_IF(address < 0, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid i2c address");
- RETVM_IF(fd_out == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid fd_out for i2c");
-
- int ret;
- int fd;
- char path[MAX_BUF_LEN] = {0, };
-
- snprintf(path, MAX_BUF_LEN, "/dev/i2c-%d", bus);
- fd = open(path, O_RDWR);
- IF_ERROR_RETURN(fd < 0);
-
- ret = ioctl(fd, I2C_SLAVE, address);
- IF_ERROR_RETURN(ret != 0, close(fd));
-
- *fd_out = fd;
-
- return PERIPHERAL_ERROR_NONE;
-}
#include <errno.h>
#include <stdlib.h>
#include <sys/file.h>
+#include <sys/ioctl.h>
#include <system_info.h>
#include "peripheral_io.h"
#include "peripheral_handle.h"
#include "peripheral_interface_i2c.h"
-#include "peripheral_direct_i2c.h"
#include "peripheral_log.h"
#define PERIPHERAL_IO_I2C_FEATURE "http://tizen.org/feature/peripheral_io.i2c"
peripheral_i2c_h handle;
int ret = PERIPHERAL_ERROR_NONE;
int lock_type = LOCK_EX;
+ char path[MAX_BUF_LEN] = {0, };
RETVM_IF(__is_feature_supported() == false, PERIPHERAL_ERROR_NOT_SUPPORTED, "I2C feature is not supported");
RETVM_IF(i2c == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid i2c handle");
return PERIPHERAL_ERROR_OUT_OF_MEMORY;
}
- ret = peripheral_direct_i2c_open(bus, address, &handle->fd);
- if (ret != PERIPHERAL_ERROR_NONE) {
- _E("Failed to open i2c communication, ret : %d", ret);
- free(handle);
- return ret;
- }
+ snprintf(path, MAX_BUF_LEN, "/dev/i2c-%d", bus);
+ handle->fd = open(path, O_RDWR);
+ IF_ERROR_RETURN(handle->fd < 0, free(handle));
+
+ IF_ERROR_RETURN(ioctl(handle->fd, I2C_SLAVE, address), close(handle->fd); free(handle));
if (flags == PERIPHERAL_OPEN_FLAGS_SHARED)
lock_type = LOCK_SH;