diff options
author | kibak.yoon <kibak.yoon@samsung.com> | 2017-09-25 14:13:51 +0900 |
---|---|---|
committer | kibak.yoon <kibak.yoon@samsung.com> | 2017-09-25 22:57:35 +0900 |
commit | dbf5629ae2ca0e05759003b6844be701520b893a (patch) | |
tree | dfefa60eae19f8d599058d765e6e2c0442d4dbec | |
parent | e56711738b1d4c62319a00fc7058c057d8101f43 (diff) | |
download | position-finder-server-accepted/tizen_6.5_unified.tar.gz position-finder-server-accepted/tizen_6.5_unified.tar.bz2 position-finder-server-accepted/tizen_6.5_unified.zip |
Change peripheral io APIstizen_8.0_m2_releasetizen_7.0_m2_releasetizen_6.5.m2_releasetizen_6.0.m2_releasetizen_5.5.m2_releasesubmit/tizen_6.5/20211028.161201submit/tizen_6.0_hotfix/20201103.114801submit/tizen_6.0_hotfix/20201102.192501submit/tizen_6.0/20201029.205101submit/tizen_5.5_wearable_hotfix/20201026.184301submit/tizen_5.5_mobile_hotfix/20201026.185101submit/tizen_5.5/20191031.000001submit/tizen_5.0/20181101.000001submit/tizen/20170926.023501accepted/tizen/unified/20170926.165620accepted/tizen/8.0/unified/20231005.092348accepted/tizen/7.0/unified/hotfix/20221116.104300accepted/tizen/7.0/unified/20221110.060951accepted/tizen/6.5/unified/20211028.093034accepted/tizen/6.0/unified/hotfix/20201103.051209accepted/tizen/6.0/unified/20201030.122833accepted/tizen/5.5/unified/wearable/hotfix/20201027.122833accepted/tizen/5.5/unified/mobile/hotfix/20201027.081414accepted/tizen/5.5/unified/20191031.014750accepted/tizen/5.0/unified/20181102.011806tizen_8.0tizen_7.0_hotfixtizen_7.0tizen_6.5tizen_6.0_hotfixtizen_6.0tizen_5.5_wearable_hotfixtizen_5.5_tvtizen_5.5_mobile_hotfixtizen_5.5tizen_5.0tizenaccepted/tizen_unifiedaccepted/tizen_8.0_unifiedaccepted/tizen_7.0_unified_hotfixaccepted/tizen_7.0_unifiedaccepted/tizen_6.5_unifiedaccepted/tizen_6.0_unified_hotfixaccepted/tizen_6.0_unifiedaccepted/tizen_5.5_unified_wearable_hotfixaccepted/tizen_5.5_unified_mobile_hotfixaccepted/tizen_5.5_unifiedaccepted/tizen_5.0_unified
- change parameter type from int to uint32_t in peripheral_gpio_read()
- change gpio interrupt-related API
Change-Id: Iec4794ef19ab299879d531b7f1615a402a4162de
Signed-off-by: kibak.yoon <kibak.yoon@samsung.com>
-rw-r--r-- | inc/resource/resource_infrared_motion_sensor.h | 2 | ||||
-rw-r--r-- | inc/resource/resource_infrared_obstacle_avoidance_sensor.h | 2 | ||||
-rw-r--r-- | src/controller.c | 2 | ||||
-rw-r--r-- | src/resource/resource_illuminance_sensor.c | 3 | ||||
-rw-r--r-- | src/resource/resource_infrared_motion_sensor.c | 2 | ||||
-rw-r--r-- | src/resource/resource_infrared_obstacle_avoidance_sensor.c | 2 | ||||
-rw-r--r-- | src/resource/resource_led.c | 2 | ||||
-rw-r--r-- | src/resource/resource_touch_sensor.c | 2 | ||||
-rw-r--r-- | src/resource/resource_ultrasonic_sensor.c | 27 |
9 files changed, 28 insertions, 16 deletions
diff --git a/inc/resource/resource_infrared_motion_sensor.h b/inc/resource/resource_infrared_motion_sensor.h index 6f9ff36..311f4db 100644 --- a/inc/resource/resource_infrared_motion_sensor.h +++ b/inc/resource/resource_infrared_motion_sensor.h @@ -29,6 +29,6 @@ * @return 0 on success, otherwise a negative error value * @see If the gpio pin is not open, creates gpio handle before reading the value of gpio. */ -extern int resource_read_infrared_motion_sensor(int pin_num, int *out_value); +extern int resource_read_infrared_motion_sensor(int pin_num, uint32_t *out_value); #endif /* __POSITION_FINDER_RESOURCE_INFRARED_MOTION_SENSOR_H__ */ diff --git a/inc/resource/resource_infrared_obstacle_avoidance_sensor.h b/inc/resource/resource_infrared_obstacle_avoidance_sensor.h index dd25e25..22d03b9 100644 --- a/inc/resource/resource_infrared_obstacle_avoidance_sensor.h +++ b/inc/resource/resource_infrared_obstacle_avoidance_sensor.h @@ -29,6 +29,6 @@ * @return 0 on success, otherwise a negative error value * @see If the gpio pin is not open, creates gpio handle before reading the value of gpio. */ -extern int resource_read_infrared_obstacle_avoidance_sensor(int pin_num, int *out_value); +extern int resource_read_infrared_obstacle_avoidance_sensor(int pin_num, uint32_t *out_value); #endif /* __POSITION_FINDER_RESOURCE_INFRARED_OBSTACLE_AVOIDANCE_SENSOR_H__ */ diff --git a/src/controller.c b/src/controller.c index 6e1e50f..92be7f3 100644 --- a/src/controller.c +++ b/src/controller.c @@ -44,7 +44,7 @@ typedef struct app_data_s { static Eina_Bool control_sensors_cb(void *data) { - int value[MULTIPLE_SENSOR_NUMBER] = { 0, }; + uint32_t value[MULTIPLE_SENSOR_NUMBER] = { 0, }; int total = 0; int gpio_num[MULTIPLE_SENSOR_NUMBER] = { 5, 6, 13, 19, 26 }; int i = 0; diff --git a/src/resource/resource_illuminance_sensor.c b/src/resource/resource_illuminance_sensor.c index 8d1d9d8..83b01c9 100644 --- a/src/resource/resource_illuminance_sensor.c +++ b/src/resource/resource_illuminance_sensor.c @@ -58,7 +58,8 @@ int resource_read_illuminance_sensor(int i2c_bus, int *out_value) resource_sensor_s.opened = 1; } - ret = peripheral_i2c_write_byte(resource_sensor_s.sensor_h, GY30_CONT_HIGH_RES_MODE); + buf[0] = GY30_CONT_HIGH_RES_MODE; + ret = peripheral_i2c_write(resource_sensor_s.sensor_h, buf, 1); retv_if(ret < 0, -1); ret = peripheral_i2c_read(resource_sensor_s.sensor_h, buf, 2); diff --git a/src/resource/resource_infrared_motion_sensor.c b/src/resource/resource_infrared_motion_sensor.c index 40308a3..1a7eab3 100644 --- a/src/resource/resource_infrared_motion_sensor.c +++ b/src/resource/resource_infrared_motion_sensor.c @@ -36,7 +36,7 @@ void resource_close_infrared_motion_sensor(int pin_num) resource_get_info(pin_num)->opened = 0; } -int resource_read_infrared_motion_sensor(int pin_num, int *out_value) +int resource_read_infrared_motion_sensor(int pin_num, uint32_t *out_value) { int ret = PERIPHERAL_ERROR_NONE; diff --git a/src/resource/resource_infrared_obstacle_avoidance_sensor.c b/src/resource/resource_infrared_obstacle_avoidance_sensor.c index bb57940..f802506 100644 --- a/src/resource/resource_infrared_obstacle_avoidance_sensor.c +++ b/src/resource/resource_infrared_obstacle_avoidance_sensor.c @@ -36,7 +36,7 @@ void resource_close_infrared_obstacle_avoidance_sensor(int pin_num) resource_get_info(pin_num)->opened = 0; } -int resource_read_infrared_obstacle_avoidance_sensor(int pin_num, int *out_value) +int resource_read_infrared_obstacle_avoidance_sensor(int pin_num, uint32_t *out_value) { int ret = PERIPHERAL_ERROR_NONE; diff --git a/src/resource/resource_led.c b/src/resource/resource_led.c index aa5e170..19361f5 100644 --- a/src/resource/resource_led.c +++ b/src/resource/resource_led.c @@ -43,7 +43,7 @@ int resource_write_led(int pin_num, int write_value) ret = peripheral_gpio_open(pin_num, &resource_get_info(pin_num)->sensor_h); retv_if(!resource_get_info(pin_num)->sensor_h, -1); - ret = peripheral_gpio_set_direction(resource_get_info(pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_OUT); + ret = peripheral_gpio_set_direction(resource_get_info(pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_LOW); retv_if(ret != 0, -1); resource_get_info(pin_num)->opened = 1; diff --git a/src/resource/resource_touch_sensor.c b/src/resource/resource_touch_sensor.c index 2b75e62..3b54fd5 100644 --- a/src/resource/resource_touch_sensor.c +++ b/src/resource/resource_touch_sensor.c @@ -36,7 +36,7 @@ void resource_close_touch_sensor(int pin_num) resource_get_info(pin_num)->opened = 0; } -int resource_read_touch_sensor(int pin_num, int *out_value) +int resource_read_touch_sensor(int pin_num, uint32_t *out_value) { int ret = PERIPHERAL_ERROR_NONE; diff --git a/src/resource/resource_ultrasonic_sensor.c b/src/resource/resource_ultrasonic_sensor.c index 9b908e0..4004820 100644 --- a/src/resource/resource_ultrasonic_sensor.c +++ b/src/resource/resource_ultrasonic_sensor.c @@ -42,26 +42,37 @@ void resource_close_ultrasonic_sensor(int trig_pin_num, int echo_pin_num) resource_get_info(echo_pin_num)->opened = 0; } -static void _resource_read_ultrasonic_sensor_cb(gpio_isr_cb_s *data, void *user_data) +static unsigned long long _get_timestamp(void) +{ + struct timespec t; + clock_gettime(CLOCK_REALTIME, &t); + return ((unsigned long long)(t.tv_sec)*1000000000LL + t.tv_nsec) / 1000; +} + +static void _resource_read_ultrasonic_sensor_cb(peripheral_gpio_h gpio, peripheral_error_e error, void *user_data) { float dist = 0; - static unsigned long long timestamp = 0; + uint32_t value; + static unsigned long long prev = 0; + unsigned long long now = _get_timestamp(); resource_read_s *resource_read_info = user_data; ret_if(!resource_read_info); ret_if(!resource_read_info->cb); - if (timestamp > 0 && data->value == 0) { - dist = data->timestamp - timestamp; + peripheral_gpio_read(gpio, &value); + + if (prev > 0 && value == 0) { + dist = now - prev; dist = (dist * 34300) / 2000000; _I("Measured Distance : %0.2fcm\n", dist); resource_read_info->cb(dist, resource_read_info->data); - peripheral_gpio_unregister_cb(resource_get_info(resource_read_info->pin_num)->sensor_h); + peripheral_gpio_unset_interrupted_cb(resource_get_info(resource_read_info->pin_num)->sensor_h); free(resource_read_info); } - timestamp = data->timestamp; + prev = now; } int resource_read_ultrasonic_sensor(int trig_pin_num, int echo_pin_num, resource_read_cb cb, void *data) @@ -81,7 +92,7 @@ int resource_read_ultrasonic_sensor(int trig_pin_num, int echo_pin_num, resource ret = peripheral_gpio_open(trig_pin_num, &resource_get_info(trig_pin_num)->sensor_h); retv_if(!resource_get_info(trig_pin_num)->sensor_h, -1); - ret = peripheral_gpio_set_direction(resource_get_info(trig_pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_OUT); + ret = peripheral_gpio_set_direction(resource_get_info(trig_pin_num)->sensor_h, PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_LOW); retv_if(ret != 0, -1); resource_get_info(trig_pin_num)->opened = 1; @@ -103,7 +114,7 @@ int resource_read_ultrasonic_sensor(int trig_pin_num, int echo_pin_num, resource } if (resource_get_info(echo_pin_num)->sensor_h) { - ret = peripheral_gpio_register_cb(resource_get_info(echo_pin_num)->sensor_h, _resource_read_ultrasonic_sensor_cb, resource_read_info); + ret = peripheral_gpio_set_interrupted_cb(resource_get_info(echo_pin_num)->sensor_h, _resource_read_ultrasonic_sensor_cb, resource_read_info); retv_if(ret != 0, -1); } |