mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-01 09:24:10 +01:00
Merge remote-tracking branch 'origin/stac/leds-in-bu-again' into next
This commit is contained in:
commit
dbd4d0fe1d
@ -34,7 +34,7 @@
|
||||
/* Prototype of PIOS_Board_Init() function */
|
||||
extern void PIOS_Board_Init(void);
|
||||
extern void FLASH_Download();
|
||||
void error(void);
|
||||
void error(int);
|
||||
|
||||
/* The ADDRESSES of the _binary_* symbols are the important
|
||||
* data. This is non-intuitive for _binary_size where you
|
||||
@ -51,11 +51,14 @@ int main() {
|
||||
|
||||
PIOS_SYS_Init();
|
||||
PIOS_Board_Init();
|
||||
PIOS_LED_On(PIOS_LED_HEARTBEAT);
|
||||
PIOS_DELAY_WaitmS(3000);
|
||||
PIOS_LED_Off(PIOS_LED_HEARTBEAT);
|
||||
|
||||
/// Self overwrite check
|
||||
uint32_t base_address = SCB->VTOR;
|
||||
if ((0x08000000 + embedded_image_size) > base_address)
|
||||
error();
|
||||
error(PIOS_LED_HEARTBEAT);
|
||||
///
|
||||
|
||||
/*
|
||||
@ -77,7 +80,7 @@ int main() {
|
||||
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();
|
||||
error(PIOS_LED_HEARTBEAT);
|
||||
}
|
||||
|
||||
/* Embedded bootloader looks like it's the right one for this HW, proceed... */
|
||||
@ -105,7 +108,7 @@ int main() {
|
||||
}
|
||||
|
||||
if (fail == true)
|
||||
error();
|
||||
error(PIOS_LED_HEARTBEAT);
|
||||
|
||||
|
||||
///
|
||||
@ -113,6 +116,7 @@ int main() {
|
||||
/// Bootloader programing
|
||||
for (uint32_t offset = 0; offset < embedded_image_size/sizeof(uint32_t); ++offset) {
|
||||
bool result = false;
|
||||
PIOS_LED_Toggle(PIOS_LED_HEARTBEAT);
|
||||
for (uint8_t retry = 0; retry < MAX_WRI_RETRYS; ++retry) {
|
||||
if (result == false) {
|
||||
result = (FLASH_ProgramWord(0x08000000 + (offset * 4), embedded_image_start[offset])
|
||||
@ -120,9 +124,15 @@ int main() {
|
||||
}
|
||||
}
|
||||
if (result == false)
|
||||
error();
|
||||
error(PIOS_LED_HEARTBEAT);
|
||||
}
|
||||
///
|
||||
for (uint8_t x = 0; x < 3; ++x) {
|
||||
PIOS_LED_On(PIOS_LED_HEARTBEAT);
|
||||
PIOS_DELAY_WaitmS(1000);
|
||||
PIOS_LED_Off(PIOS_LED_HEARTBEAT);
|
||||
PIOS_DELAY_WaitmS(1000);
|
||||
}
|
||||
|
||||
/// Invalidate the bootloader updater so we won't run
|
||||
/// the update again on the next power cycle.
|
||||
@ -135,7 +145,11 @@ int main() {
|
||||
|
||||
}
|
||||
|
||||
void error(void) {
|
||||
void error(int led) {
|
||||
for (;;) {
|
||||
PIOS_LED_On(led);
|
||||
PIOS_DELAY_WaitmS(500);
|
||||
PIOS_LED_Off(led);
|
||||
PIOS_DELAY_WaitmS(500);
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,8 @@
|
||||
#include <pios.h>
|
||||
|
||||
void PIOS_Board_Init(void) {
|
||||
const struct pios_board_info * bdinfo = &pios_board_info_blob;
|
||||
|
||||
/* Enable Prefetch Buffer */
|
||||
FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
|
||||
|
||||
@ -42,8 +44,15 @@ void PIOS_Board_Init(void) {
|
||||
FLASH_SetLatency(FLASH_Latency_2);
|
||||
|
||||
/* Delay system */
|
||||
PIOS_DELAY_Init();
|
||||
|
||||
PIOS_DELAY_Init();
|
||||
|
||||
/* LEDs */
|
||||
#if defined(PIOS_INCLUDE_LED)
|
||||
const struct pios_led_cfg * led_cfg = PIOS_BOARD_HW_DEFS_GetLedCfg(bdinfo->board_rev);
|
||||
PIOS_Assert(led_cfg);
|
||||
PIOS_LED_Init(led_cfg);
|
||||
#endif /* PIOS_INCLUDE_LED */
|
||||
|
||||
/* Initialize the PiOS library */
|
||||
PIOS_GPIO_Init();
|
||||
}
|
||||
|
@ -62,17 +62,9 @@ void PIOS_Board_Init(void) {
|
||||
const struct pios_board_info * bdinfo = &pios_board_info_blob;
|
||||
|
||||
#if defined(PIOS_INCLUDE_LED)
|
||||
switch(bdinfo->board_rev) {
|
||||
case 0x01: // Revision 1
|
||||
PIOS_LED_Init(&pios_led_cfg_cc);
|
||||
break;
|
||||
case 0x02: // Revision 2
|
||||
GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);
|
||||
PIOS_LED_Init(&pios_led_cfg_cc3d);
|
||||
break;
|
||||
default:
|
||||
PIOS_Assert(0);
|
||||
}
|
||||
const struct pios_led_cfg * led_cfg = PIOS_BOARD_HW_DEFS_GetLedCfg(bdinfo->board_rev);
|
||||
PIOS_Assert(led_cfg);
|
||||
PIOS_LED_Init(led_cfg);
|
||||
#endif /* PIOS_INCLUDE_LED */
|
||||
|
||||
#if defined(PIOS_INCLUDE_USB)
|
||||
@ -84,10 +76,10 @@ void PIOS_Board_Init(void) {
|
||||
|
||||
uint32_t pios_usb_id;
|
||||
switch(bdinfo->board_rev) {
|
||||
case 0x01: // Revision 1
|
||||
case BOARD_REVISION_CC:
|
||||
PIOS_USB_Init(&pios_usb_id, &pios_usb_main_cfg_cc);
|
||||
break;
|
||||
case 0x02: // Revision 2
|
||||
case BOARD_REVISION_CC3D:
|
||||
PIOS_USB_Init(&pios_usb_id, &pios_usb_main_cfg_cc3d);
|
||||
break;
|
||||
default:
|
||||
|
@ -156,29 +156,21 @@ void PIOS_Board_Init(void) {
|
||||
const struct pios_board_info * bdinfo = &pios_board_info_blob;
|
||||
|
||||
#if defined(PIOS_INCLUDE_LED)
|
||||
switch(bdinfo->board_rev) {
|
||||
case 0x01: // Revision 1
|
||||
PIOS_LED_Init(&pios_led_cfg_cc);
|
||||
break;
|
||||
case 0x02: // Revision 2
|
||||
GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);
|
||||
PIOS_LED_Init(&pios_led_cfg_cc3d);
|
||||
break;
|
||||
default:
|
||||
PIOS_Assert(0);
|
||||
}
|
||||
const struct pios_led_cfg * led_cfg = PIOS_BOARD_HW_DEFS_GetLedCfg(bdinfo->board_rev);
|
||||
PIOS_Assert(led_cfg);
|
||||
PIOS_LED_Init(led_cfg);
|
||||
#endif /* PIOS_INCLUDE_LED */
|
||||
|
||||
#if defined(PIOS_INCLUDE_SPI)
|
||||
/* Set up the SPI interface to the serial flash */
|
||||
|
||||
switch(bdinfo->board_rev) {
|
||||
case 0x01: // Revision 1
|
||||
case BOARD_REVISION_CC:
|
||||
if (PIOS_SPI_Init(&pios_spi_flash_accel_id, &pios_spi_flash_accel_cfg_cc)) {
|
||||
PIOS_Assert(0);
|
||||
}
|
||||
break;
|
||||
case 0x02: // Revision 2
|
||||
case BOARD_REVISION_CC3D:
|
||||
if (PIOS_SPI_Init(&pios_spi_flash_accel_id, &pios_spi_flash_accel_cfg_cc3d)) {
|
||||
PIOS_Assert(0);
|
||||
}
|
||||
@ -190,11 +182,11 @@ void PIOS_Board_Init(void) {
|
||||
#endif
|
||||
|
||||
switch(bdinfo->board_rev) {
|
||||
case 0x01: // Revision 1
|
||||
case BOARD_REVISION_CC:
|
||||
PIOS_Flash_Jedec_Init(pios_spi_flash_accel_id, 1, &flash_w25x_cfg);
|
||||
PIOS_FLASHFS_Init(&flashfs_w25x_cfg);
|
||||
break;
|
||||
case 0x02: // Revision 2
|
||||
case BOARD_REVISION_CC3D:
|
||||
PIOS_Flash_Jedec_Init(pios_spi_flash_accel_id, 0, &flash_m25p_cfg);
|
||||
PIOS_FLASHFS_Init(&flashfs_m25p_cfg);
|
||||
break;
|
||||
@ -267,10 +259,10 @@ void PIOS_Board_Init(void) {
|
||||
uint32_t pios_usb_id;
|
||||
|
||||
switch(bdinfo->board_rev) {
|
||||
case 0x01: // Revision 1
|
||||
case BOARD_REVISION_CC:
|
||||
PIOS_USB_Init(&pios_usb_id, &pios_usb_main_cfg_cc);
|
||||
break;
|
||||
case 0x02: // Revision 2
|
||||
case BOARD_REVISION_CC3D:
|
||||
PIOS_USB_Init(&pios_usb_id, &pios_usb_main_cfg_cc3d);
|
||||
break;
|
||||
default:
|
||||
@ -690,7 +682,7 @@ void PIOS_Board_Init(void) {
|
||||
#endif /* PIOS_DEBUG_ENABLE_DEBUG_PINS */
|
||||
|
||||
switch(bdinfo->board_rev) {
|
||||
case 0x01:
|
||||
case BOARD_REVISION_CC:
|
||||
// Revision 1 with invensense gyros, start the ADC
|
||||
#if defined(PIOS_INCLUDE_ADC)
|
||||
PIOS_ADC_Init(&pios_adc_cfg);
|
||||
@ -699,7 +691,7 @@ void PIOS_Board_Init(void) {
|
||||
PIOS_ADXL345_Init(pios_spi_flash_accel_id, 0);
|
||||
#endif
|
||||
break;
|
||||
case 0x02:
|
||||
case BOARD_REVISION_CC3D:
|
||||
// Revision 2 with L3GD20 gyros, start a SPI interface and connect to it
|
||||
GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);
|
||||
|
||||
|
@ -1,3 +1,8 @@
|
||||
#ifndef PIOS_BOARD_INFO_H
|
||||
#define PIOS_BOARD_INFO_H
|
||||
|
||||
#include <stdint.h> /* uint* */
|
||||
|
||||
#define PIOS_BOARD_INFO_BLOB_MAGIC 0xBDBDBDBD
|
||||
|
||||
struct pios_board_info {
|
||||
@ -15,3 +20,5 @@ struct pios_board_info {
|
||||
} __attribute__((packed));
|
||||
|
||||
extern const struct pios_board_info pios_board_info_blob;
|
||||
|
||||
#endif /* PIOS_BOARD_INFO_H */
|
||||
|
@ -27,6 +27,10 @@
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include <pios_config.h>
|
||||
#include <pios_board_info.h>
|
||||
|
||||
#define BOARD_REVISION_CC 1
|
||||
#define BOARD_REVISION_CC3D 2
|
||||
|
||||
#if defined(PIOS_INCLUDE_LED)
|
||||
|
||||
@ -59,6 +63,7 @@ static const struct pios_led pios_leds_cc3d[] = {
|
||||
.GPIO_Speed = GPIO_Speed_50MHz,
|
||||
},
|
||||
},
|
||||
.remap = GPIO_Remap_SWJ_JTAGDisable,
|
||||
},
|
||||
};
|
||||
|
||||
@ -67,6 +72,15 @@ static const struct pios_led_cfg pios_led_cfg_cc3d = {
|
||||
.num_leds = NELEMENTS(pios_leds_cc3d),
|
||||
};
|
||||
|
||||
const struct pios_led_cfg * PIOS_BOARD_HW_DEFS_GetLedCfg (uint32_t board_revision)
|
||||
{
|
||||
switch (board_revision) {
|
||||
case BOARD_REVISION_CC: return &pios_led_cfg_cc;
|
||||
case BOARD_REVISION_CC3D: return &pios_led_cfg_cc3d;
|
||||
default: return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* PIOS_INCLUDE_LED */
|
||||
|
||||
#if defined(PIOS_INCLUDE_SPI)
|
||||
|
Loading…
Reference in New Issue
Block a user