diff options
Diffstat (limited to 'src/resource/resource_ultrasonic_jsn_sr04t.c')
-rw-r--r-- | src/resource/resource_ultrasonic_jsn_sr04t.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/resource/resource_ultrasonic_jsn_sr04t.c b/src/resource/resource_ultrasonic_jsn_sr04t.c index 5e40914..ab2c893 100644 --- a/src/resource/resource_ultrasonic_jsn_sr04t.c +++ b/src/resource/resource_ultrasonic_jsn_sr04t.c @@ -112,10 +112,11 @@ int resource_read_ultrasonic_jsn_sr04t(int trig_pin_num, int echo_pin_num, resou ret = peripheral_gpio_open(trig_pin_num, &resource_get_info(trig_pin_num)->sensor_h); retv_if(ret != PERIPHERAL_ERROR_NONE, -1); + resource_get_info(trig_pin_num)->opened = 1; + ret = peripheral_gpio_set_direction(resource_get_info(trig_pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_LOW); goto_if(ret != PERIPHERAL_ERROR_NONE, error); - resource_get_info(trig_pin_num)->opened = 1; resource_get_info(trig_pin_num)->close = resource_close_ultrasonic_jsn_sr04t_trig; } @@ -132,6 +133,8 @@ int resource_read_ultrasonic_jsn_sr04t(int trig_pin_num, int echo_pin_num, resou ret = peripheral_gpio_open(echo_pin_num, &resource_get_info(echo_pin_num)->sensor_h); goto_if(ret != PERIPHERAL_ERROR_NONE, error); + resource_get_info(echo_pin_num)->opened = 1; + ret = peripheral_gpio_set_direction(resource_get_info(echo_pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_LOW); goto_if(ret != PERIPHERAL_ERROR_NONE, error); @@ -145,7 +148,6 @@ int resource_read_ultrasonic_jsn_sr04t(int trig_pin_num, int echo_pin_num, resou ret = peripheral_gpio_set_interrupted_cb(resource_get_info(echo_pin_num)->sensor_h, _resource_read_ultrasonic_sensor_cb, resource_read_info); goto_if(ret != PERIPHERAL_ERROR_NONE, error); - resource_get_info(echo_pin_num)->opened = 1; resource_get_info(echo_pin_num)->close = resource_close_ultrasonic_jsn_sr04t_echo; } |