mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-14 11:59:58 +03:00
Prepare flash code for multiple device type support (#5683)
* Prepare flash drivers for multiple device type support * Add static assertions on device page and flashfs alloc sizes.
This commit is contained in:
parent
4a5e79a534
commit
864dba98c1
13 changed files with 387 additions and 187 deletions
50
src/main/drivers/flash_impl.h
Normal file
50
src/main/drivers/flash_impl.h
Normal file
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* This file is part of Betaflight/Cleanflight.
|
||||
*
|
||||
* Betaflight/Cleanflight is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Betaflight/Cleanflight is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Author: jflyper
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "drivers/bus.h"
|
||||
|
||||
struct flashVTable_s;
|
||||
|
||||
typedef struct flashDevice_s {
|
||||
busDevice_t *busdev;
|
||||
const struct flashVTable_s *vTable;
|
||||
flashGeometry_t geometry;
|
||||
uint32_t currentWriteAddress;
|
||||
bool isLargeFlash;
|
||||
// Whether we've performed an action that could have made the device busy
|
||||
// for writes. This allows us to avoid polling for writable status
|
||||
// when it is definitely ready already.
|
||||
bool couldBeBusy;
|
||||
} flashDevice_t;
|
||||
|
||||
typedef struct flashVTable_s {
|
||||
bool (*isReady)(flashDevice_t *fdevice);
|
||||
bool (*waitForReady)(flashDevice_t *fdevice, uint32_t timeoutMillis);
|
||||
void (*eraseSector)(flashDevice_t *fdevice, uint32_t address);
|
||||
void (*eraseCompletely)(flashDevice_t *fdevice);
|
||||
void (*pageProgramBegin)(flashDevice_t *fdevice, uint32_t address);
|
||||
void (*pageProgramContinue)(flashDevice_t *fdevice, const uint8_t *data, int length);
|
||||
void (*pageProgramFinish)(flashDevice_t *fdevice);
|
||||
void (*pageProgram)(flashDevice_t *fdevice, uint32_t address, const uint8_t *data, int length);
|
||||
void (*flush)(flashDevice_t *fdevice);
|
||||
int (*readBytes)(flashDevice_t *fdevice, uint32_t address, uint8_t *buffer, int length);
|
||||
const flashGeometry_t *(*getGeometry)(flashDevice_t *fdevice);
|
||||
} flashVTable_t;
|
Loading…
Add table
Add a link
Reference in a new issue