Skip to content

Commit

Permalink
Added servo_start param to support ESCs
Browse files Browse the repository at this point in the history
Electronic Speed Controls might want to start at 0 or 1ms pulse.
  • Loading branch information
Scott Ellis committed Sep 12, 2011
1 parent 3f00f8c commit 4a1618e
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions pwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,17 @@ MODULE_PARM_DESC(servo, "Enable servo mode operation");
#define SERVO_ABSOLUTE_MAX 20000
#define SERVO_CENTER 15000

static int servo_min = 10000;
static int servo_min = SERVO_ABSOLUTE_MIN;
module_param(servo_min, int, S_IRUGO);
MODULE_PARM_DESC(servo_min, "Servo min value in tenths of usec, default 10000");

static int servo_max = 20000;
static int servo_max = SERVO_ABSOLUTE_MAX;
module_param(servo_max, int, S_IRUGO);
MODULE_PARM_DESC(servo_max, "Servo max value in tenths of usec, default 20000");

static int servo_start = SERVO_CENTER;
module_param(servo_start, int, S_IRUGO);
MODULE_PARM_DESC(servo_start, "Servo value on startup in tenths of usec, default 15000");

#define USER_BUFF_SIZE 128

Expand Down Expand Up @@ -387,7 +390,7 @@ static int pwm_timer_init(void)
goto timer_init_fail;

if (servo)
pwm_set_servo_pulse(&pwm_dev[i], SERVO_CENTER);
pwm_set_servo_pulse(&pwm_dev[i], servo_start);
}

return 0;
Expand Down Expand Up @@ -667,6 +670,11 @@ static int __init pwm_init(void)
servo_min = SERVO_ABSOLUTE_MIN;
servo_max = SERVO_ABSOLUTE_MAX;
}

if (servo_start < servo_min)
servo_start = servo_min;
else if (servo_start > servo_max)
servo_start = servo_max;
}

if (pwm_timer_init())
Expand Down

0 comments on commit 4a1618e

Please sign in to comment.