rename modules
authorJeonghoon Park <jh1979.park@samsung.com>
Tue, 17 Jul 2018 11:04:09 +0000 (20:04 +0900)
committerJeonghoon Park <jh1979.park@samsung.com>
Tue, 17 Jul 2018 11:04:09 +0000 (20:04 +0900)
inc/adc-mcp3008.h [moved from inc/resource.h with 75% similarity, mode: 0644]
inc/co2-sensor.h [moved from inc/resource/resource_co2_sensor.h with 82% similarity]
inc/log.h
inc/resource/resource_adc_mcp3008.h [deleted file]
inc/resource/resource_co2_sensor_internal.h [deleted file]
inc/resource_internal.h [deleted file]
inc/sensor-data.h
src/adc-mcp3008.c [moved from src/resource/resource_adc_mcp3008.c with 97% similarity]
src/co2-sensor.c [moved from src/resource/resource_co2_sensor.c with 78% similarity]
src/co2.c [moved from src/controller.c with 96% similarity]
src/resource.c [deleted file]

old mode 100755 (executable)
new mode 100644 (file)
similarity index 75%
rename from inc/resource.h
rename to inc/adc-mcp3008.h
index 56cf3ad..3d8e9b3
  * 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__ */
similarity index 82%
rename from inc/resource/resource_co2_sensor.h
rename to inc/co2-sensor.h
index e8b21c7..6a4322e 100644 (file)
@@ -14,8 +14,8 @@
  * 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).
@@ -24,7 +24,8 @@
   * @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__ */
 
index 0df7a69..adc0c41 100644 (file)
--- a/inc/log.h
+++ b/inc/log.h
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-#ifndef __RCC_LOG_H__
-#define  __RCC_LOG_H__
+#ifndef __CO2_LOG_H__
+#define  __CO2_LOG_H__
 
 #include <dlog.h>
 
@@ -92,4 +92,4 @@ extern "C" {
 }
 #endif
 
-#endif /* __RCC_LOG_H__ */
+#endif /* __CO2_LOG_H__ */
diff --git a/inc/resource/resource_adc_mcp3008.h b/inc/resource/resource_adc_mcp3008.h
deleted file mode 100644 (file)
index cc19ea9..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * 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__ */
-
diff --git a/inc/resource/resource_co2_sensor_internal.h b/inc/resource/resource_co2_sensor_internal.h
deleted file mode 100644 (file)
index 7aeb0cc..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * 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__ */
-
diff --git a/inc/resource_internal.h b/inc/resource_internal.h
deleted file mode 100755 (executable)
index 1f86fc4..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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__ */
index e4b9554..54f0c72 100644 (file)
@@ -14,8 +14,8 @@
  * 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,
@@ -40,4 +40,4 @@ int sensor_data_get_uint(sensor_data *data, unsigned int *value);
 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__ */
similarity index 97%
rename from src/resource/resource_adc_mcp3008.c
rename to src/adc-mcp3008.c
index feab8ad..4434897 100644 (file)
@@ -50,7 +50,7 @@
 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;
@@ -120,7 +120,7 @@ error_after_open:
 }
 
 
-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, };
@@ -186,7 +186,7 @@ int resource_read_adc_mcp3008(int ch_num, unsigned int *out_value)
        return 0;
 }
 
-void resource_adc_mcp3008_fini(void)
+void adc_mcp3008_fini(void)
 {
        if (MCP3008_H)
                ref_count--;
similarity index 78%
rename from src/resource/resource_co2_sensor.c
rename to src/co2-sensor.c
index e262377..caa055c 100644 (file)
 #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;
similarity index 96%
rename from src/controller.c
rename to src/co2.c
index daa015e..895e82b 100644 (file)
+++ b/src/co2.c
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+#include <co2-sensor.h>
 #include <tizen.h>
 #include <service_app.h>
 #include <stdio.h>
@@ -24,8 +25,8 @@
 
 #include "st_things.h"
 #include "log.h"
-#include "resource.h"
 #include "sensor-data.h"
+#include "co2-sensor.h"
 
 //#define TEST_RANDOM_VAL_GEN
 
@@ -57,7 +58,7 @@ typedef struct app_data_s {
 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;
 
@@ -74,9 +75,9 @@ static int read_co2_sensor(unsigned int *out_value)
        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;
@@ -300,7 +301,7 @@ static void service_app_terminate(void *user_data)
 #endif
 
        sensor_data_free(ad->co2_data);
-       resource_close_all();
+       co2_sensor_close();
        free(ad);
 
        FN_END;
diff --git a/src/resource.c b/src/resource.c
deleted file mode 100644 (file)
index 760ab83..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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();
-}