X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fresource%2Fresource_servo_motor.c;h=5b75e957bbd3dc784070ef332cefdd16b7f015fe;hb=98b118389f7848f66d9f98c12f0f5d920d2e403b;hp=c6895ea6d74f6597b73597190b14015f9c5935d2;hpb=b12040d13b411ddddbd8f755b9d9629c3e8bdb6f;p=apps%2Fnative%2Fst-things-blind.git diff --git a/src/resource/resource_servo_motor.c b/src/resource/resource_servo_motor.c index c6895ea..5b75e95 100644 --- a/src/resource/resource_servo_motor.c +++ b/src/resource/resource_servo_motor.c @@ -19,7 +19,8 @@ #include #include "log.h" -#define SERVO_MOTOR_CHANNER (0) +#define SERVO_MOTOR_CHANNEL (0) +#define SERVO_MOTOR_DEFAULT_PERIOD 20.0 static peripheral_pwm_h g_pwm_h; @@ -35,15 +36,20 @@ int resource_set_servo_motor_value(double duty_cycle_ms) { int ret = 0; + if (duty_cycle_ms >= SERVO_MOTOR_DEFAULT_PERIOD) { + _E("Too large duty cycle"); + return -1; + } + if (!g_pwm_h) { - ret = peripheral_pwm_open(0, SERVO_MOTOR_CHANNER, &g_pwm_h); + ret = peripheral_pwm_open(0, SERVO_MOTOR_CHANNEL, &g_pwm_h); if (ret != PERIPHERAL_ERROR_NONE) { _E("failed to open servo motor with ch : %s", get_error_message(ret)); return -1; } } - ret = peripheral_pwm_set_period(g_pwm_h, 20 * 1000 * 1000); + ret = peripheral_pwm_set_period(g_pwm_h, SERVO_MOTOR_DEFAULT_PERIOD * 1000 * 1000); if (ret != PERIPHERAL_ERROR_NONE) { _E("failed to set period : %s", get_error_message(ret)); return -1;