mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-06 07:21:36 +08:00
Trying to get rid of magic PWM numbers
This commit is contained in:
@@ -64,6 +64,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.
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user