This commit is contained in:
Julian Oes
2012-11-04 17:25:29 -08:00
4 changed files with 23 additions and 18 deletions
+5 -9
View File
@@ -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);
}
+1 -1
View File
@@ -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);
+6 -7
View File
@@ -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 */
+11 -1
View File
@@ -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.