File tree Expand file tree Collapse file tree 6 files changed +452
-405
lines changed Expand file tree Collapse file tree 6 files changed +452
-405
lines changed Original file line number Diff line number Diff line change
1
+ #ifndef CMD_H
2
+ #define CMD_H
3
+
4
+ #include < cstdint>
5
+
6
+ enum
7
+ {
8
+ CMD_NAND_READ_ID = 0x00 ,
9
+ CMD_NAND_ERASE = 0x01 ,
10
+ CMD_NAND_READ = 0x02 ,
11
+ CMD_NAND_WRITE_S = 0x03 ,
12
+ CMD_NAND_WRITE_D = 0x04 ,
13
+ CMD_NAND_WRITE_E = 0x05 ,
14
+ CMD_NAND_SELECT = 0x06 ,
15
+ };
16
+
17
+ typedef struct __attribute__ ((__packed__))
18
+ {
19
+ uint8_t code;
20
+ } Cmd;
21
+
22
+ typedef struct __attribute__ ((__packed__))
23
+ {
24
+ Cmd cmd;
25
+ uint32_t addr;
26
+ uint32_t len;
27
+ } EraseCmd;
28
+
29
+ typedef struct __attribute__ ((__packed__))
30
+ {
31
+ Cmd cmd;
32
+ uint32_t addr;
33
+ uint32_t len;
34
+ } ReadCmd;
35
+
36
+ typedef struct __attribute__ ((__packed__))
37
+ {
38
+ Cmd cmd;
39
+ uint32_t addr;
40
+ } WriteStartCmd;
41
+
42
+ typedef struct __attribute__ ((__packed__))
43
+ {
44
+ Cmd cmd;
45
+ uint8_t len;
46
+ uint8_t data[];
47
+ } WriteDataCmd;
48
+
49
+ typedef struct __attribute__ ((__packed__))
50
+ {
51
+ Cmd cmd;
52
+ } WriteEndCmd;
53
+
54
+ typedef struct __attribute__ ((__packed__))
55
+ {
56
+ Cmd cmd;
57
+ uint32_t chipNum;
58
+ } SelectCmd;
59
+
60
+ enum
61
+ {
62
+ RESP_DATA = 0x00 ,
63
+ RESP_STATUS = 0x01 ,
64
+ };
65
+
66
+ typedef enum
67
+ {
68
+ STATUS_OK = 0x00 ,
69
+ STATUS_ERROR = 0x01 ,
70
+ STATUS_BAD_BLOCK = 0x02 ,
71
+ STATUS_WRITE_ACK = 0x03 ,
72
+ } StatusData;
73
+
74
+
75
+
76
+ typedef struct __attribute__ ((__packed__))
77
+ {
78
+ uint8_t makerId;
79
+ uint8_t deviceId;
80
+ uint8_t thirdId;
81
+ uint8_t fourthId;
82
+ } ChipId;
83
+
84
+ typedef struct __attribute__ ((__packed__))
85
+ {
86
+ uint8_t code;
87
+ uint8_t info;
88
+ uint8_t data[];
89
+ } RespHeader;
90
+
91
+ typedef struct __attribute__ ((__packed__))
92
+ {
93
+ RespHeader header;
94
+ ChipId nandId;
95
+ } RespId;
96
+
97
+ typedef struct __attribute__ ((__packed__))
98
+ {
99
+ RespHeader header;
100
+ uint32_t addr;
101
+ } RespBadBlock;
102
+
103
+ typedef struct __attribute__ ((__packed__))
104
+ {
105
+ RespHeader header;
106
+ uint32_t ackBytes;
107
+ } RespWriteAck;
108
+
109
+ #endif // CMD_H
110
+
You can’t perform that action at this time.
0 commit comments