From: Hyeongsik Min Date: Wed, 14 Jun 2017 09:47:10 +0000 (+0900) Subject: Improve preset test(I2C, PWM) X-Git-Tag: submit/tizen/20170713.044725~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6f7c431546416acd5d03b0ef34b3390db10d77dc;p=platform%2Fcore%2Fapi%2Fperipheral-io.git Improve preset test(I2C, PWM) - Get user input for PWM device and channel number. - Read 2 bytes from GY30 light sensor. Change-Id: I2225119d7ae21e8fd7ebe9bd794c04afe0f40dd1 Signed-off-by: Hyeongsik Min --- diff --git a/test/peripheral-io-test.c b/test/peripheral-io-test.c index 23a63ae..4ccbbe1 100644 --- a/test/peripheral-io-test.c +++ b/test/peripheral-io-test.c @@ -207,7 +207,7 @@ int i2c_gy30_test(void) gettimeofday(&tv_1, NULL); while (cnt++ < 1000) { - ret = peripheral_i2c_read_byte(i2c, buf); + ret = peripheral_i2c_read(i2c, buf, 2); if (ret < 0) printf("Failed to read, ret : %d\n", ret); result = GY30_READ_INTENSITY(buf); @@ -378,7 +378,7 @@ error: int pwm_test_led(void) { - int device = 0, channel = 0; + int device, channel, ret; int period = 1 * 1000; int duty_cycle = 1 * 1000 / 100; int cnt = 0; @@ -388,13 +388,24 @@ int pwm_test_led(void) peripheral_pwm_h dev; printf(" %s()\n", __func__); + printf("Enter PWM device number\n"); + if (read_int_input(&device) < 0) + return -1; - peripheral_pwm_open(device, channel, &dev); + printf("Enter PWM channel number\n"); + if (read_int_input(&channel) < 0) + return -1; + + ret = peripheral_pwm_open(device, channel, &dev); + if (ret != PERIPHERAL_ERROR_NONE) { + printf("Failed to open\n"); + return ret; + } peripheral_pwm_set_period(dev, period); /* period: nanosecond */ peripheral_pwm_set_duty_cycle(dev, duty_cycle); /* duty_cycle: nanosecond */ peripheral_pwm_set_enable(dev, 1); /* 0: disable, 1: enable */ - while (cnt < 5) { + while (cnt < 2) { for (set_duty_cycle = period; set_duty_cycle > 0; set_duty_cycle -= 50) { /* set duty cycle */ peripheral_pwm_set_duty_cycle(dev, set_duty_cycle); @@ -421,7 +432,7 @@ int pwm_test_led(void) int pwm_test_motor(void) { - int device = 0, channel = 0; + int device, channel, ret; int period = 20000000; int duty_cycle = 1500000; int cnt = 0, idx = 0; @@ -429,8 +440,19 @@ int pwm_test_motor(void) peripheral_pwm_h dev; printf(" %s()\n", __func__); + printf("Enter PWM device number\n"); + if (read_int_input(&device) < 0) + return -1; - peripheral_pwm_open(device, channel, &dev); + printf("Enter PWM channel number\n"); + if (read_int_input(&channel) < 0) + return -1; + + ret = peripheral_pwm_open(device, channel, &dev); + if (ret != PERIPHERAL_ERROR_NONE) { + printf("Failed to open\n"); + return ret; + } for (cnt = 0; cnt < 5; cnt++) { for (idx = 0; idx < 3; idx++) { switch (degree[idx]) {