2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
4 * Contact: Jin Yoon <jinny.yoon@samsung.com>
5 * Geunsun Lee <gs86.lee@samsung.com>
6 * Eunyoung Lee <ey928.lee@samsung.com>
7 * Junkyu Han <junkyu.han@samsung.com>
9 * Licensed under the Flora License, Version 1.1 (the License);
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://floralicense.org/license/
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an AS IS BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
24 #include <peripheral_io.h>
27 #include "resource_internal.h"
29 void resource_close_led(int pin_num)
31 if (!resource_get_info(pin_num)->opened) return;
33 _I("LED is finishing...");
34 peripheral_gpio_close(resource_get_info(pin_num)->sensor_h);
35 resource_get_info(pin_num)->opened = 0;
38 int resource_write_led(int pin_num, int write_value)
40 int ret = PERIPHERAL_ERROR_NONE;
42 if (!resource_get_info(pin_num)->opened) {
43 ret = peripheral_gpio_open(pin_num, &resource_get_info(pin_num)->sensor_h);
44 retv_if(!resource_get_info(pin_num)->sensor_h, -1);
46 ret = peripheral_gpio_set_direction(resource_get_info(pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_LOW);
47 retv_if(ret != 0, -1);
49 resource_get_info(pin_num)->opened = 1;
50 resource_get_info(pin_num)->close = resource_close_led;
53 ret = peripheral_gpio_write(resource_get_info(pin_num)->sensor_h, write_value);
56 _I("LED Value : %s", write_value ? "ON":"OFF");