From 7fbad5adea0a022d71d8c5c4453cda1244e154b3 Mon Sep 17 00:00:00 2001 From: px4dev Date: Sun, 4 Nov 2012 16:44:36 -0800 Subject: [PATCH] Fix PWM channel zero output; pin configuration was being overwritten by USART2 setup. --- apps/px4io/mixer.c | 2 +- apps/px4io/px4io.c | 13 ++++++------- apps/px4io/px4io.h | 12 +++++++++++- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/apps/px4io/mixer.c b/apps/px4io/mixer.c index 94d10ef573..fab5773832 100644 --- a/apps/px4io/mixer.c +++ b/apps/px4io/mixer.c @@ -96,7 +96,7 @@ struct mixer { } mixers[IO_SERVO_COUNT]; int -mixer_init(const char *mq_name) +mixer_init(void) { /* look for control data at 50Hz */ hrt_call_every(&mixer_input_call, 1000, 20000, mixer_tick, NULL); diff --git a/apps/px4io/px4io.c b/apps/px4io/px4io.c index 90057c790c..dc8e227fcd 100644 --- a/apps/px4io/px4io.c +++ b/apps/px4io/px4io.c @@ -59,8 +59,6 @@ int gpio_fd; static const char cursor[] = {'|', '/', '-', '\\'}; -static const char *rc_input_mq_name = "rc_input"; - static struct hrt_call timer_tick_call; volatile int timers[TIMER_NUM_TIMERS]; static void timer_tick(void *arg); @@ -74,7 +72,11 @@ int user_start(int argc, char *argv[]) /* configure the high-resolution time/callout interface */ hrt_init(); - /* configure the PWM outputs */ + /* init the FMU link */ + comms_init(); + + /* configure the first 8 PWM outputs (i.e. all of them) */ + /* note, must do this after comms init to steal back PA0, which is CTS otherwise */ up_pwm_servo_init(0xff); /* print some startup info */ @@ -94,14 +96,11 @@ int user_start(int argc, char *argv[]) POWER_SERVO(true); /* start the mixer */ - mixer_init(rc_input_mq_name); + mixer_init(); /* start the safety switch handler */ safety_init(); - /* init the FMU link */ - comms_init(); - /* set up some timers for the main loop */ timers[TIMER_BLINK_AMBER] = 250; /* heartbeat blink @ 2Hz */ timers[TIMER_STATUS_PRINT] = 1000; /* print status message @ 1Hz */ diff --git a/apps/px4io/px4io.h b/apps/px4io/px4io.h index bbbe918654..7aef881020 100644 --- a/apps/px4io/px4io.h +++ b/apps/px4io/px4io.h @@ -52,6 +52,16 @@ #define MAX_CONTROL_CHANNELS 12 #define IO_SERVO_COUNT 8 +/* + * Debug logging + */ + +#if 1 +# define debug(fmt, ...) lib_lowprintf(fmt "\n", ##args) +#else +# define debug(fmt, ...) do {} while(0) +#endif + /* * System state structure. */ @@ -130,7 +140,7 @@ extern volatile int timers[TIMER_NUM_TIMERS]; /* * Mixer */ -extern int mixer_init(const char *mq_name); +extern int mixer_init(void); /* * Safety switch/LED.