- [ardrone] daren's mag freeze fix, cleaned up acc. to suggestions

This commit is contained in:
Oswald Berthold
2014-07-03 10:44:32 +02:00
parent 4c8e8f271c
commit c536eb81f1
+7 -8
View File
@@ -288,23 +288,22 @@ static void mag_freeze_check(void) {
if (LastMagValue == navdata.mx) {
MagFreezeCounter++;
// re-initialize the serial port here, in paparazzi this should be ~3 seconds
// Re-initialize the serial port here, in paparazzi this should be ~150 ms
// considering it updates at 200 Hz
if (MagFreezeCounter > 100) { // rathern than 600
printf("Mag needs resetting, Values are frozen!!! %d , %d \n",LastMagValue, navdata.mx);
if (MagFreezeCounter > 30) {
printf("Mag needs resetting, Values are frozen!!! %d , %d \n", LastMagValue, navdata.mx);
printf("Setting GPIO 177 to reset PIC Navigation Board \n");
// stop acquisition
uint8_t cmd=0x02;
navdata_write(&cmd, 1);
// do the navboard reset via GPIOs
system("gpio 177 -d lo 0 &"); // GPIO used to reset PIC
system("gpio 177 -d lo 1 &");
// wait 20ms to retrieve data
for (int i=0;i<22;i++)
{
usleep(1000);
}
usleep(20000);
// restart acquisition
cmd = 0x01;