From 8b15fdd88be64bfc73384406c8e89ba1b7c0fe4e Mon Sep 17 00:00:00 2001 From: James Cotton Date: Thu, 26 Jan 2012 11:26:19 -0600 Subject: [PATCH] Flash: Add a vTaskDelay when waiting for flash operations to complete to prevent blocking the bus from accels --- flight/PiOS/Common/pios_flash_jedec.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/flight/PiOS/Common/pios_flash_jedec.c b/flight/PiOS/Common/pios_flash_jedec.c index 690b22bb5..675fc51c8 100644 --- a/flight/PiOS/Common/pios_flash_jedec.c +++ b/flight/PiOS/Common/pios_flash_jedec.c @@ -257,7 +257,8 @@ int32_t PIOS_Flash_Jedec_EraseSector(uint32_t addr) PIOS_Flash_Jedec_ReleaseBus(); // Keep polling when bus is busy too - while(PIOS_Flash_Jedec_Busy() != 0); + while(PIOS_Flash_Jedec_Busy() != 0) + vTaskDelay(1); return 0; } @@ -288,7 +289,8 @@ int32_t PIOS_Flash_Jedec_EraseChip() PIOS_Flash_Jedec_ReleaseBus(); // Keep polling when bus is busy too - while(PIOS_Flash_Jedec_Busy() != 0); + while(PIOS_Flash_Jedec_Busy() != 0) + vTaskDelay(1); return 0; } @@ -340,8 +342,9 @@ int32_t PIOS_Flash_Jedec_WriteData(uint32_t addr, uint8_t * data, uint16_t len) PIOS_Flash_Jedec_ReleaseBus(); - // Keep polling while bus is busy too - while(PIOS_Flash_Jedec_Busy() != 0); + // Keep polling when bus is busy too + while(PIOS_Flash_Jedec_Busy() != 0) + vTaskDelay(1); return 0; }