diff options
author | Julian Oes <julian@oes.ch> | 2013-10-07 18:03:05 +0200 |
---|---|---|
committer | Julian Oes <julian@oes.ch> | 2013-10-07 18:03:05 +0200 |
commit | 19879432ad6cf709af25192401829719defd2983 (patch) | |
tree | 567bda3cb54df9c177ac1d2e47ece0c30ba03bce /src/drivers | |
parent | 03edf901617c5f5785ef7d78d8fa74e2bfdd45fc (diff) | |
download | px4-firmware-19879432ad6cf709af25192401829719defd2983.tar.gz px4-firmware-19879432ad6cf709af25192401829719defd2983.tar.bz2 px4-firmware-19879432ad6cf709af25192401829719defd2983.zip |
Trying to get rid of magic PWM numbers
Diffstat (limited to 'src/drivers')
-rw-r--r-- | src/drivers/drv_pwm_output.h | 20 | ||||
-rw-r--r-- | src/drivers/px4io/px4io.cpp | 6 |
2 files changed, 23 insertions, 3 deletions
diff --git a/src/drivers/drv_pwm_output.h b/src/drivers/drv_pwm_output.h index 76e98597a..5a3a126d0 100644 --- a/src/drivers/drv_pwm_output.h +++ b/src/drivers/drv_pwm_output.h @@ -65,6 +65,26 @@ __BEGIN_DECLS #define PWM_OUTPUT_MAX_CHANNELS 16 /** + * Minimum PWM in us + */ +#define PWM_MIN 900 + +/** + * Highest PWM allowed as the minimum PWM + */ +#define PWM_HIGHEST_MIN 1300 + +/** + * Maximum PWM in us + */ +#define PWM_MAX 2100 + +/** + * Lowest PWM allowed as the maximum PWM + */ +#define PWM_LOWEST_MAX 1700 + +/** * Servo output signal type, value is actual servo output pulse * width in microseconds. */ diff --git a/src/drivers/px4io/px4io.cpp b/src/drivers/px4io/px4io.cpp index ea3a73822..f9dc3773e 100644 --- a/src/drivers/px4io/px4io.cpp +++ b/src/drivers/px4io/px4io.cpp @@ -1818,7 +1818,7 @@ PX4IO::ioctl(file * /*filep*/, int cmd, unsigned long arg) /* TODO: we could go lower for e.g. TurboPWM */ unsigned channel = cmd - PWM_SERVO_SET(0); - if ((channel >= _max_actuators) || (arg < 900) || (arg > 2100)) { + if ((channel >= _max_actuators) || (arg < PWM_MIN) || (arg > PWM_MAX)) { ret = -EINVAL; } else { /* send a direct PWM value */ @@ -2402,8 +2402,8 @@ px4io_main(int argc, char *argv[]) /* set channel to commandline argument or to 900 for non-provided channels */ if (argc > i + 2) { failsafe[i] = atoi(argv[i+2]); - if (failsafe[i] < 800 || failsafe[i] > 2200) { - errx(1, "value out of range of 800 < value < 2200. Aborting."); + if (failsafe[i] < PWM_MIN || failsafe[i] > PWM_AX) { + errx(1, "value out of range of %d < value < %d. Aborting.", PWM_MIN, PWM_MAX); } } else { /* a zero value will result in stopping to output any pulse */ |