1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-18 08:54:15 +01:00

Merge remote-tracking branch 'origin/next' into brian/rfm22_FHSS

This commit is contained in:
Brian Webb 2013-03-12 01:36:34 +01:00
commit d5795b2118
2 changed files with 48 additions and 33 deletions

View File

@ -34,7 +34,7 @@
/* Prototype of PIOS_Board_Init() function */
extern void PIOS_Board_Init(void);
extern void FLASH_Download();
void error(int);
void error(int, int);
/* The ADDRESSES of the _binary_* symbols are the important
* data. This is non-intuitive for _binary_size where you
@ -47,7 +47,8 @@ const uint32_t * embedded_image_start = (uint32_t *) &(_binary_start);
const uint32_t * embedded_image_end = (uint32_t *) &(_binary_end);
const uint32_t embedded_image_size = (uint32_t) &(_binary_size);
int main() {
int main()
{
PIOS_SYS_Init();
PIOS_Board_Init();
@ -58,7 +59,7 @@ int main() {
/// Self overwrite check
uint32_t base_address = SCB->VTOR;
if ((0x08000000 + embedded_image_size) > base_address)
error(PIOS_LED_HEARTBEAT);
error(PIOS_LED_HEARTBEAT, 1);
///
/*
@ -70,7 +71,7 @@ int main() {
*/
/* 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;
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 *)
@ -80,7 +81,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(PIOS_LED_HEARTBEAT);
error(PIOS_LED_HEARTBEAT, 2);
}
/* Embedded bootloader looks like it's the right one for this HW, proceed... */
@ -108,30 +109,30 @@ int main() {
}
if (fail == true)
error(PIOS_LED_HEARTBEAT);
error(PIOS_LED_HEARTBEAT, 3);
///
/// Bootloader programing
for (uint32_t offset = 0; offset < embedded_image_size/sizeof(uint32_t); ++offset) {
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])
== FLASH_COMPLETE) ? true : false;
== FLASH_COMPLETE) ? true : false;
}
}
if (result == false)
error(PIOS_LED_HEARTBEAT);
error(PIOS_LED_HEARTBEAT, 4);
}
///
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);
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
@ -145,11 +146,22 @@ int main() {
}
void error(int led) {
void error(int led, int code)
{
for (;;) {
PIOS_LED_On(led);
PIOS_DELAY_WaitmS(500);
PIOS_LED_Off(led);
PIOS_DELAY_WaitmS(500);
PIOS_DELAY_WaitmS(1000);
for (int x = 0; x < code; x++) {
PIOS_LED_On(led);
PIOS_DELAY_WaitmS(200);
PIOS_LED_Off(led);
PIOS_DELAY_WaitmS(1000);
}
PIOS_DELAY_WaitmS(1000);
for (int x = 0; x < 10; x++) {
PIOS_LED_On(led);
PIOS_DELAY_WaitmS(200);
PIOS_LED_Off(led);
PIOS_DELAY_WaitmS(200);
}
}
}
}

View File

@ -91,6 +91,7 @@ using namespace Core;
using namespace Core::Internal;
static const char *uriListMimeFormatC = "text/uri-list";
static const char *DEFAULT_CONFIG_FILENAME = "OpenPilotGCS.xml";
enum { debugMainWindow = 0 };
@ -267,7 +268,6 @@ void MainWindow::modeChanged(Core::IMode */*mode*/)
void MainWindow::extensionsInitialized()
{
QSettings *qs = m_settings;
QSettings *settings;
QString commandLine;
if ( ! qs->allKeys().count() ) {
foreach(QString str, qApp->arguments()) {
@ -288,28 +288,31 @@ void MainWindow::extensionsInitialized()
#endif
directory.cd("default_configurations");
qDebug() << "Looking for default config files in: " + directory.absolutePath();
bool showDialog = true;
qDebug() << "Looking for configuration files in:" << directory.absolutePath();
QString filename;
if(!commandLine.isEmpty()) {
if(QFile::exists(directory.absolutePath() + QDir::separator()+commandLine)) {
filename = directory.absolutePath() + QDir::separator()+commandLine;
qDebug() << "Load configuration from command line";
settings = new QSettings(filename, XmlConfig::XmlSettingsFormat);
showDialog = false;
}
if(!commandLine.isEmpty() && QFile::exists(directory.absolutePath() + QDir::separator() + commandLine)) {
filename = directory.absolutePath() + QDir::separator() + commandLine;
qDebug() << "Configuration file" << filename << "specified on command line will be loaded.";
}
if(showDialog) {
else if(QFile::exists(directory.absolutePath() + QDir::separator() + DEFAULT_CONFIG_FILENAME)) {
filename = directory.absolutePath() + QDir::separator() + DEFAULT_CONFIG_FILENAME;
qDebug() << "Default configuration file" << filename << "will be loaded.";
}
else {
qDebug() << "Default configuration file " << directory.absolutePath() << QDir::separator() << DEFAULT_CONFIG_FILENAME << "was not found.";
importSettings *dialog = new importSettings(this);
dialog->loadFiles(directory.absolutePath());
dialog->exec();
filename = dialog->choosenConfig();
settings = new QSettings(filename, XmlConfig::XmlSettingsFormat);
delete dialog;
qDebug() << "Configuration file" << filename << "was selected and will be loaded.";
}
qs = settings;
qDebug() << "Load default config from resource " << filename;
qs = new QSettings(filename, XmlConfig::XmlSettingsFormat);
qDebug() << "Configuration file" << filename << "was loaded.";
}
qs->beginGroup("General");
m_config_description=qs->value("Description", "none").toString();
m_config_details=qs->value("Details", "none").toString();