Init master branch with timer code
[apps/native/st-things-light.git] / inc / resource / resource_infrared_motion.h
1 /*
2  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #ifndef __RESOURCE_INFRARED_MOTION_H__
18 #define __RESOURCE_INFRARED_MOTION_H__
19
20 typedef void (*resource_infrared_motion_interrupted_cb) (uint32_t motion_value, void *user_data);
21
22 /**
23  * @brief Reads value of gpio connected infrared motion sensor (HC-SR501)
24  * @param[in] pin_num The gpio pin number for the infrared motion sensor
25  * @param[out] out_value The value of the gpio (zero or non-zero)
26  * @return 0 on success, otherwise a negative error value
27  * @see If the gpio pin is not open, create gpio handle before reading the value
28  */
29 extern int resource_read_infrared_motion(int pin_num, uint32_t *out_value);
30
31 /**
32  * @brief Releases the gpio handle
33  */
34 extern void resource_close_infrared_motion(void);
35
36 /**
37  * @brief Sets an interrupted callback to be invoked when interrupt is triggered on motion sensor
38  * @param[in] pin_num The gpio pin number for the infrared motion sensor
39  * @param[in] interrupted_cb interrupted user callback to be invoked
40  * @return 0 on success, otherwise a negative error value
41  * @see If the gpio pin is not open, create gpio handle before reading the value
42  */
43 extern int resource_set_interrupted_cb_infrared_motion(int pin_num, resource_infrared_motion_interrupted_cb interrupted_cb, void *user_data);
44
45 /**
46  * @brief Unsets the interrupted callback for motion sensor
47  * @param[in] pin_num The gpio pin number for the infrared motion sensor
48  */
49 extern int resource_unset_interrupted_cb_infrared_motion(int pin_num);
50
51 #endif /* __RESOURCE_INFRARED_MOTION_H__ */