1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

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)

This commit is contained in:
Eric Price 2018-10-16 11:41:27 +02:00
parent a4e20499c0
commit 868d787912
2 changed files with 13 additions and 1 deletions

View File

@ -199,6 +199,18 @@ bool PIOS_USB_CheckAvailable(__attribute__((unused)) uint32_t id)
return transfer_possible;
}
/**
* This function returns wether a USB cable (5V pin) has been detected
* \return true: cable connected
* \return false: cable not detected (no cable or cable with no power)
*/
bool PIOS_USB_CableConnected(__attribute__((unused)) uint8_t id)
{
struct pios_usb_dev *usb_dev = (struct pios_usb_dev *)pios_usb_id;
return ((usb_dev->cfg->vsense.gpio->IDR & usb_dev->cfg->vsense.init.GPIO_Pin) != 0) ^ usb_dev->cfg->vsense_active_low;
}
/*
*
* Register a physical disconnection callback

View File

@ -82,7 +82,7 @@ int main()
// is 2.7 volts
check_bor();
USB_connected = PIOS_USB_CheckAvailable(0);
USB_connected = PIOS_USB_CableConnected(0);
if (PIOS_IAP_CheckRequest() == true) {
PIOS_DELAY_WaitmS(1000);