diff --git a/AP_Periph/AP_Periph.cpp b/AP_Periph/AP_Periph.cpp index b81add1..d2d3ef2 100644 --- a/AP_Periph/AP_Periph.cpp +++ b/AP_Periph/AP_Periph.cpp @@ -91,7 +91,7 @@ void AP_Periph_FW::init() // sleep for 2ms to fetch the VBUS voltage hal.scheduler->delay(2); - if (vbus_voltage_source->voltage_latest() < 4.0f) { + if ((vbus_voltage_source->voltage_latest() < 4.0f) || g.can2_force_en) { // we are not connected over USB, disable USB msdStop(&USBMSD1); usbDisconnectBus(&USBD2); diff --git a/AP_Periph/Parameters.cpp b/AP_Periph/Parameters.cpp index 0878c5d..898fbbf 100644 --- a/AP_Periph/Parameters.cpp +++ b/AP_Periph/Parameters.cpp @@ -218,6 +218,14 @@ const AP_Param::Info AP_Periph_FW::var_info[] = { GOBJECT(gps_rover, "ROVER", GPS_Rover), #endif +#ifdef HAL_USB_VBUS_SENS_CHAN + // @Param: CAN2_FORCE_EN + // @DisplayName: Force CAN2 enable + // @Description: Force CAN2 enable + // @Values: 0:Disabled, 1:Enabled + // @User: Standard + GSCALAR(can2_force_en, "CAN2_FORCE_EN", 0), +#endif AP_VAREND }; diff --git a/AP_Periph/Parameters.h b/AP_Periph/Parameters.h index 99dc90a..1b7e12b 100644 --- a/AP_Periph/Parameters.h +++ b/AP_Periph/Parameters.h @@ -59,7 +59,8 @@ class Parameters { k_param_imu, k_param_gps_safeboot, k_param_gps_rover, - k_param_gps_type + k_param_gps_type, + k_param_can2_force_en, }; AP_Int16 format_version; @@ -107,6 +108,7 @@ class Parameters { AP_Int16 imu_sample_rate; AP_Int8 gps_safeboot; AP_Int8 gps_type; + AP_Int8 can2_force_en; Parameters() {} };