Skip to content

Commit

Permalink
AP_Periph: add option to force enable CAN2
Browse files Browse the repository at this point in the history
  • Loading branch information
bugobliterator committed Oct 8, 2024
1 parent 4b7bcc7 commit ce8382e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion AP_Periph/AP_Periph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions AP_Periph/Parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand Down
4 changes: 3 additions & 1 deletion AP_Periph/Parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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() {}
};

Expand Down

0 comments on commit ce8382e

Please sign in to comment.