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>
24 #include "model/model_touch_sensor.h"
28 struct model_touch_sensor {
29 peripheral_gpio_h gpio;
31 static struct model_touch_sensor model_touch_sensor_s;
33 void model_fini_touch_sensor(void)
35 _I("Touch Sensor is finishing...");
37 if (model_touch_sensor_s.gpio)
38 peripheral_gpio_close(model_touch_sensor_s.gpio);
41 int model_init_touch_sensor(void)
45 _I("Touch is initializing...");
47 /* GPIO for Ultrasonic Sensor's Transmit */
48 ret = peripheral_gpio_open(GPIO_NUM, &model_touch_sensor_s.gpio);
49 retv_if(ret != 0, -1);
50 retv_if(!model_touch_sensor_s.gpio, -1);
52 ret = peripheral_gpio_set_direction(model_touch_sensor_s.gpio, PERIPHERAL_GPIO_DIRECTION_IN);
53 goto_if(ret != 0, error);
58 model_fini_touch_sensor();
62 int model_read_touch_sensor(int *out_value)
66 ret = peripheral_gpio_read(model_touch_sensor_s.gpio, out_value);
69 _I("Touch Sensor Value : %d", *out_value);