#include <peripheral_io.h>
#include "resource_internal.h"
+
#include "resource/resource_illuminance_sensor.h"
+#include "resource/resource_illuminance_sensor_internal.h"
+
#include "resource/resource_infrared_motion_sensor.h"
+#include "resource/resource_infrared_motion_sensor_internal.h"
+
#include "resource/resource_infrared_obstacle_avoidance_sensor.h"
+#include "resource/resource_infrared_obstacle_avoidance_sensor_internal.h"
+
#include "resource/resource_touch_sensor.h"
+#include "resource/resource_touch_sensor_internal.h"
+
#include "resource/resource_ultrasonic_sensor.h"
+#include "resource/resource_ultrasonic_sensor_internal.h"
#endif /* __POSITION_FINDER_RESOURCE_H__ */
/* You have to use this illuminance sensor ONLY ONE in the pi board */
extern int resource_read_illuminance_sensor(int i2c_bus, int *out_value);
-extern void resource_close_illuminance_sensor(void);
#endif /* __POSITION_FINDER_RESOURCE_ILLUMINANCE_SENSOR_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 __POSITION_FINDER_RESOURCE_ILLUMINANCE_SENSOR_INTERNAL_H__
+#define __POSITION_FINDER_RESOURCE_ILLUMINANCE_SENSOR_INTERNAL_H__
+
+extern void resource_close_illuminance_sensor(void);
+
+#endif /* __POSITION_FINDER_RESOURCE_ILLUMINANCE_SENSOR_INTERNAL_H__ */
+
#ifndef __POSITION_FINDER_RESOURCE_INFRARED_MOTION_SENSOR_H__
#define __POSITION_FINDER_RESOURCE_INFRARED_MOTION_SENSOR_H__
-extern void resource_close_infrared_motion_sensor(int sensor_index);
extern int resource_read_infrared_motion_sensor(int pin_num, int *out_value);
#endif /* __POSITION_FINDER_RESOURCE_INFRARED_MOTION_SENSOR_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 __POSITION_FINDER_RESOURCE_INFRARED_MOTION_SENSOR_INTERNAL_H__
+#define __POSITION_FINDER_RESOURCE_INFRARED_MOTION_SENSOR_INTERNAL_H__
+
+extern void resource_close_infrared_motion_sensor(int sensor_index);
+
+#endif /* __POSITION_FINDER_RESOURCE_INFRARED_MOTION_SENSOR_INTERNAL_H__ */
#ifndef __POSITION_FINDER_RESOURCE_INFRARED_OBSTACLE_AVOIDANCE_SENSOR_H__
#define __POSITION_FINDER_RESOURCE_INFRARED_OBSTACLE_AVOIDANCE_SENSOR_H__
-extern void resource_close_infrared_obstacle_avoidance_sensor(int pin_num);
extern int resource_read_infrared_obstacle_avoidance_sensor(int pin_num, int *out_value);
#endif /* __POSITION_FINDER_RESOURCE_INFRARED_OBSTACLE_AVOIDANCE_SENSOR_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 __POSITION_FINDER_RESOURCE_INFRARED_OBSTACLE_AVOIDANCE_SENSOR_INTERNAL_H__
+#define __POSITION_FINDER_RESOURCE_INFRARED_OBSTACLE_AVOIDANCE_SENSOR_INTERNAL_H__
+
+extern void resource_close_infrared_obstacle_avoidance_sensor(int pin_num);
+
+#endif /* __POSITION_FINDER_RESOURCE_INFRARED_OBSTACLE_AVOIDANCE_SENSOR_INTERNAL_H__ */
#ifndef __POSITION_FINDER_RESOURCE_TOUCH_SENSOR_H__
#define __POSITION_FINDER_RESOURCE_TOUCH_SENSOR_H__
-extern void resource_close_touch_sensor(int pin_num);
extern int resource_read_touch_sensor(int pin_num, int *out_value);
#endif /* __POSITION_FINDER_RESOURCE_TOUCH_SENSOR_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 __POSITION_FINDER_RESOURCE_TOUCH_SENSOR_INTERNAL_H__
+#define __POSITION_FINDER_RESOURCE_TOUCH_SENSOR_INTERNAL_H__
+
+extern void resource_close_touch_sensor(int pin_num);
+
+#endif /* __POSITION_FINDER_RESOURCE_TOUCH_SENSOR_INTERNAL_H__ */
#ifndef __POSITION_FINDER_RESOURCE_ULTRASONIC_SENSOR_H__
#define __POSITION_FINDER_RESOURCE_ULTRASONIC_SENSOR_H__
-extern void resource_close_ultrasonic_sensor(int echo_pin_num, int trig_pin_num);
extern int resource_read_ultrasonic_sensor(int echo_pin_num, int trig_pin_num, double *out_value);
#endif /* __POSITION_FINDER_RESOURCE_ULTRASONIC_SENSOR_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 __POSITION_FINDER_RESOURCE_ULTRASONIC_SENSOR_INTERNAL_H__
+#define __POSITION_FINDER_RESOURCE_ULTRASONIC_SENSOR_INTERNAL_H__
+
+extern void resource_close_ultrasonic_sensor(int echo_pin_num, int trig_pin_num);
+
+#endif /* __POSITION_FINDER_RESOURCE_ULTRASONIC_SENSOR_INTERNAL_H__ */
typedef struct _resource_s resource_s;
extern resource_s *resource_get_info(int pin_num);
+extern void resource_close_all(void);
#endif /* __POSITION_FINDER_RESOURCE_INTERNAL_H__ */
ecore_timer_del(ad->getter_timer[i]);
}
}
- resource_close_infrared_motion_sensor(GPIO_INFRARED_MOTION_NUM_1);
- resource_close_ultrasonic_sensor(GPIO_ULTRASONIC_TRIG_NUM_1, GPIO_ULTRASONIC_ECHO_NUM_1);
- resource_close_illuminance_sensor();
+ resource_close_all();
free(ad);
}
*/
#include <peripheral_io.h>
+
+#include "log.h"
#include "resource.h"
static resource_s resource_info[PIN_MAX] = { 0, };
{
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);
+ peripheral_gpio_close(resource_info[i].sensor_h);
+ resource_info[i].opened = 0;
+ }
+ resource_close_illuminance_sensor();
+}
void resource_close_illuminance_sensor(void)
{
- ret_if(!resource_sensor_s.opened);
+ if (!resource_sensor_s.opened) return;
_I("Infrared Motion Sensor is finishing...");
peripheral_i2c_close(resource_sensor_s.sensor_h);
void resource_close_infrared_motion_sensor(int pin_num)
{
- ret_if(!resource_get_info(pin_num)->opened);
+ if (!resource_get_info(pin_num)->opened) return;
_I("Infrared Motion Sensor is finishing...");
+ peripheral_gpio_close(resource_get_info(pin_num)->sensor_h);
resource_get_info(pin_num)->opened = 0;
}
void resource_close_infrared_obstacle_avoidance_sensor(int pin_num)
{
- ret_if(!resource_get_info(pin_num)->opened);
+ if (!resource_get_info(pin_num)->opened) return;
_I("Infrared Obstacle Avoidance Sensor is finishing...");
peripheral_gpio_close(resource_get_info(pin_num)->sensor_h);
void resource_close_touch_sensor(int pin_num)
{
- ret_if(!resource_get_info(pin_num)->opened);
+ if (!resource_get_info(pin_num)->opened) return;
_I("Touch Sensor is finishing...");
peripheral_gpio_close(resource_get_info(pin_num)->sensor_h);
void resource_close_ultrasonic_sensor(int echo_pin_num, int trig_pin_num)
{
- ret_if(!resource_get_info(echo_pin_num)->opened);
- ret_if(!resource_get_info(trig_pin_num)->opened);
+ if (!resource_get_info(echo_pin_num)->opened) return;
+ if (!resource_get_info(trig_pin_num)->opened) return;
_I("Ultrasonic sensor is finishing...");