ad85e2722e36c9e82c588c1bd52d46016246021a
[apps/native/st-things-blind.git] / src / resource.c
1 /*
2  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
3  *
4  * Contact: Jin Yoon <jinny.yoon@samsung.com>
5  *
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
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
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.
17  */
18
19 #include <peripheral_io.h>
20
21 #include "log.h"
22 #include "resource.h"
23
24 static resource_s resource_info[PIN_MAX] = { {0, NULL, NULL}, };
25
26 resource_s *resource_get_info(int pin_num)
27 {
28         return &resource_info[pin_num];
29 }
30
31 void resource_close_all(void)
32 {
33         int i = 0;
34         for (i = 0; i < PIN_MAX; i++) {
35                 if (!resource_info[i].opened) continue;
36                 _I("GPIO[%d] is closing...", i);
37
38                 if (resource_info[i].close)
39                         resource_info[i].close(i);
40         }
41         resource_close_illuminance_sensor();
42 }