Rev 90 | Rev 211 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 90 | Rev 210 | ||
---|---|---|---|
1 | #ifndef _FAT16_H |
1 | #ifndef _FAT16_H |
2 | #define _FAT16_H |
2 | #define _FAT16_H |
3 | 3 | ||
4 | 4 | ||
5 | //________________________________________________________________________________________________________________________________________ |
5 | //________________________________________________________________________________________________________________________________________ |
6 | // |
6 | // |
7 | // Definitions |
7 | // Definitions |
8 | // |
8 | // |
9 | //________________________________________________________________________________________________________________________________________ |
9 | //________________________________________________________________________________________________________________________________________ |
10 | 10 | ||
11 | //#define __USE_TIME_DATE_ATTRIBUTE |
11 | //#define __USE_TIME_DATE_ATTRIBUTE |
12 | #define FILE_MAX_OPEN 3 // The number of files that can accessed simultaneously. |
12 | #define FILE_MAX_OPEN 3 // The number of files that can accessed simultaneously. |
13 | #define SEEK_SET 0 |
13 | #define SEEK_SET 0 |
14 | #define SEEK_CUR 1 |
14 | #define SEEK_CUR 1 |
15 | #define SEEK_END 2 |
15 | #define SEEK_END 2 |
16 | #define EOF (-1) |
16 | #define EOF (-1) |
17 | #define BYTES_PER_SECTOR 512 |
17 | #define BYTES_PER_SECTOR 512 |
18 | /* |
18 | /* |
19 | ________________________________________________________________________________________________________________________________________ |
19 | ________________________________________________________________________________________________________________________________________ |
20 | |
20 | |
21 | Structure of a filepointer |
21 | Structure of a filepointer |
22 | ________________________________________________________________________________________________________________________________________ |
22 | ________________________________________________________________________________________________________________________________________ |
23 | */ |
23 | */ |
24 | typedef struct |
24 | typedef struct |
25 | { |
25 | { |
26 | u32 FirstSectorOfFirstCluster; // First sector of the first cluster of the file. |
26 | u32 FirstSectorOfFirstCluster; // First sector of the first cluster of the file. |
27 | u32 FirstSectorOfCurrCluster; // First sector of the cluster which is edited at the moment. |
27 | u32 FirstSectorOfCurrCluster; // First sector of the cluster which is edited at the moment. |
28 | u8 SectorOfCurrCluster; // The sector within the current cluster. |
28 | u8 SectorOfCurrCluster; // The sector within the current cluster. |
29 | u16 ByteOfCurrSector; // The byte location within the current sector. |
29 | u16 ByteOfCurrSector; // The byte location within the current sector. |
30 | u8 Mode; // Mode of fileoperation (read,write) |
30 | u8 Mode; // Mode of fileoperation (read,write) |
31 | u32 Size; // The size of the opend file in bytes. |
31 | u32 Size; // The size of the opend file in bytes. |
32 | u32 Position; // Pointer to a character within the file 0 < fileposition < filesize |
32 | u32 Position; // Pointer to a character within the file 0 < fileposition < filesize |
33 | u32 DirectorySector; // the sectorposition where the directoryentry has been made. |
33 | u32 DirectorySector; // the sectorposition where the directoryentry has been made. |
34 | u16 DirectoryIndex; // The index to the directoryentry within the specified sector. |
34 | u16 DirectoryIndex; // The index to the directoryentry within the specified sector. |
35 | u8 Attribute; // The attribute of the file opened. |
35 | u8 Attribute; // The attribute of the file opened. |
36 | u8 Cache[BYTES_PER_SECTOR]; // Cache for read and write operation from or to the sd-card. |
36 | u8 Cache[BYTES_PER_SECTOR]; // Cache for read and write operation from or to the sd-card. |
37 | u32 SectorInCache; // The last sector read, which is still in the sector cache. |
37 | u32 SectorInCache; // The last sector read, which is still in the sector cache. |
38 | u8 State; // State of the filepointer (used/unused/...) |
38 | u8 State; // State of the filepointer (used/unused/...) |
39 | } File_t; |
39 | } File_t; |
40 | 40 | ||
41 | //________________________________________________________________________________________________________________________________________ |
41 | //________________________________________________________________________________________________________________________________________ |
42 | // |
42 | // |
43 | // API to the FAT16 filesystem |
43 | // API to the FAT16 filesystem |
44 | // |
44 | // |
45 | //________________________________________________________________________________________________________________________________________ |
45 | //________________________________________________________________________________________________________________________________________ |
46 | 46 | ||
47 | u8 Fat16_Init(void); |
47 | u8 Fat16_Init(void); |
48 | u8 Fat16_Deinit(void); |
48 | u8 Fat16_Deinit(void); |
49 | u8 Fat16_IsValid(void); |
49 | u8 Fat16_IsValid(void); |
- | 50 | s8* FAT16_GetVolumeLabel(void); |
|
50 | 51 | ||
51 | File_t *fopen_(s8 * const filename, const s8 mode); |
52 | File_t *fopen_(s8 * const filename, const s8 mode); |
52 | s16 fclose_(File_t *file); |
53 | s16 fclose_(File_t *file); |
53 | u8 fexist_(s8 * const filename); |
54 | u8 fexist_(s8 * const filename); |
54 | s16 fflush_(File_t * const file); |
55 | s16 fflush_(File_t * const file); |
55 | s16 fseek_(File_t * const file, s32 offset, s16 origin); |
56 | s16 fseek_(File_t * const file, s32 offset, s16 origin); |
56 | s16 fgetc_(File_t * const file); |
57 | s16 fgetc_(File_t * const file); |
57 | s16 fputc_(s8 c, File_t * const file); |
58 | s16 fputc_(s8 c, File_t * const file); |
58 | u32 fread_(void *buffer, u32 size, u32 count, File_t * const file); |
59 | u32 fread_(void *buffer, u32 size, u32 count, File_t * const file); |
59 | u32 fwrite_(void *buffer, u32 size, u32 count, File_t * const file); |
60 | u32 fwrite_(void *buffer, u32 size, u32 count, File_t * const file); |
60 | s16 fputs_(s8 * const string, File_t * const file); |
61 | s16 fputs_(s8 * const string, File_t * const file); |
61 | s8 * fgets_(s8 * const string, s16 length, File_t * const file); |
62 | s8 * fgets_(s8 * const string, s16 length, File_t * const file); |
62 | u8 feof_(File_t * const file); |
63 | u8 feof_(File_t * const file); |
63 | 64 | ||
64 | 65 | ||
65 | 66 | ||
66 | #endif //_FAT16_H |
67 | #endif //_FAT16_H |
67 | 68 | ||
68 | 69 | ||
69 | 70 | ||
70 | 71 | ||
71 | 72 |