2 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include <peripheral_io.h>
21 static peripheral_gpio_h g_sensor_h = NULL;
22 static int g_pin_num = -1;
24 void resource_close_infrared_motion_sensor(void)
26 if (!g_sensor_h) return;
28 _I("Infrared Motion Sensor is finishing...");
30 peripheral_gpio_close(g_sensor_h);
36 int resource_read_infrared_motion_sensor(int pin_num, uint32_t *out_value)
38 int ret = PERIPHERAL_ERROR_NONE;
41 peripheral_gpio_h temp = NULL;
43 ret = peripheral_gpio_open(pin_num, &temp);
46 ret = peripheral_gpio_set_direction(temp, PERIPHERAL_GPIO_DIRECTION_IN);
48 peripheral_gpio_close(temp);
49 _E("peripheral_gpio_set_direction failed.");
57 if (g_pin_num != pin_num) {
58 _E("Invalid pin number.");
62 ret = peripheral_gpio_read(g_sensor_h, out_value);