HAL_ChibiOS: use EXPECT_DELAY() macro

This commit is contained in:
Andrew Tridgell 2019-05-11 18:18:21 +10:00
parent ecc6f15dc0
commit 1b8cbfc6a4

View File

@ -230,12 +230,11 @@ bool Util::flash_bootloader()
uint32_t fw_size;
const char *fw_name = "bootloader.bin";
hal.scheduler->expect_delay_ms(11000);
EXPECT_DELAY(hal, 11000);
uint8_t *fw = AP_ROMFS::find_decompress(fw_name, fw_size);
if (!fw) {
hal.console->printf("failed to find %s\n", fw_name);
hal.scheduler->expect_delay_ms(0);
return false;
}
@ -243,7 +242,6 @@ bool Util::flash_bootloader()
if (!memcmp(fw, (const void*)addr, fw_size)) {
hal.console->printf("Bootloader up-to-date\n");
free(fw);
hal.scheduler->expect_delay_ms(0);
return true;
}
@ -251,7 +249,6 @@ bool Util::flash_bootloader()
if (!hal.flash->erasepage(0)) {
hal.console->printf("Erase failed\n");
free(fw);
hal.scheduler->expect_delay_ms(0);
return false;
}
hal.console->printf("Flashing %s @%08x\n", fw_name, (unsigned int)addr);
@ -267,13 +264,11 @@ bool Util::flash_bootloader()
}
hal.console->printf("Flash OK\n");
free(fw);
hal.scheduler->expect_delay_ms(0);
return true;
}
hal.console->printf("Flash failed after %u attempts\n", max_attempts);
free(fw);
hal.scheduler->expect_delay_ms(0);
return false;
}
#endif //#ifndef HAL_NO_FLASH_SUPPORT