diff --git a/flight/PipXtreme/Makefile b/flight/PipXtreme/Makefile index 635d46b53..9ef5e9842 100644 --- a/flight/PipXtreme/Makefile +++ b/flight/PipXtreme/Makefile @@ -163,16 +163,16 @@ SRC += $(PIOSSTM32F10X)/pios_eeprom.c SRC += $(PIOSSTM32F10X)/pios_bl_helper.c # PIOS USB related files (seperated to make code maintenance more easy) -ifeq ($(USE_USB), YES) - SRC += $(PIOSSTM32F10X)/pios_usb.c - SRC += $(PIOSSTM32F10X)/pios_usbhook.c - SRC += $(PIOSSTM32F10X)/pios_usb_hid.c - SRC += $(PIOSSTM32F10X)/pios_usb_hid_istr.c - SRC += $(PIOSSTM32F10X)/pios_usb_hid_pwr.c - SRC += $(HOME_DIR)/pios_usb_board_data.c - SRC += $(PIOSCOMMON)/pios_usb_desc_hid_only.c - SRC += $(PIOSCOMMON)/pios_usb_util.c -endif +SRC += $(PIOSSTM32F10X)/pios_usb.c +SRC += $(PIOSSTM32F10X)/pios_usbhook.c +SRC += $(PIOSSTM32F10X)/pios_usb_hid.c +SRC += $(PIOSSTM32F10X)/pios_usb_cdc.c +SRC += $(PIOSSTM32F10X)/pios_usb_hid_istr.c +SRC += $(PIOSSTM32F10X)/pios_usb_hid_pwr.c +SRC += $(OPSYSTEM)/pios_usb_board_data.c +SRC += $(PIOSCOMMON)/pios_usb_desc_hid_cdc.c +SRC += $(PIOSCOMMON)/pios_usb_desc_hid_only.c +SRC += $(PIOSCOMMON)/pios_usb_util.c ## PIOS Hardware (Common) SRC += $(PIOSCOMMON)/pios_crc.c diff --git a/flight/PipXtreme/System/pios_board.c b/flight/PipXtreme/System/pios_board.c index 28c21f40b..ab53d7611 100644 --- a/flight/PipXtreme/System/pios_board.c +++ b/flight/PipXtreme/System/pios_board.c @@ -127,36 +127,37 @@ void PIOS_Board_Init(void) { /* Initialize board specific USB data */ PIOS_USB_BOARD_DATA_Init(); + + /* Flags to determine if various USB interfaces are advertised */ + bool usb_hid_present = false; bool usb_cdc_present = false; + #if defined(PIOS_INCLUDE_USB_CDC) - switch (pipxSettings.VCPConfig) - { - case PIPXSETTINGS_VCPCONFIG_SERIAL: - case PIPXSETTINGS_VCPCONFIG_DEBUG: - if (PIOS_USB_DESC_HID_CDC_Init()) { - PIOS_Assert(0); - } - usb_cdc_present = true; - break; - case PIPXSETTINGS_VCPCONFIG_DISABLED: - if (PIOS_USB_DESC_HID_ONLY_Init()) { - PIOS_Assert(0); - } - break; + if (PIOS_USB_DESC_HID_CDC_Init()) { + PIOS_Assert(0); } + usb_hid_present = true; + usb_cdc_present = true; #else if (PIOS_USB_DESC_HID_ONLY_Init()) { PIOS_Assert(0); } + usb_hid_present = true; #endif uint32_t pios_usb_id; PIOS_USB_Init(&pios_usb_id, &pios_usb_main_cfg); #if defined(PIOS_INCLUDE_USB_CDC) + if (!usb_cdc_present) { + /* Force VCP port function to disabled if we haven't advertised VCP in our USB descriptor */ + pipxSettings.VCPConfig = PIPXSETTINGS_VCPCONFIG_DISABLED; + } -#if defined(PIOS_INCLUDE_COM) - if(usb_cdc_present) + switch (pipxSettings.VCPConfig) + { + case PIPXSETTINGS_VCPCONFIG_SERIAL: + case PIPXSETTINGS_VCPCONFIG_DEBUG: { uint32_t pios_usb_cdc_id; if (PIOS_USB_CDC_Init(&pios_usb_cdc_id, &pios_usb_cdc_cfg, pios_usb_id)) { @@ -180,10 +181,12 @@ void PIOS_Board_Init(void) { pios_com_debug_id = pios_com_vcp_id; break; } + break; } -#endif /* PIOS_INCLUDE_COM */ - -#endif /* PIOS_INCLUDE_USB_CDC */ + case PIPXSETTINGS_VCPCONFIG_DISABLED: + break; + } +#endif #if defined(PIOS_INCLUDE_USB_HID) diff --git a/flight/board_hw_defs/pipxtreme/board_hw_defs.c b/flight/board_hw_defs/pipxtreme/board_hw_defs.c index e68154181..bb17bf1ca 100644 --- a/flight/board_hw_defs/pipxtreme/board_hw_defs.c +++ b/flight/board_hw_defs/pipxtreme/board_hw_defs.c @@ -504,7 +504,7 @@ static const struct pios_usb_cfg pios_usb_main_cfg = { #include const struct pios_usb_hid_cfg pios_usb_hid_cfg = { - .data_if = 0, + .data_if = 2, .data_rx_ep = 1, .data_tx_ep = 1, }; @@ -514,10 +514,10 @@ const struct pios_usb_hid_cfg pios_usb_hid_cfg = { #include const struct pios_usb_cdc_cfg pios_usb_cdc_cfg = { - .ctrl_if = 1, + .ctrl_if = 0, .ctrl_tx_ep = 2, - .data_if = 2, + .data_if = 1, .data_rx_ep = 3, .data_tx_ep = 3, };