mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-17 02:52:12 +01:00
Merge remote-tracking branch 'origin/next' into Brian-PipXtreme-V2
This commit is contained in:
commit
8b98d48fc4
@ -28,6 +28,7 @@
|
||||
/* Bootloader Includes */
|
||||
#include <pios.h>
|
||||
#include <stdbool.h>
|
||||
#include "pios_board_info.h"
|
||||
|
||||
#define MAX_WRI_RETRYS 3
|
||||
/* Prototype of PIOS_Board_Init() function */
|
||||
@ -56,6 +57,31 @@ int main() {
|
||||
if ((0x08000000 + embedded_image_size) > base_address)
|
||||
error();
|
||||
///
|
||||
|
||||
/*
|
||||
* Make sure the bootloader we're carrying is for the same
|
||||
* board type and board revision as the one we're running on.
|
||||
*
|
||||
* Assume the bootloader in flash and the bootloader contained in
|
||||
* the updater both carry a board_info_blob at the end of the image.
|
||||
*/
|
||||
|
||||
/* Calculate how far the board_info_blob is from the beginning of the bootloader */
|
||||
uint32_t board_info_blob_offset = (uint32_t)&pios_board_info_blob - (uint32_t)0x08000000;
|
||||
|
||||
/* Use the same offset into our embedded bootloader image */
|
||||
struct pios_board_info * new_board_info_blob = (struct pios_board_info *)
|
||||
((uint32_t)embedded_image_start + board_info_blob_offset);
|
||||
|
||||
/* Compare the two board info blobs to make sure they're for the same HW revision */
|
||||
if ((pios_board_info_blob.magic != new_board_info_blob->magic) ||
|
||||
(pios_board_info_blob.board_type != new_board_info_blob->board_type) ||
|
||||
(pios_board_info_blob.board_rev != new_board_info_blob->board_rev)) {
|
||||
error();
|
||||
}
|
||||
|
||||
/* Embedded bootloader looks like it's the right one for this HW, proceed... */
|
||||
|
||||
FLASH_Unlock();
|
||||
|
||||
/// Bootloader memory space erase
|
||||
|
@ -74,7 +74,7 @@ int main() {
|
||||
PIOS_Board_Init();
|
||||
PIOS_IAP_Init();
|
||||
|
||||
USB_connected = PIOS_USB_CheckAvailable(0);
|
||||
USB_connected = PIOS_USB_CableConnected(0);
|
||||
|
||||
if (PIOS_IAP_CheckRequest() == TRUE) {
|
||||
PIOS_DELAY_WaitmS(1000);
|
||||
|
@ -40,7 +40,7 @@
|
||||
#if defined(PIOS_INCLUDE_USB_HID)
|
||||
|
||||
/* Rx/Tx status */
|
||||
static uint8_t transfer_possible = 0;
|
||||
static bool transfer_possible = false;
|
||||
|
||||
enum pios_usb_dev_magic {
|
||||
PIOS_USB_DEV_MAGIC = 0x17365904,
|
||||
@ -152,7 +152,7 @@ int32_t PIOS_USB_ChangeConnectionState(bool Connected)
|
||||
{
|
||||
// In all cases: re-initialise USB HID driver
|
||||
if (Connected) {
|
||||
transfer_possible = 1;
|
||||
transfer_possible = true;
|
||||
|
||||
//TODO: Check SetEPRxValid(ENDP1);
|
||||
|
||||
@ -161,7 +161,7 @@ int32_t PIOS_USB_ChangeConnectionState(bool Connected)
|
||||
#endif
|
||||
} else {
|
||||
// Cable disconnected: disable transfers
|
||||
transfer_possible = 0;
|
||||
transfer_possible = false;
|
||||
|
||||
#if defined(USB_LED_OFF)
|
||||
USB_LED_OFF; // turn the USB led off
|
||||
@ -207,22 +207,30 @@ int32_t PIOS_USB_Reenumerate()
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool PIOS_USB_CableConnected(uint8_t id)
|
||||
{
|
||||
struct pios_usb_dev * usb_dev = (struct pios_usb_dev *) pios_usb_com_id;
|
||||
|
||||
if (PIOS_USB_validate(usb_dev) != 0)
|
||||
return false;
|
||||
|
||||
return usb_dev->cfg->vsense.gpio->IDR & usb_dev->cfg->vsense.init.GPIO_Pin;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function returns the connection status of the USB HID interface
|
||||
* \return 1: interface available
|
||||
* \return 0: interface not available
|
||||
* \note Applications shouldn't call this function directly, instead please use \ref PIOS_COM layer functions
|
||||
*/
|
||||
uint32_t usb_found;
|
||||
bool PIOS_USB_CheckAvailable(uint8_t id)
|
||||
{
|
||||
struct pios_usb_dev * usb_dev = (struct pios_usb_dev *) pios_usb_com_id;
|
||||
|
||||
if(PIOS_USB_validate(usb_dev) != 0)
|
||||
return 0;
|
||||
if (PIOS_USB_validate(usb_dev) != 0)
|
||||
return false;
|
||||
|
||||
usb_found = (usb_dev->cfg->vsense.gpio->IDR & usb_dev->cfg->vsense.init.GPIO_Pin);
|
||||
return usb_found != 0 && transfer_possible ? 1 : 0;
|
||||
return PIOS_USB_CableConnected(id) && transfer_possible;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -35,6 +35,7 @@
|
||||
/* Global functions */
|
||||
extern int32_t PIOS_USB_Reenumerate();
|
||||
extern int32_t PIOS_USB_ChangeConnectionState(bool connected);
|
||||
extern bool PIOS_USB_CableConnected(uint8_t id);
|
||||
extern bool PIOS_USB_CheckAvailable(uint8_t id);
|
||||
|
||||
#endif /* PIOS_USB_H */
|
||||
|
Loading…
x
Reference in New Issue
Block a user