NinjaFlight
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
asyncfatfs.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 #include <stdbool.h>
22 
23 #include "fat_standard.h"
24 
25 typedef struct afatfsFile_t *afatfsFilePtr_t;
26 
27 typedef enum {
33 
34 typedef enum {
39 
40 typedef enum {
46 
47 typedef struct afatfsDirEntryPointer_t {
49  int16_t entryIndex;
51 
53 
54 typedef enum {
58 } afatfsSeek_e;
59 
60 typedef void (*afatfsFileCallback_t)(afatfsFilePtr_t file);
61 typedef void (*afatfsCallback_t)(void);
62 
63 bool afatfs_fopen(const char *filename, const char *mode, afatfsFileCallback_t complete);
64 bool afatfs_ftruncate(afatfsFilePtr_t file, afatfsFileCallback_t callback);
65 bool afatfs_fclose(afatfsFilePtr_t file, afatfsCallback_t callback);
66 bool afatfs_funlink(afatfsFilePtr_t file, afatfsCallback_t callback);
67 
68 bool afatfs_feof(afatfsFilePtr_t file);
69 void afatfs_fputc(afatfsFilePtr_t file, uint8_t c);
70 uint32_t afatfs_fwrite(afatfsFilePtr_t file, const uint8_t *buffer, uint32_t len);
71 uint32_t afatfs_fread(afatfsFilePtr_t file, uint8_t *buffer, uint32_t len);
72 afatfsOperationStatus_e afatfs_fseek(afatfsFilePtr_t file, int32_t offset, afatfsSeek_e whence);
73 bool afatfs_ftell(afatfsFilePtr_t file, uint32_t *position);
74 
75 bool afatfs_mkdir(const char *filename, afatfsFileCallback_t complete);
76 bool afatfs_chdir(afatfsFilePtr_t dirHandle);
77 
78 void afatfs_findFirst(afatfsFilePtr_t directory, afatfsFinder_t *finder);
79 afatfsOperationStatus_e afatfs_findNext(afatfsFilePtr_t directory, afatfsFinder_t *finder, fatDirectoryEntry_t **dirEntry);
80 void afatfs_findLast(afatfsFilePtr_t directory);
81 
82 bool afatfs_flush(void);
83 void afatfs_init(void);
84 bool afatfs_destroy(bool dirty);
85 void afatfs_poll(void);
86 
87 uint32_t afatfs_getFreeBufferSpace(void);
88 uint32_t afatfs_getContiguousFreeSpace(void);
89 bool afatfs_isFull(void);
90 
void afatfs_init(void)
Definition: asyncfatfs.c:3569
afatfsFilesystemState_e afatfs_getFilesystemState(void)
Definition: asyncfatfs.c:3559
afatfsOperationStatus_e afatfs_findNext(afatfsFilePtr_t directory, afatfsFinder_t *finder, fatDirectoryEntry_t **dirEntry)
Definition: asyncfatfs.c:2140
Definition: asyncfatfs.h:41
bool afatfs_destroy(bool dirty)
Definition: asyncfatfs.c:3585
afatfsOperationStatus_e afatfs_fseek(afatfsFilePtr_t file, int32_t offset, afatfsSeek_e whence)
Definition: asyncfatfs.c:2075
bool afatfs_fopen(const char *filename, const char *mode, afatfsFileCallback_t complete)
Definition: asyncfatfs.c:2959
void afatfs_findLast(afatfsFilePtr_t directory)
Definition: asyncfatfs.c:2177
void(* afatfsCallback_t)(void)
Definition: asyncfatfs.h:61
afatfsDirEntryPointer_t afatfsFinder_t
Definition: asyncfatfs.h:52
Definition: asyncfatfs.h:56
bool afatfs_ftruncate(afatfsFilePtr_t file, afatfsFileCallback_t callback)
Definition: asyncfatfs.c:2494
uint8_t mode
Definition: gimbal.h:49
Definition: asyncfatfs.h:57
uint32_t afatfs_fwrite(afatfsFilePtr_t file, const uint8_t *buffer, uint32_t len)
Definition: asyncfatfs.c:3036
Definition: asyncfatfs.h:55
Definition: fat_standard.h:115
Definition: asyncfatfs.c:343
afatfsOperationStatus_e
Definition: asyncfatfs.h:34
int16_t entryIndex
Definition: asyncfatfs.h:49
struct afatfsDirEntryPointer_t afatfsDirEntryPointer_t
bool afatfs_feof(afatfsFilePtr_t file)
Definition: asyncfatfs.c:3164
Definition: asyncfatfs.h:31
Definition: asyncfatfs.h:30
Definition: asyncfatfs.h:47
afatfsSeek_e
Definition: asyncfatfs.h:54
afatfsError_e
Definition: asyncfatfs.h:40
bool afatfs_fclose(afatfsFilePtr_t file, afatfsCallback_t callback)
Definition: asyncfatfs.c:2855
void(* afatfsFileCallback_t)(afatfsFilePtr_t file)
Definition: asyncfatfs.h:60
char filename[FAT_FILENAME_LENGTH]
Definition: fat_standard.h:65
bool afatfs_isFull(void)
Definition: asyncfatfs.c:841
void afatfs_fputc(afatfsFilePtr_t file, uint8_t c)
Definition: asyncfatfs.c:3006
Definition: asyncfatfs.h:28
struct afatfsFile_t * afatfsFilePtr_t
Definition: asyncfatfs.h:25
afatfsFilesystemState_e
Definition: asyncfatfs.h:27
void afatfs_poll(void)
Definition: asyncfatfs.c:3496
bool afatfs_mkdir(const char *filename, afatfsFileCallback_t complete)
Definition: asyncfatfs.c:2878
void afatfs_findFirst(afatfsFilePtr_t directory, afatfsFinder_t *finder)
Definition: asyncfatfs.c:2186
uint32_t afatfs_getFreeBufferSpace(void)
Definition: asyncfatfs.c:3651
Definition: asyncfatfs.h:35
afatfsError_e afatfs_getLastError(void)
Definition: asyncfatfs.c:3564
bool afatfs_ftell(afatfsFilePtr_t file, uint32_t *position)
Definition: asyncfatfs.c:2122
Definition: asyncfatfs.h:44
uint32_t sectorNumberPhysical
Definition: asyncfatfs.h:48
bool afatfs_chdir(afatfsFilePtr_t dirHandle)
Definition: asyncfatfs.c:2898
Definition: asyncfatfs.h:37
bool afatfs_flush(void)
Definition: asyncfatfs.c:811
Definition: asyncfatfs.h:36
uint32_t afatfs_getContiguousFreeSpace(void)
Definition: asyncfatfs.c:3234
Definition: asyncfatfs.h:29
Definition: asyncfatfs.h:43
Definition: asyncfatfs.h:42
bool afatfs_funlink(afatfsFilePtr_t file, afatfsCallback_t callback)
Definition: asyncfatfs.c:2718
uint32_t afatfs_fread(afatfsFilePtr_t file, uint8_t *buffer, uint32_t len)
Definition: asyncfatfs.c:3103