Skip to content

Commit 868d787

Browse files
committed
LP-602 Fix regression of bootloader which checks for USB availability without initialising it, so it really needs to check if the cable is present (gpio check)
1 parent a4e2049 commit 868d787

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

flight/pios/stm32f4xx/pios_usb.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,18 @@ bool PIOS_USB_CheckAvailable(__attribute__((unused)) uint32_t id)
199199
return transfer_possible;
200200
}
201201

202+
/**
203+
* This function returns wether a USB cable (5V pin) has been detected
204+
* \return true: cable connected
205+
* \return false: cable not detected (no cable or cable with no power)
206+
*/
207+
bool PIOS_USB_CableConnected(__attribute__((unused)) uint8_t id)
208+
{
209+
struct pios_usb_dev *usb_dev = (struct pios_usb_dev *)pios_usb_id;
210+
211+
return ((usb_dev->cfg->vsense.gpio->IDR & usb_dev->cfg->vsense.init.GPIO_Pin) != 0) ^ usb_dev->cfg->vsense_active_low;
212+
}
213+
202214
/*
203215
*
204216
* Register a physical disconnection callback

flight/targets/boards/revolution/bootloader/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ int main()
8282
// is 2.7 volts
8383
check_bor();
8484

85-
USB_connected = PIOS_USB_CheckAvailable(0);
85+
USB_connected = PIOS_USB_CableConnected(0);
8686

8787
if (PIOS_IAP_CheckRequest() == true) {
8888
PIOS_DELAY_WaitmS(1000);

0 commit comments

Comments
 (0)