Browse code

Add source code of the firmware for the IO Board

Pawel Jablonski authored on 05/06/2023 17:01:27
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,52 @@
1
+/*
2
+ * Author: Pawel Jablonski
3
+ * E-mail: pj@xirx.net
4
+ * WWW: xirx.net
5
+ * GIT: git.xirx.net
6
+ *
7
+ * License: You can use this code however you like
8
+ * but leave information about the original author.
9
+ * Code is free for non-commercial and commercial use.
10
+ */
11
+
12
+#ifndef _FS_H
13
+#define _FS_H
14
+
15
+#include "type.h"
16
+
17
+#define FS_NAME_MAX_LENGTH 12 //!< Maximum name length of the file
18
+#define FS_PATH_MAX_LENGTH ((FS_NAME_MAX_LENGTH * 2) + 1) //!< Maximum path length to the file
19
+
20
+#define FS_BLOCK_SIZE 256 //!<  Virtual block size available to address by communication bus between motherboard and CPU
21
+
22
+#define FS_DIR_ENTRY_SIZE 16 //!< Size of the header with information about file
23
+#define FS_DIR_SIZE_FIELD_SIZE 2 //!< Size of the size field in the header
24
+#define FS_DIR_MAX_QUANTITY 64 //!< Maximum quantity of files in directory
25
+
26
+//! This struct contains a name of the file
27
+struct FSName
28
+{
29
+	unsigned char data[FS_NAME_MAX_LENGTH + 1]; //!< Name of the file
30
+};
31
+
32
+//! This struct contains a size of the file
33
+struct FSSize
34
+{
35
+	unsigned char low; //!< Lower byte of the size
36
+	unsigned char high; //!< Higher byte of the size
37
+};
38
+
39
+//! This struct contains virtual block data
40
+struct FSBlock
41
+{
42
+	unsigned char data[FS_BLOCK_SIZE]; //!< Virtual block data
43
+};
44
+
45
+void fsInit(void);
46
+
47
+bool fsOpen(const char *dirName, const struct FSName *fileName, struct FSSize *size);
48
+bool fsList(const char *dirName, struct FSSize *size);
49
+
50
+void fsReadBlock(struct FSBlock *block, int number);
51
+
52
+#endif