📄 fat16.lst
字号:
89
90 0x00,//active partion
91 0x00,//head
92 0x00,//partion begin
93 0x00,//cylinder
94 0x06,//is partion used
95 0x00,//end head
96 0x00,//partion end
97 0x00,//end cylinder
98 0x00,0x00,0x00,0x00,
99 0x00,0x80,0x00,0x00,//fist partion
100
101 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,//second partion
102 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,//third partion
103 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,//forth partion
104
105 0x55,0xAA // Offset_short int_Signature 510 //0x55AA
C51 COMPILER V6.23a FAT16 07/30/2003 17:38:25 PAGE 3
106
107 };
108
109
110 void WriteMBR2Flash(void)
111 {
112 1 if(Check_Flash_Id()==KM29U128_ID){
113 2 WritePage(Root_Cluster, BPB_Sector, BPB_Data);
114 2 }
115 1 else printu("\nKM29U128 is Not Found!");
116 1 }
117
118 void CreatFAT12(void)
119 {
120 1 short int i;
121 1 unsigned char *FAT=Page_Buf;
122 1 for(i=0;i<512;i++) FAT[i] = 0x00;
123 1 //disk type lower byte is equal to Offset_U8_BPB_Media
124 1 FAT[0] = 0xf8;
125 1 FAT[1] = 0xff;//system occupied the first cluster
126 1 FAT[2] = 0xff;
127 1 FAT[3] = 0x7f;
128 1
129 1 if(Check_Flash_Id()==KM29U128_ID){
130 2 WritePage(Root_Cluster,Fat_Sector,FAT); //Sector 1 of Fat16
131 2 WritePage(Root_Cluster,Fat_Sector+2,FAT); //Sector 1 of Fat16
132 2 FAT[0]=FAT[1]=FAT[2]=FAT[3]=0x00;
133 2 WritePage(Root_Cluster,Fat_Sector+1,FAT); //Sector 2 of Fat16
134 2 WritePage(Root_Cluster,Fat_Sector+3,FAT); //Sector 2 of Fat16
135 2 }
136 1 else printu("\nKM29U128 is Not Found!");
137 1 }
138
139 void CreatDirectoryEntry(void)
140 {
141 1 long int i;
142 1 unsigned char *Directory_Enties=Page_Buf;
143 1 for(i=0;i<512;i++) Directory_Enties[i]= 0x00;
144 1
145 1 if(Check_Flash_Id()==KM29U128_ID){
146 2 for(i=0;i<35;i++) {
147 3 WritePage(Root_Cluster+i/32,Directory_Sector+i%32,Directory_Enties);
148 3 // Delay(100);
149 3 }
150 2 }
151 1 else printu("\nKM29U128 is Not Found!");
152 1
153 1 }
154
155
156 //函数实现
157 void Format_Fat12Media(void)
158 {
159 1 Flash_Reset();
160 1 printu("\nFlash_Reset Succeed");
161 1 Erase_Cluster(Root_Cluster);
162 1 Erase_Cluster(Root_Cluster+1);
163 1
164 1 printu("\nErase_Cluster Succeed");
165 1 WriteMBR2Flash();
166 1 printu("\nCreat BPB Succeed");
167 1 CreatFAT12();
C51 COMPILER V6.23a FAT16 07/30/2003 17:38:25 PAGE 4
168 1 printu("\nCreat FAT12 Succeed");
169 1 CreatDirectoryEntry();
170 1 printu("\nCreat Directory Entry Succeed");
171 1
172 1 printu("\nFlash have been Fomarted");
173 1 }
174
175 void WriteFlashTest()
176 {
177 1 Erase_Cluster(0);
178 1 WritePage(0,0,BPB_Data);
179 1
180 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 754 ----
CONSTANT SIZE = 677 ----
XDATA SIZE = 512 18
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -