diff options
author | Julian Oes <joes@student.ethz.ch> | 2012-11-04 17:25:29 -0800 |
---|---|---|
committer | Julian Oes <joes@student.ethz.ch> | 2012-11-04 17:25:29 -0800 |
commit | 7ee9628559c57d876f57dfb936e13647c0604cd0 (patch) | |
tree | 10e118f557242cfe935ab2081927708231606c59 | |
parent | 87618bb9f28dcbb26a7b0c5f50b62edd53949699 (diff) | |
parent | 7fbad5adea0a022d71d8c5c4453cda1244e154b3 (diff) | |
download | px4-firmware-7ee9628559c57d876f57dfb936e13647c0604cd0.tar.gz px4-firmware-7ee9628559c57d876f57dfb936e13647c0604cd0.tar.bz2 px4-firmware-7ee9628559c57d876f57dfb936e13647c0604cd0.zip |
Merge branch 'master' of https://github.com/PX4/Firmware
-rw-r--r-- | apps/drivers/stm32/drv_pwm_servo.c | 14 | ||||
-rw-r--r-- | apps/px4io/mixer.c | 2 | ||||
-rw-r--r-- | apps/px4io/px4io.c | 13 | ||||
-rw-r--r-- | apps/px4io/px4io.h | 12 |
4 files changed, 23 insertions, 18 deletions
diff --git a/apps/drivers/stm32/drv_pwm_servo.c b/apps/drivers/stm32/drv_pwm_servo.c index e3801a417..50aa34d81 100644 --- a/apps/drivers/stm32/drv_pwm_servo.c +++ b/apps/drivers/stm32/drv_pwm_servo.c @@ -171,10 +171,8 @@ pwm_channel_init(unsigned channel) int up_pwm_servo_set(unsigned channel, servo_position_t value) { - if (channel >= PWM_SERVO_MAX_CHANNELS) { - lldbg("pwm_channel_set: bogus channel %u\n", channel); + if (channel >= PWM_SERVO_MAX_CHANNELS) return -1; - } unsigned timer = pwm_channels[channel].timer_index; @@ -214,17 +212,15 @@ up_pwm_servo_set(unsigned channel, servo_position_t value) servo_position_t up_pwm_servo_get(unsigned channel) { - if (channel >= PWM_SERVO_MAX_CHANNELS) { - lldbg("pwm_channel_get: bogus channel %u\n", channel); + if (channel >= PWM_SERVO_MAX_CHANNELS) return 0; - } unsigned timer = pwm_channels[channel].timer_index; servo_position_t value = 0; /* test timer for validity */ if ((pwm_timers[timer].base == 0) || - (pwm_channels[channel].gpio == 0)) + (pwm_channels[channel].timer_channel == 0)) return 0; /* configure the channel */ @@ -246,7 +242,7 @@ up_pwm_servo_get(unsigned channel) break; } - return value; + return value + 1; } int @@ -261,7 +257,7 @@ up_pwm_servo_init(uint32_t channel_mask) /* now init channels */ for (unsigned i = 0; i < PWM_SERVO_MAX_CHANNELS; i++) { /* don't do init for disabled channels; this leaves the pin configs alone */ - if (((1 << i) & channel_mask) && (pwm_channels[i].gpio != 0)) + if (((1 << i) & channel_mask) && (pwm_channels[i].timer_channel != 0)) pwm_channel_init(i); } diff --git a/apps/px4io/mixer.c b/apps/px4io/mixer.c index 94d10ef57..fab577383 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 90057c790..dc8e227fc 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 bbbe91865..7aef88102 100644 --- a/apps/px4io/px4io.h +++ b/apps/px4io/px4io.h @@ -53,6 +53,16 @@ #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. */ struct sys_state_s @@ -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. |