2 * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
4 * Contact: Jin Yoon <jinny.yoon@samsung.com>
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
20 #include <peripheral_io.h>
25 #include "model/model_infrared_motion_sensor.h"
26 #include "model/model_infrared_obstacle_avoidance_sensor.h"
29 sensor_type_e sensor_type;
31 static struct _model_s model_s;
35 switch (model_s.sensor_type) {
36 case SENSOR_TYPE_ULTRASONIC:
38 case SENSOR_TYPE_INFRARED_MOTION:
39 model_fini_infrared_motion_sensor();
41 case SENSOR_TYPE_INFRARED_OBSTACLE_AVOIDANCE:
42 model_fini_infrared_obstacle_avoidance_sensor();
49 int model_init(sensor_type_e sensor_type)
52 model_s.sensor_type = sensor_type;
54 switch (sensor_type) {
55 case SENSOR_TYPE_ULTRASONIC:
57 case SENSOR_TYPE_INFRARED_MOTION:
58 ret = model_init_infrared_motion_sensor();
60 case SENSOR_TYPE_INFRARED_OBSTACLE_AVOIDANCE:
61 ret = model_init_infrared_obstacle_avoidance_sensor();
67 goto_if(ret != 0, error);
76 int model_alloc(void **data)
78 switch (model_s.sensor_type) {
79 case SENSOR_TYPE_ULTRASONIC:
81 case SENSOR_TYPE_INFRARED_MOTION:
82 case SENSOR_TYPE_INFRARED_OBSTACLE_AVOIDANCE:
83 _E("No function for allocation");
92 int model_read_int_value(int *out_value)
96 switch (model_s.sensor_type) {
97 case SENSOR_TYPE_ULTRASONIC:
98 ret = model_read_infrared_obstacle_avoidance_sensor(out_value);
100 case SENSOR_TYPE_INFRARED_MOTION:
101 ret = model_read_infrared_motion_sensor(out_value);
108 _E("Something wrong in the result[%d]", ret);
115 int model_write(void *data)
117 switch (model_s.sensor_type) {
118 case SENSOR_TYPE_ULTRASONIC:
119 case SENSOR_TYPE_INFRARED_MOTION:
120 _E("No function for writing");