summaryrefslogtreecommitdiff
path: root/src/resource/resource_infrared_motion.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/resource/resource_infrared_motion.c')
-rwxr-xr-xsrc/resource/resource_infrared_motion.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/resource/resource_infrared_motion.c b/src/resource/resource_infrared_motion.c
index 574c58f..b432637 100755
--- a/src/resource/resource_infrared_motion.c
+++ b/src/resource/resource_infrared_motion.c
@@ -54,11 +54,18 @@ static int resource_open_infrared_motion(int pin_num)
int ret = peripheral_gpio_open(pin_num, &temp);
if (ret) {
- peripheral_gpio_close(temp);
_E("peripheral_gpio_open failed.");
return -1;
}
+ // It should be removed after peripheral-io is patched.
+ peripheral_gpio_set_direction(temp, PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_LOW);
+ if (ret) {
+ peripheral_gpio_close(temp);
+ _E("peripheral_gpio_set_direction failed.");
+ return -1;
+ }
+
ret = peripheral_gpio_set_direction(temp, PERIPHERAL_GPIO_DIRECTION_IN);
if (ret) {
peripheral_gpio_close(temp);
@@ -127,6 +134,8 @@ int resource_set_interrupted_cb_infrared_motion(int pin_num, resource_infrared_m
int ret = PERIPHERAL_ERROR_NONE;
int ret_valid = MOTION_HANDLE_ERROR_NONE;
+ retv_if(!interrupted_cb, -1);
+
ret_valid = _resource_validate_infrared_motion(pin_num);
if (ret_valid == MOTION_HANDLE_ERROR_NOT_OPEN) {
ret = resource_open_infrared_motion(pin_num);