AP_BoardConfig: added px4io auto-update to AP_BoardConfig

This commit is contained in:
Andrew Tridgell 2016-11-03 18:15:45 +11:00
parent 7e803df221
commit b9e1490740
2 changed files with 70 additions and 5 deletions

View File

@ -101,6 +101,8 @@ private:
void px4_setup_canbus(void); void px4_setup_canbus(void);
void px4_setup_drivers(void); void px4_setup_drivers(void);
void px4_setup_peripherals(void); void px4_setup_peripherals(void);
void px4_setup_px4io(void);
void px4_tone_alarm(const char *tone_string);
void px4_sensor_error(const char *reason); void px4_sensor_error(const char *reason);
#if CONFIG_HAL_BOARD == HAL_BOARD_PX4 #if CONFIG_HAL_BOARD == HAL_BOARD_PX4

View File

@ -53,6 +53,7 @@ extern "C" {
int fmu_main(int, char **); int fmu_main(int, char **);
int px4io_main(int, char **); int px4io_main(int, char **);
int adc_main(int, char **); int adc_main(int, char **);
int tone_alarm_main(int, char **);
}; };
@ -741,6 +742,72 @@ void AP_BoardConfig::px4_setup_drivers(void)
hal.scheduler->delay(1000); hal.scheduler->delay(1000);
} }
/*
play a tune
*/
void AP_BoardConfig::px4_tone_alarm(const char *tone_string)
{
px4_start_driver(tone_alarm_main, "tone_alarm", tone_string);
}
/*
setup px4io, possibly updating firmware
*/
void AP_BoardConfig::px4_setup_px4io(void)
{
if (px4_start_driver(px4io_main, "px4io", "start norc")) {
printf("px4io started OK\n");
} else {
// might be in bootloader mode if user held down safety switch
// at power on
printf("Loading /etc/px4io/px4io.bin\n");
px4_tone_alarm("MBABGP");
if (px4_start_driver(px4io_main, "px4io", "update /etc/px4io/px4io.bin")) {
printf("upgraded PX4IO firmware OK\n");
px4_tone_alarm("MSPAA");
} else {
printf("Failed to upgrade PX4IO firmware\n");
px4_tone_alarm("MNGGG");
}
hal.scheduler->delay(1000);
if (px4_start_driver(px4io_main, "px4io", "start norc")) {
printf("px4io started OK\n");
} else {
px4_sensor_error("px4io start failed");
}
}
/*
see if we need to update px4io firmware
*/
if (px4_start_driver(px4io_main, "px4io", "checkcrc /etc/px4io/px4io.bin")) {
printf("PX4IO CRC OK\n");
} else {
printf("PX4IO CRC failure\n");
px4_tone_alarm("MBABGP");
if (px4_start_driver(px4io_main, "px4io", "safety_on")) {
printf("PX4IO disarm OK\n");
} else {
printf("PX4IO disarm failed\n");
}
hal.scheduler->delay(1000);
if (px4_start_driver(px4io_main, "px4io", "forceupdate 14662 /etc/px4io/px4io.bin")) {
hal.scheduler->delay(1000);
if (px4_start_driver(px4io_main, "px4io", "start norc")) {
printf("px4io restart OK\n");
px4_tone_alarm("MSPAA");
} else {
px4_tone_alarm("MNGGG");
px4_sensor_error("PX4IO restart failed");
}
} else {
printf("PX4IO update failed\n");
px4_tone_alarm("MNGGG");
}
}
}
/* /*
setup required peripherals like adc, rcinput and rcoutput setup required peripherals like adc, rcinput and rcoutput
*/ */
@ -755,11 +822,7 @@ void AP_BoardConfig::px4_setup_peripherals(void)
} }
#ifndef CONFIG_ARCH_BOARD_PX4FMU_V4 #ifndef CONFIG_ARCH_BOARD_PX4FMU_V4
if (px4_start_driver(px4io_main, "px4io", "start norc")) { px4_setup_px4io();
printf("px4io started OK\n");
} else {
px4_sensor_error("px4io start failed found");
}
#endif #endif
#ifdef CONFIG_ARCH_BOARD_PX4FMU_V1 #ifdef CONFIG_ARCH_BOARD_PX4FMU_V1