AP_BoardConfig: added BRD_CAN_ENABLE option

this allows uavcan to be enabled/disabled at boot. When it is disabled
we save about 25k of memory, allowing for more options for things like
multiple EKF
This commit is contained in:
Andrew Tridgell 2015-11-06 10:23:37 +11:00
parent e9c6702269
commit c334bd0ddf
2 changed files with 26 additions and 0 deletions

View File

@ -75,6 +75,7 @@ const AP_Param::GroupInfo AP_BoardConfig::var_info[] = {
// @Description: Enabling this option on a Pixhawk enables SBUS servo output from the SBUS output connector // @Description: Enabling this option on a Pixhawk enables SBUS servo output from the SBUS output connector
// @Values: 0:Disabled,1:Enabled // @Values: 0:Disabled,1:Enabled
AP_GROUPINFO("SBUS_OUT", 4, AP_BoardConfig, _sbus_out_enable, 0), AP_GROUPINFO("SBUS_OUT", 4, AP_BoardConfig, _sbus_out_enable, 0),
#elif CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN #elif CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN
#endif #endif
@ -85,9 +86,21 @@ const AP_Param::GroupInfo AP_BoardConfig::var_info[] = {
// @User: Standard // @User: Standard
AP_GROUPINFO("SERIAL_NUM", 5, AP_BoardConfig, vehicleSerialNumber, 0), AP_GROUPINFO("SERIAL_NUM", 5, AP_BoardConfig, vehicleSerialNumber, 0),
#if CONFIG_HAL_BOARD == HAL_BOARD_PX4
// @Param: CAN_ENABLE
// @DisplayName: Enable use of UAVCAN devices
// @Description: Enabling this option on a Pixhawk enables UAVCAN devices. Note that this uses about 25k of memory
// @Values: 0:Disabled,1:Enabled
AP_GROUPINFO("CAN_ENABLE", 6, AP_BoardConfig, _can_enable, 0),
#endif
AP_GROUPEND AP_GROUPEND
}; };
#if CONFIG_HAL_BOARD == HAL_BOARD_PX4
extern "C" int uavcan_main(int argc, const char *argv[]);
#endif
void AP_BoardConfig::init() void AP_BoardConfig::init()
{ {
#if CONFIG_HAL_BOARD == HAL_BOARD_PX4 #if CONFIG_HAL_BOARD == HAL_BOARD_PX4
@ -127,6 +140,18 @@ void AP_BoardConfig::init()
close(fd); close(fd);
} }
} }
if (_can_enable == 1) {
const char *args[] = { "uavcan", "start", NULL };
int ret = uavcan_main(3, args);
if (ret != 0) {
hal.console->printf("UAVCAN: failed to start\n");
} else {
hal.console->printf("UAVCAN: started\n");
// give some time for CAN bus initialisation
hal.scheduler->delay(500);
}
}
#elif CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN #elif CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN
/* configure the VRBRAIN driver for the right number of PWMs */ /* configure the VRBRAIN driver for the right number of PWMs */

View File

@ -29,6 +29,7 @@ private:
AP_Int8 _ser2_rtscts; AP_Int8 _ser2_rtscts;
AP_Int8 _safety_enable; AP_Int8 _safety_enable;
AP_Int8 _sbus_out_enable; AP_Int8 _sbus_out_enable;
AP_Int8 _can_enable;
#endif #endif
#if CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN #if CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN