aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2013-04-25 20:13:03 +1000
committerAndrew Tridgell <tridge@samba.org>2013-05-04 19:18:20 +1000
commitff7712ca3e752141e54f3cbf15198a62429617f7 (patch)
tree0ffe93d7141f75ba88534c6e56a39bd26f43005e /src
parentfc572906b7693d910ded443632e8608b200a7933 (diff)
downloadpx4-firmware-ff7712ca3e752141e54f3cbf15198a62429617f7.tar.gz
px4-firmware-ff7712ca3e752141e54f3cbf15198a62429617f7.tar.bz2
px4-firmware-ff7712ca3e752141e54f3cbf15198a62429617f7.zip
pwm: added -m option
this allows setting of the channel mask directly, which is useful for testing
Diffstat (limited to 'src')
-rw-r--r--src/systemcmds/pwm/pwm.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/systemcmds/pwm/pwm.c b/src/systemcmds/pwm/pwm.c
index de7a53199..08e6c88df 100644
--- a/src/systemcmds/pwm/pwm.c
+++ b/src/systemcmds/pwm/pwm.c
@@ -71,13 +71,14 @@ usage(const char *reason)
warnx("%s", reason);
errx(1,
"usage:\n"
- "pwm [-v] [-d <device>] [-u <alt_rate>] [-c <channel group>] [arm|disarm] [<channel_value> ...]\n"
+ "pwm [-v] [-d <device>] [-u <alt_rate>] [-c <channel group>] [-m chanmask ] [arm|disarm] [<channel_value> ...]\n"
" -v Print information about the PWM device\n"
" <device> PWM output device (defaults to " PWM_OUTPUT_DEVICE_PATH ")\n"
" <alt_rate> PWM update rate for channels in <alt_channel_mask>\n"
" <channel_group> Channel group that should update at the alternate rate (may be specified more than once)\n"
" arm | disarm Arm or disarm the ouptut\n"
" <channel_value>... PWM output values in microseconds to assign to the PWM outputs\n"
+ " <chanmask> Directly supply alt rate channel mask\n"
"\n"
"When -c is specified, any channel groups not listed with -c will update at the default rate.\n"
);
@@ -96,11 +97,12 @@ pwm_main(int argc, char *argv[])
int ret;
char *ep;
unsigned group;
+ int32_t set_mask = -1;
if (argc < 2)
usage(NULL);
- while ((ch = getopt(argc, argv, "c:d:u:v")) != EOF) {
+ while ((ch = getopt(argc, argv, "c:d:u:vm:")) != EOF) {
switch (ch) {
case 'c':
group = strtoul(optarg, &ep, 0);
@@ -120,6 +122,12 @@ pwm_main(int argc, char *argv[])
usage("bad alt_rate value");
break;
+ case 'm':
+ set_mask = strtol(optarg, &ep, 0);
+ if (*ep != '\0')
+ usage("bad set_mask value");
+ break;
+
case 'v':
print_info = true;
break;
@@ -143,6 +151,13 @@ pwm_main(int argc, char *argv[])
err(1, "PWM_SERVO_SET_UPDATE_RATE (check rate for sanity)");
}
+ /* directly supplied channel mask */
+ if (set_mask != -1) {
+ ret = ioctl(fd, PWM_SERVO_SELECT_UPDATE_RATE, set_mask);
+ if (ret != OK)
+ err(1, "PWM_SERVO_SELECT_UPDATE_RATE");
+ }
+
/* assign alternate rate to channel groups */
if (alt_channels_set) {
uint32_t mask = 0;