User manual

Table Of Contents
304
mikoC PRO for PIC32
MikroElektronika
// Deletes a le. If le doesn’t exist, it will rst be created
// and then deleted.
void M_Delete_File() {
lename[7] = ‘F’;
Cf_Fat_Assign(lename, 0);
Cf_Fat_Delete();
}
// Tests whether le exists, and if so sends its creation date
// and le size via UART
void M_Test_File_Exist() {
unsigned long fsize;
unsigned int year;
unsigned short month, day, hour, minute;
unsigned char outstr[12];
lename[7] = ‘B’; //uncomment this line to search for le that DOES exists
// lename[7] = ‘F’; //uncomment this line to search for le that DOES NOT exist
if (Cf_Fat_Assign(lename, 0)) {
//--- le has been found - get its date
Cf_Fat_Get_File_Date(&year, &month, &day, &hour, &minute);
UART1_Write_Text(“ created: “);
WordToStr(year, outstr);
UART1_Write_Text(outstr);
ByteToStr(month, outstr);
UART1_Write_Text(outstr);
WordToStr(day, outstr);
UART1_Write_Text(outstr);
WordToStr(hour, outstr);
UART1_Write_Text(outstr);
WordToStr(minute, outstr);
UART1_Write_Text(outstr);
//--- le has been found - get its modied date
Cf_Fat_Get_File_Date_Modied(&year, &month, &day, &hour, &minute);
UART1_Write_Text(“ modied: “);
WordToStr(year, outstr);
UART1_Write_Text(outstr);
ByteToStr(month, outstr);
UART1_Write_Text(outstr);
WordToStr(day, outstr);
UART1_Write_Text(outstr);
WordToStr(hour, outstr);
UART1_Write_Text(outstr);
WordToStr(minute, outstr);
UART1_Write_Text(outstr);
//--- get le size
fsize = Cf_Fat_Get_File_Size();
LongToStr((signed long)fsize, outstr);
UART1_Write_Line(outstr);
}
else {
//--- le was not found - signal it
UART1_Write(0x55);
Delay_ms(1000);
UART1_Write(0x55);