V1.10
Direct support added for CrossWorks for ARM compiler using NXP 32bit Arm micro.
FFS_CE output pin definition modified to support pin set and pin clear registers where needed.
Added ffs_change_file_size() function.
The ffs_check_command_response_byte function relied on the last response value being retained in FFS_SPI_RX_BYTE_BUFFER as the value was read again and tested by various functions which called ffs_check_command_response_byte. This is not suitable for microcontrollers that have a fifo buffer on the SPI port receive. Changed to use a new global variable called chk_cmd_response_data in which the FFS_SPI_RX_BYTE_BUFFER value is stored and which the calling functions instead use to test with.
It has been found in some circumstances that corruption issues can be solved by replacing the following occurrences:
while (FFC_DI == 0)
ffs_read_byte();
with this:
ffs_read_byte();
while (FFC_DI == 0)
ffs_read_byte();
The cause of this is unknown as the specification does not appear to require this, but it does not prohibit it either so it is sensible to include.
Added the following at the end of ffs_flush:
//----- ENSURE CARD HAS COMPLETED LAST WRITE PROCESS -----
//When closing a file if the last write to the card before it is removed or powered down just occurred
//some cards have been found to not store the last sector written. If the card is flagging that its busy
//then provide clock pulses to allow it to complete its last operation
DO_BUSY_STATE_ACCESS_DELAY;
FFS_CE(0); //Select the card
DO_BUSY_STATE_ACCESS_DELAY;
ffs_read_byte();
while (FFC_DI == 0)
ffs_read_byte();
FFS_CE(1); //Deselect the card
return(0);
Removed the ENSURE CARD HAS COMPLETED LAST WRITE PROCESS section from ffs_fclose as this is now provided by ffs_flush.
ffs_read_sector_to_buffer function modified to include retry if the read fails to deal with rare cards found to not action the command if busy whilst not actually flagging that they are busy.
ffs_write_sector_from_buffer function modified to include retry if the read fails to deal with rare cards found to not action the command if busy whilst not actually flagging that they are busy..
ffs_remove function updated to ensure both FAT tables are updated.
Issue fixed in ffs_fputc where overwriting within a file across a cluster boundary could cause corruption.
In mem-ffs.c changed:
bytes_to_new_posn -= (DWORD)0 – offset;
to be
bytes_to_new_posn -= (DWORD)(0 – offset);
as this solved a “unary minus operator applied to unsigned type” error with the Codewarrior compiler.
V1.11
In ffs_write_sector_from_buffer the line:
buffer_pointer = &FFS_DRIVER_GEN_512_BYTE_BUFFER[0];
to be inside the while loop in case card returns error at the very end of the write operation.
In ffs_change_file_size and ffs_remove changed the line:
dw_temp = (next_cluster / fat_entries_per_sector); //dw_temp now has the sector address that will need to be modifed for the next cluster entry
to be:
dw_temp = (read_cluster_number / fat_entries_per_sector); //dw_temp now has the sector address that will need to be modifed for this cluster entry
to correct possible memory corruption bug
Microchip PIC32 support added to driver
V1.12
ffs_remove() function re-written to fix issue with FAT table updating.
Updated this line in mem-mmcsd.c as on fast systems with some cards a longer timeout has been found to be necessary:
//Wait for data token
for (count = 100; count > 0; count--)
to be:
//Wait for data token
for (count = 1000; count > 0; count--)


