+void WriteFAT12ClusterEntry(uint8_t* FATTable, uint8_t Index, uint16_t NextEntry)
+{
+ uint8_t StartOffset = ((uint16_t)Index * 3) / 2;
+
+ /* Check if the start of the entry is at an upper nibble of the byte */
+ if (((uint16_t)Index * 3) % 2)
+ {
+ FATTable[StartOffset] |= ((NextEntry & 0x0F) << 4);
+ FATTable[StartOffset + 1] = (NextEntry >> 4);
+ }
+ else
+ {
+ FATTable[StartOffset] = NextEntry;
+ FATTable[StartOffset + 1] = (NextEntry >> 8);
+ }
+}
+