NinjaFlight
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
flashfs.h
Go to the documentation of this file.
1 /*
2  * This file is part of Ninjaflight.
3  *
4  * Ninjaflight is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * Ninjaflight is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with Ninjaflight. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #pragma once
19 
20 #include <stdint.h>
21 
22 #include "drivers/flash.h"
23 
24 #define FLASHFS_WRITE_BUFFER_SIZE 128
25 #define FLASHFS_WRITE_BUFFER_USABLE (FLASHFS_WRITE_BUFFER_SIZE - 1)
26 
27 // Automatically trigger a flush when this much data is in the buffer
28 #define FLASHFS_WRITE_BUFFER_AUTO_FLUSH_LEN 64
29 
30 void flashfsEraseCompletely(void);
31 void flashfsEraseRange(uint32_t start, uint32_t end);
32 
33 uint32_t flashfsGetSize(void);
34 uint32_t flashfsGetOffset(void);
35 uint32_t flashfsGetWriteBufferFreeSpace(void);
36 uint32_t flashfsGetWriteBufferSize(void);
39 
40 void flashfsSeekAbs(uint32_t offset);
41 void flashfsSeekRel(int32_t offset);
42 
43 void flashfsWriteByte(uint8_t byte);
44 void flashfsWrite(const uint8_t *data, unsigned int len, bool sync);
45 
46 int flashfsReadAbs(uint32_t offset, uint8_t *data, unsigned int len);
47 
48 bool flashfsFlushAsync(void);
49 void flashfsFlushSync(void);
50 
51 void flashfsInit(void);
52 
53 bool flashfsIsReady(void);
54 bool flashfsIsEOF(void);
int flashfsReadAbs(uint32_t offset, uint8_t *data, unsigned int len)
Definition: flashfs.c:464
void flashfsFlushSync(void)
Definition: flashfs.c:329
uint32_t flashfsGetWriteBufferFreeSpace(void)
Definition: flashfs.c:136
void flashfsSeekAbs(uint32_t offset)
Definition: flashfs.c:345
bool flashfsIsReady(void)
Definition: flashfs.c:107
void flashfsWrite(const uint8_t *data, unsigned int len, bool sync)
Definition: flashfs.c:381
void flashfsWriteByte(uint8_t byte)
Definition: flashfs.c:362
void flashfsEraseCompletely(void)
Definition: flashfs.c:68
bool flashfsIsEOF(void)
Definition: flashfs.c:554
const flashGeometry_t * flashfsGetGeometry(void)
Definition: flashfs.c:141
void flashfsEraseRange(uint32_t start, uint32_t end)
Definition: flashfs.c:81
void flashfsInit(void)
Definition: flashfs.c:562
void flashfsSeekRel(int32_t offset)
Definition: flashfs.c:352
bool flashfsFlushAsync(void)
Definition: flashfs.c:306
uint32_t flashfsGetWriteBufferSize(void)
Definition: flashfs.c:128
uint32_t flashfsGetOffset(void)
Definition: flashfs.c:271
uint32_t flashfsGetSize(void)
Definition: flashfs.c:112
Definition: flash.h:22
uint16_t data
Definition: config.c:91
int flashfsIdentifyStartOfFreeSpace(void)
Definition: flashfs.c:485