src/peripheral_spi.c
src/interface/peripheral_interface_gpio.c
src/interface/peripheral_interface_pwm.c
- src/interface/peripheral_interface_adc.c
src/gdbus/peripheral_gdbus_gpio.c
src/gdbus/peripheral_gdbus_pwm.c
src/gdbus/peripheral_io_gdbus.c)
+++ /dev/null
-/*
- * Copyright (c) 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_INTERFACE_ADC_H__
-#define __PERIPHERAL_INTERFACE_ADC_H__
-
-#include "peripheral_interface_common.h"
-
-#define ADC_BUFFER_MAX 64
-
-void peripheral_interface_adc_close(peripheral_adc_h adc);
-
-int peripheral_interface_adc_read(peripheral_adc_h adc, uint32_t *value);
-
-#endif/*__PERIPHERAL_INTERFACE_GPIO_H__*/
* @brief Internal struct for adc context
*/
struct _peripheral_adc_s {
- uint handle;
int fd;
};
+++ /dev/null
-/*
- * Copyright (c) 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.
- */
-
-#include "peripheral_interface_adc.h"
-
-int peripheral_interface_adc_read(peripheral_adc_h adc, uint32_t *value)
-{
- int ret;
- uint32_t tmp_val;
- char adc_buf[ADC_BUFFER_MAX] = {0, };
-
- ret = pread(adc->fd, &adc_buf, ADC_BUFFER_MAX, 0);
- CHECK_ERROR(ret <= 0);
-
- ret = sscanf(adc_buf, "%d", &tmp_val);
- if (ret == 1) {
- *value = tmp_val;
- } else {
- _E("Error: unable to read adc value \n");
- return PERIPHERAL_ERROR_IO_ERROR;
- }
-
- return PERIPHERAL_ERROR_NONE;
-}
-
-void peripheral_interface_adc_close(peripheral_adc_h adc)
-{
- close(adc->fd);
-}
*/
#include <fcntl.h>
+#include <inttypes.h>
#include <stdlib.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <system_info.h>
#include "peripheral_io.h"
-#include "peripheral_handle.h"
-#include "peripheral_interface_adc.h"
+#include "peripheral_interface_common.h"
#include "peripheral_log.h"
#define PERIPHERAL_IO_ADC_FEATURE "http://tizen.org/feature/peripheral_io.adc"
#define ADC_FEATURE_FALSE 0
#define ADC_FEATURE_TRUE 1
+#define ADC_BUFFER_MAX 64
+
static int adc_feature = ADC_FEATURE_UNKNOWN;
static bool __is_feature_supported(void)
RETVM_IF(adc == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "adc handle is NULL");
RETVM_IF(value == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "adc read value is invalid");
- return peripheral_interface_adc_read(adc, value);
+ int ret;
+ char adc_buf[ADC_BUFFER_MAX] = {0, };
+
+ ret = pread(adc->fd, &adc_buf, ADC_BUFFER_MAX, 0);
+ CHECK_ERROR(ret <= 0);
+
+ ret = sscanf(adc_buf, "%" SCNu32, value);
+ if (ret != 1) {
+ _E("Error: unable to read adc value: %m\n");
+ return PERIPHERAL_ERROR_IO_ERROR;
+ }
+
+ return PERIPHERAL_ERROR_NONE;
}