forked from Archive/PX4-Autopilot
px4io code style
This commit is contained in:
parent
dc100f2020
commit
cf563eda86
|
@ -87,12 +87,16 @@ adc_init(void)
|
||||||
#ifdef ADC_CR2_CAL
|
#ifdef ADC_CR2_CAL
|
||||||
rCR2 |= ADC_CR2_RSTCAL;
|
rCR2 |= ADC_CR2_RSTCAL;
|
||||||
up_udelay(1);
|
up_udelay(1);
|
||||||
|
|
||||||
if (rCR2 & ADC_CR2_RSTCAL)
|
if (rCR2 & ADC_CR2_RSTCAL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
rCR2 |= ADC_CR2_CAL;
|
rCR2 |= ADC_CR2_CAL;
|
||||||
up_udelay(100);
|
up_udelay(100);
|
||||||
|
|
||||||
if (rCR2 & ADC_CR2_CAL)
|
if (rCR2 & ADC_CR2_CAL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* arbitrarily configure all channels for 55 cycle sample time */
|
/* arbitrarily configure all channels for 55 cycle sample time */
|
||||||
|
@ -146,6 +150,7 @@ adc_measure(unsigned channel)
|
||||||
|
|
||||||
/* wait for the conversion to complete */
|
/* wait for the conversion to complete */
|
||||||
hrt_abstime now = hrt_absolute_time();
|
hrt_abstime now = hrt_absolute_time();
|
||||||
|
|
||||||
while (!(rSR & ADC_SR_EOC)) {
|
while (!(rSR & ADC_SR_EOC)) {
|
||||||
|
|
||||||
/* never spin forever - this will give a bogus result though */
|
/* never spin forever - this will give a bogus result though */
|
||||||
|
|
|
@ -253,10 +253,12 @@ comms_handle_command(const void *buffer, size_t length)
|
||||||
if (new_servo_rate > 500) {
|
if (new_servo_rate > 500) {
|
||||||
new_servo_rate = 500;
|
new_servo_rate = 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* reject slower than 50 Hz updates */
|
/* reject slower than 50 Hz updates */
|
||||||
if (new_servo_rate < 50) {
|
if (new_servo_rate < 50) {
|
||||||
new_servo_rate = 50;
|
new_servo_rate = 50;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (system_state.servo_rate != new_servo_rate) {
|
if (system_state.servo_rate != new_servo_rate) {
|
||||||
up_pwm_servo_set_rate(new_servo_rate);
|
up_pwm_servo_set_rate(new_servo_rate);
|
||||||
system_state.servo_rate = new_servo_rate;
|
system_state.servo_rate = new_servo_rate;
|
||||||
|
@ -277,17 +279,21 @@ comms_handle_command(const void *buffer, size_t length)
|
||||||
case 0:
|
case 0:
|
||||||
POWER_ACC1(cmd->relay_state[i]);
|
POWER_ACC1(cmd->relay_state[i]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
POWER_ACC2(cmd->relay_state[i]);
|
POWER_ACC2(cmd->relay_state[i]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
POWER_RELAY1(cmd->relay_state[i]);
|
POWER_RELAY1(cmd->relay_state[i]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
POWER_RELAY2(cmd->relay_state[i]);
|
POWER_RELAY2(cmd->relay_state[i]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
system_state.relays[i] = cmd->relay_state[i];
|
system_state.relays[i] = cmd->relay_state[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -121,6 +121,7 @@ controls_main(void)
|
||||||
if (system_state.rc_channel_data[4] > RC_CHANNEL_HIGH_THRESH) {
|
if (system_state.rc_channel_data[4] > RC_CHANNEL_HIGH_THRESH) {
|
||||||
/* force manual input override */
|
/* force manual input override */
|
||||||
system_state.mixer_manual_override = true;
|
system_state.mixer_manual_override = true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
/* override not engaged, use FMU */
|
/* override not engaged, use FMU */
|
||||||
system_state.mixer_manual_override = false;
|
system_state.mixer_manual_override = false;
|
||||||
|
|
|
@ -159,6 +159,7 @@ safety_check_button(void *arg)
|
||||||
|
|
||||||
} else if (system_state.arm_ok) {
|
} else if (system_state.arm_ok) {
|
||||||
pattern = LED_PATTERN_FMU_ARMED;
|
pattern = LED_PATTERN_FMU_ARMED;
|
||||||
|
|
||||||
} else if (system_state.vector_flight_mode_ok) {
|
} else if (system_state.vector_flight_mode_ok) {
|
||||||
pattern = LED_PATTERN_VECTOR_FLIGHT_MODE_OK;
|
pattern = LED_PATTERN_VECTOR_FLIGHT_MODE_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,6 +88,7 @@ sbus_init(const char *device)
|
||||||
last_rx_time = hrt_absolute_time();
|
last_rx_time = hrt_absolute_time();
|
||||||
|
|
||||||
debug("S.Bus: ready");
|
debug("S.Bus: ready");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
debug("S.Bus: open failed");
|
debug("S.Bus: open failed");
|
||||||
}
|
}
|
||||||
|
@ -117,6 +118,7 @@ sbus_input(void)
|
||||||
* if we didn't drop bytes...
|
* if we didn't drop bytes...
|
||||||
*/
|
*/
|
||||||
now = hrt_absolute_time();
|
now = hrt_absolute_time();
|
||||||
|
|
||||||
if ((now - last_rx_time) > 3000) {
|
if ((now - last_rx_time) > 3000) {
|
||||||
if (partial_frame_count > 0) {
|
if (partial_frame_count > 0) {
|
||||||
sbus_frame_drops++;
|
sbus_frame_drops++;
|
||||||
|
@ -133,6 +135,7 @@ sbus_input(void)
|
||||||
/* if the read failed for any reason, just give up here */
|
/* if the read failed for any reason, just give up here */
|
||||||
if (ret < 1)
|
if (ret < 1)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
last_rx_time = now;
|
last_rx_time = now;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -236,6 +239,7 @@ sbus_decode(hrt_abstime frame_time)
|
||||||
value |= piece;
|
value |= piece;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* convert 0-2048 values to 1000-2000 ppm encoding in a very sloppy fashion */
|
/* convert 0-2048 values to 1000-2000 ppm encoding in a very sloppy fashion */
|
||||||
system_state.rc_channel_data[channel] = (value / 2) + 998;
|
system_state.rc_channel_data[channel] = (value / 2) + 998;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue