1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

Added support for an active low USB vsense line.

This commit is contained in:
Brian Webb 2013-05-14 20:37:13 -07:00
parent eedfb7081c
commit 156109bb88
8 changed files with 17 additions and 9 deletions

View File

@ -37,6 +37,7 @@
struct pios_usb_cfg {
struct stm32_irq irq;
struct stm32_gpio vsense;
bool vsense_active_low;
};
extern int32_t PIOS_USB_Init(uint32_t * usb_id, const struct pios_usb_cfg * cfg);

View File

@ -215,7 +215,7 @@ bool PIOS_USB_CableConnected(__attribute__((unused)) uint8_t id)
if (PIOS_USB_validate(usb_dev) != 0)
return false;
return usb_dev->cfg->vsense.gpio->IDR & usb_dev->cfg->vsense.init.GPIO_Pin;
return ((usb_dev->cfg->vsense.gpio->IDR & usb_dev->cfg->vsense.init.GPIO_Pin) != 0) ^ usb_dev->cfg->vsense_active_low;
}
/**

View File

@ -162,7 +162,7 @@ bool PIOS_USB_CheckAvailable(__attribute__((unused)) uint32_t id)
if(!PIOS_USB_validate(usb_dev))
return false;
usb_found = (usb_dev->cfg->vsense.gpio->IDR & usb_dev->cfg->vsense.init.GPIO_Pin);
usb_found = ((usb_dev->cfg->vsense.gpio->IDR & usb_dev->cfg->vsense.init.GPIO_Pin) != 0) ^ usb_dev->cfg->vsense_active_low;
return usb_found;
return usb_found != 0 && transfer_possible ? 1 : 0;
}

View File

@ -1431,7 +1431,8 @@ static const struct pios_usb_cfg pios_usb_main_cfg_cc = {
.GPIO_Speed = GPIO_Speed_10MHz,
.GPIO_Mode = GPIO_Mode_AF_OD,
},
}
},
.vsense_active_low = false
};
static const struct pios_usb_cfg pios_usb_main_cfg_cc3d = {
@ -1450,7 +1451,8 @@ static const struct pios_usb_cfg pios_usb_main_cfg_cc3d = {
.GPIO_Speed = GPIO_Speed_10MHz,
.GPIO_Mode = GPIO_Mode_AF_OD,
},
}
},
.vsense_active_low = false
};
#include "pios_usb_board_data_priv.h"

View File

@ -640,7 +640,8 @@ static const struct pios_usb_cfg pios_usb_main_cfg = {
.GPIO_Speed = GPIO_Speed_10MHz,
.GPIO_Mode = GPIO_Mode_AF_OD,
},
}
},
.vsense_active_low = false
};
#include "pios_usb_board_data_priv.h"

View File

@ -502,7 +502,8 @@ static const struct pios_usb_cfg pios_usb_main_cfg = {
.GPIO_Mode = GPIO_Mode_IN,
.GPIO_OType = GPIO_OType_OD,
},
}
},
.vsense_active_low = false
};
#include "pios_usb_board_data_priv.h"

View File

@ -1837,7 +1837,8 @@ static const struct pios_usb_cfg pios_usb_main_rm1_cfg = {
.GPIO_Mode = GPIO_Mode_IN,
.GPIO_OType = GPIO_OType_OD,
},
}
},
.vsense_active_low = false
};
static const struct pios_usb_cfg pios_usb_main_rm2_cfg = {
@ -1857,7 +1858,8 @@ static const struct pios_usb_cfg pios_usb_main_rm2_cfg = {
.GPIO_Mode = GPIO_Mode_IN,
.GPIO_OType = GPIO_OType_OD,
},
}
},
.vsense_active_low = false
};
const struct pios_usb_cfg * PIOS_BOARD_HW_DEFS_GetUsbCfg (uint32_t board_revision)

View File

@ -2003,7 +2003,8 @@ static const struct pios_usb_cfg pios_usb_main_cfg = {
.GPIO_Mode = GPIO_Mode_IN,
.GPIO_OType = GPIO_OType_OD,
},
}
},
.vsense_active_low = false
};
#include "pios_usb_board_data_priv.h"