mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 00:05:33 +03:00
Fix Flash API timeout issues.
Flash operations can specify how long to wait before the next operation is issued. Prior to this the amount of time waited, and when, was wrong. e.g. m25p16_eraseCompletely - possibly waits ages TO START, starts, exit. m25p16_pageProgramContinue - waits DEFAULT_TIMEOUT_MILLIS to START, starts, exits. m25p16_pageProgramContinue would fail to write to the flash as the device was still busy erasing and didn't wait long enough. what happens now is: m25p16_eraseCompletely - waits using the current timeout, starts, sets timeout to be `now + BULK_ERASE_TIMEOUT_MILLIS`, exits. m25p16_pageProgramContinue - waits using the current `BULK_ERASE_TIMEOUT_MILLIS`, starts, exists, sets timeout to be `now + DEFAULT_TIMEOUT_MILLIS`. Since the timeout is stored in the flashDevice_t the solution also works for multi-die devices which use an instance of flashDevice_t for each die.
This commit is contained in:
parent
ad00c6b66b
commit
6189d6bdc5
6 changed files with 74 additions and 39 deletions
|
@ -205,9 +205,9 @@ bool flashIsReady(void)
|
|||
return flashDevice.vTable->isReady(&flashDevice);
|
||||
}
|
||||
|
||||
bool flashWaitForReady(uint32_t timeoutMillis)
|
||||
bool flashWaitForReady(void)
|
||||
{
|
||||
return flashDevice.vTable->waitForReady(&flashDevice, timeoutMillis);
|
||||
return flashDevice.vTable->waitForReady(&flashDevice);
|
||||
}
|
||||
|
||||
void flashEraseSector(uint32_t address)
|
||||
|
@ -247,7 +247,9 @@ int flashReadBytes(uint32_t address, uint8_t *buffer, int length)
|
|||
|
||||
void flashFlush(void)
|
||||
{
|
||||
flashDevice.vTable->flush(&flashDevice);
|
||||
if (flashDevice.vTable->flush) {
|
||||
flashDevice.vTable->flush(&flashDevice);
|
||||
}
|
||||
}
|
||||
|
||||
static const flashGeometry_t noFlashGeometry = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue