* limitations under the License.
*/
-#ifndef __RCC_RESOURCE_H__
-#define __RCC_RESOURCE_H__
+#ifndef __ADC_MCP3008_H__
+#define __ADC_MCP3008_H__
-#include <peripheral_io.h>
+int adc_mcp3008_init(void);
+int adc_mcp3008_read(int ch_num, unsigned int *out_value);
+void adc_mcp3008_fini(void);
-#include "resource_internal.h"
-#include "resource/resource_co2_sensor.h"
+#endif /* __ADC_MCP3008_H__ */
-
-#endif /* __RCC_RESOURCE_H__ */
* limitations under the License.
*/
-#ifndef __RCC_RESOURCE_CO2_SENSOR_H__
-#define __RCC_RESOURCE_CO2_SENSOR_H__
+#ifndef __CO2_SENSOR_H__
+#define __CO2_SENSOR_H__
/**
* @brief Reads the value from co2 sensor through AD converter(MCP3008).
* @return 0 on success, otherwise a negative error value
*
*/
-extern int resource_read_co2_sensor(int ch_num, unsigned int *out_value);
+extern int co2_sensor_read(int ch_num, unsigned int *out_value);
+extern void co2_sensor_close(void);
-#endif /* __RCC_RESOURCE_CO2_SENSOR_H__ */
+#endif /* __CO2_SENSOR_H__ */
* limitations under the License.
*/
-#ifndef __RCC_LOG_H__
-#define __RCC_LOG_H__
+#ifndef __CO2_LOG_H__
+#define __CO2_LOG_H__
#include <dlog.h>
}
#endif
-#endif /* __RCC_LOG_H__ */
+#endif /* __CO2_LOG_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 __RCC_RESOURCE_ADC_MCP3008_H__
-#define __RCC_RESOURCE_ADC_MCP3008_H__
-
-int resource_adc_mcp3008_init(void);
-int resource_read_adc_mcp3008(int ch_num, unsigned int *out_value);
-void resource_adc_mcp3008_fini(void);
-
-#endif /* __RCC_RESOURCE_ADC_MCP3008_H__ */
-
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.1 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 __RCC_CO2_SENSOR_INTERNAL_H__
-#define __RCC_CO2_SENSOR_INTERNAL_H__
-
-extern void resource_close_co2_sensor(void);
-
-#endif /* __RCC_CO2_SENSOR_INTERNAL_H__ */
-
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * 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 __RCC_RESOURCE_INTERNAL_H__
-#define __RCC_RESOURCE_INTERNAL_H__
-
-#include <peripheral_io.h>
-
-#include "resource/resource_co2_sensor_internal.h"
-
-#define PIN_MAX 40
-
-struct _resource_s {
- int opened;
- peripheral_gpio_h sensor_h;
- void (*close) (int);
-};
-typedef struct _resource_s resource_s;
-
-typedef void (*resource_read_cb)(double value, void *data);
-
-struct _resource_read_cb_s {
- resource_read_cb cb;
- void *data;
- int pin_num;
-};
-typedef struct _resource_read_cb_s resource_read_s;
-
-extern resource_s *resource_get_info(int pin_num);
-extern void resource_close_all(void);
-
-#endif /* __RCC_RESOURCE_INTERNAL_H__ */
* limitations under the License.
*/
-#ifndef __RCC_SENSOR_DATA_H__
-#define __RCC_SENSOR_DATA_H__
+#ifndef __SENSOR_DATA_H__
+#define __SENSOR_DATA_H__
typedef enum {
SENSOR_DATA_TYPE_NONE = 0,
int sensor_data_get_double(sensor_data *data, double *value);
int sensor_data_get_string(sensor_data *data, const char **value);
-#endif /* __RCC_SENSOR_DATA_H__ */
+#endif /* __SENSOR_DATA_H__ */
static peripheral_spi_h MCP3008_H = NULL;
static unsigned int ref_count = 0;
-int resource_adc_mcp3008_init(void)
+int adc_mcp3008_init(void)
{
int ret = 0;
int bus = -1;
}
-int resource_read_adc_mcp3008(int ch_num, unsigned int *out_value)
+int adc_mcp3008_read(int ch_num, unsigned int *out_value)
{
unsigned char rx[3] = {0, };
unsigned char tx[3] = {0, };
return 0;
}
-void resource_adc_mcp3008_fini(void)
+void adc_mcp3008_fini(void)
{
if (MCP3008_H)
ref_count--;
#include <peripheral_io.h>
#include <sys/time.h>
+#include "adc-mcp3008.h"
#include "log.h"
-#include "resource/resource_adc_mcp3008.h"
static bool initialized = false;
-void resource_close_co2_sensor(void)
+void co2_sensor_close(void)
{
- resource_adc_mcp3008_fini();
+ adc_mcp3008_fini();
initialized = false;
}
-int resource_read_co2_sensor(int ch_num, unsigned int *out_value)
+int co2_sensor_read(int ch_num, unsigned int *out_value)
{
unsigned int read_value = 0;
int ret = 0;
if (!initialized) {
- ret = resource_adc_mcp3008_init();
+ ret = adc_mcp3008_init();
retv_if(ret != 0, -1);
initialized = true;
}
- ret = resource_read_adc_mcp3008(ch_num, &read_value);
+ ret = adc_mcp3008_read(ch_num, &read_value);
retv_if(ret != 0, -1);
*out_value = read_value;
* limitations under the License.
*/
+#include <co2-sensor.h>
#include <tizen.h>
#include <service_app.h>
#include <stdio.h>
#include "st_things.h"
#include "log.h"
-#include "resource.h"
#include "sensor-data.h"
+#include "co2-sensor.h"
//#define TEST_RANDOM_VAL_GEN
static app_data *g_ad = NULL;
#ifdef TEST_RANDOM_VAL_GEN
-static int rand_resource_read_co2_sensor(unsigned int *out_value)
+static int rand_read_co2_sensor(unsigned int *out_value)
{
unsigned int val = 0;
retv_if(!out_value, -1);
#ifdef TEST_RANDOM_VAL_GEN
- ret = rand_resource_read_co2_sensor(out_value);
+ ret = rand_read_co2_sensor(out_value);
#else /* TEST_RANDOM_VAL_GEN */
- ret = resource_read_co2_sensor(SENSOR_CH_CO2, out_value);
+ ret = co2_sensor_read(SENSOR_CH_CO2, out_value);
#endif /* TEST_RANDOM_VAL_GEN */
return ret;
#endif
sensor_data_free(ad->co2_data);
- resource_close_all();
+ co2_sensor_close();
free(ad);
FN_END;
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Contact: Jin Yoon <jinny.yoon@samsung.com>
- * Geunsun Lee <gs86.lee@samsung.com>
- * Eunyoung Lee <ey928.lee@samsung.com>
- * Junkyu Han <junkyu.han@samsung.com>
- *
- * 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_io.h>
-
-#include "log.h"
-#include "resource.h"
-
-static resource_s resource_info[PIN_MAX] = { {0, NULL, NULL}, };
-
-resource_s *resource_get_info(int pin_num)
-{
- return &resource_info[pin_num];
-}
-
-void resource_close_all(void)
-{
- int i = 0;
- for (i = 0; i < PIN_MAX; i++) {
- if (!resource_info[i].opened) continue;
- _I("GPIO[%d] is closing...", i);
-
- if (resource_info[i].close)
- resource_info[i].close(i);
- }
- resource_close_co2_sensor();
-}