mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 16:25:31 +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
|
@ -53,12 +53,13 @@ typedef struct flashDevice_s {
|
|||
// for writes. This allows us to avoid polling for writable status
|
||||
// when it is definitely ready already.
|
||||
bool couldBeBusy;
|
||||
uint32_t timeoutAt;
|
||||
flashDeviceIO_t io;
|
||||
} flashDevice_t;
|
||||
|
||||
typedef struct flashVTable_s {
|
||||
bool (*isReady)(flashDevice_t *fdevice);
|
||||
bool (*waitForReady)(flashDevice_t *fdevice, uint32_t timeoutMillis);
|
||||
bool (*waitForReady)(flashDevice_t *fdevice);
|
||||
void (*eraseSector)(flashDevice_t *fdevice, uint32_t address);
|
||||
void (*eraseCompletely)(flashDevice_t *fdevice);
|
||||
void (*pageProgramBegin)(flashDevice_t *fdevice, uint32_t address);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue