// Generate File Allocation Table to save Flash space // First Two FAT entries are reserved Fat_RootDir[0]= 0xF8; Fat_RootDir[1]= 0xFF; Fat_RootDir[2]= 0xFF; /* Start cluster of a file is indicated by the Directory entry = 2 */ m = 3; for ( n = 3;n < NO_OF_CLUSTERS+2;n+=2) { if( n == ((NO_OF_CLUSTERS+2)-1) ) { next_cluster = 0xFFF; } else { next_cluster = n + 1; } [COLOR=Red]Fat_RootDir[m] = (BYTE)n & 0xFF; Fat_RootDir[m+1] = (((BYTE)next_cluster & 0xF) << 4) | ((BYTE)(n>>8)&0xF); Fat_RootDir[m+2] = (BYTE)(next_cluster >> 4) & 0xFF; m = m+3;[/COLOR] } |