20260324
568
RTX5_20220316/Driver/FATFS/data_handle.c
Normal file
@ -0,0 +1,568 @@
|
||||
/*
|
||||
*****************************************************************
|
||||
ͷ<>ļ<EFBFBD>
|
||||
*****************************************************************
|
||||
*/
|
||||
#include "bsp.h"
|
||||
|
||||
/*
|
||||
************************************************************************************
|
||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
************************************************************************************
|
||||
*/
|
||||
data_common data_common1;
|
||||
FIL fp; /* Pointer to the blank file object */
|
||||
FATFS fs1;
|
||||
UINT btw; /* Number of bytes to write */
|
||||
UINT bws;
|
||||
u32 send_pos=0;
|
||||
DIR DirInf;
|
||||
FILINFO FileInf;
|
||||
char name[20]="\0";
|
||||
char Tf_Read_Buff[max_transmission+15],Send_Buf[max_transmission+15] = {'\0'},Temp_Buf[max_transmission+15] = {'\0'};
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <09><> <20><> <20><>: FATFS_WriteFile()
|
||||
* <09><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: TF<54><46><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>
|
||||
* <09><> <20><> <20><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD> fname <20><><EFBFBD><EFBFBD> dat <20><><EFBFBD><EFBFBD> len
|
||||
* <20><> <20><> <20><><EFBFBD><EFBFBD>
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
void FATFS_WriteFile(char *fname,char *dat,u16 len) //д<><D0B4><EFBFBD>ݵ<EFBFBD>SD<53><44>
|
||||
{
|
||||
UINT br;
|
||||
char name[20];
|
||||
sprintf(name,"%s%s",fname,".txt");
|
||||
f_mount(&fs1, "0:", 1);
|
||||
f_open (&fp,fname,FA_READ|FA_WRITE|FA_OPEN_ALWAYS);
|
||||
f_lseek(&fp,f_size(&fp)); //<2F>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>ĩβ--<><D7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
f_write(&fp,dat,len,&br);
|
||||
f_close(&fp);
|
||||
f_mount(NULL, DiskPath, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <09><> <20><> <20><>: Data_Write_TF()
|
||||
* <09><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: TF<54><46><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4> ʱ<>䡢<EFBFBD><E4A1A2>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD>γ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>Ρ<EFBFBD><CEA1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <09><> <20><> <20><><EFBFBD><EFBFBD>
|
||||
* <20><> <20><> <20><><EFBFBD><EFBFBD>
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
|
||||
FRESULT Data_Write_TF(void)
|
||||
{
|
||||
FRESULT res;
|
||||
u8 i=0;
|
||||
|
||||
char hhmmss[8]={'\0'},yymmdd[8]={'\0'};
|
||||
RTC_DateTypeDef dates;
|
||||
|
||||
//RTC_GetDate(RTC_Format_BIN,&dates);
|
||||
//GetRTC(hhmmss,yymmdd);
|
||||
//sprintf(name,"%s_%s.txt",yymmdd,Init_Data_Equipment.Measure_Interval);
|
||||
|
||||
f_mount(&fs1, "0:", 1);
|
||||
res=f_open(&fp,name,FA_WRITE);
|
||||
if((res==FR_NO_FILE)||(Init_Data_Equipment.par_change==1))//<2F>ж<EFBFBD><D0B6>ļ<EFBFBD><C4BC>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD>ͷ
|
||||
{
|
||||
f_close(&fp);
|
||||
f_open(&fp,name,FA_READ | FA_WRITE | FA_OPEN_ALWAYS );
|
||||
f_lseek (&fp,f_size(&fp));
|
||||
|
||||
f_write(&fp,"Equipment_ID:",strlen("Equipment_ID:"),&bws);
|
||||
f_write(&fp,Init_Data_Equipment.Equipment_ID,strlen(Init_Data_Equipment.Equipment_ID),&bws);
|
||||
f_write(&fp,"\r\n",2,&bws);
|
||||
|
||||
f_write(&fp,"TCP_Ip:",strlen("TCP_Ip:"),&bws);
|
||||
f_write(&fp,Init_Data_Equipment.Bc25_Ip,strlen(Init_Data_Equipment.Bc25_Ip),&bws);
|
||||
f_write(&fp,"\r\n",2,&bws);
|
||||
|
||||
f_write(&fp,"TCP_Port:",strlen("TCP_Port:"),&bws);
|
||||
f_write(&fp,Init_Data_Equipment.Bc25_Port,strlen(Init_Data_Equipment.Bc25_Port),&bws);
|
||||
f_write(&fp,"\r\n",2,&bws);
|
||||
|
||||
f_write(&fp,"Wifi_SSID:",strlen("Wifi_SSID:"),&bws);
|
||||
f_write(&fp,Init_Data_Equipment.ESP8266_AP_SSIDs,strlen(Init_Data_Equipment.ESP8266_AP_SSIDs),&bws);
|
||||
f_write(&fp,"\r\n",2,&bws);
|
||||
|
||||
f_write(&fp,"Wifi_Pwd:",strlen("Wifi_Pwd:"),&bws);
|
||||
f_write(&fp,Init_Data_Equipment.ESP8266_AP_PWDs,strlen(Init_Data_Equipment.ESP8266_AP_PWDs),&bws);
|
||||
f_write(&fp,"\r\n",2,&bws);
|
||||
|
||||
f_write(&fp,"Wifi_Port:",strlen("Wifi_Port:"),&bws);
|
||||
f_write(&fp,Init_Data_Equipment.ESP8266_AP_Ports,strlen(Init_Data_Equipment.ESP8266_AP_Ports),&bws);
|
||||
f_write(&fp,"\r\n",2,&bws);
|
||||
|
||||
f_write(&fp,"Measure_Interval:",strlen("Measure_Interval:"),&bws);
|
||||
f_write(&fp,Init_Data_Equipment.Measure_Interval,strlen(Init_Data_Equipment.Measure_Interval),&bws);
|
||||
f_write(&fp,"\r\n",2,&bws);
|
||||
|
||||
f_write(&fp,"Pub_Interval:",strlen("Pub_Interval:"),&bws);
|
||||
f_write(&fp,Init_Data_Equipment.Pub_Time,strlen(Init_Data_Equipment.Pub_Time),&bws);
|
||||
f_write(&fp,"\r\n",2,&bws);
|
||||
|
||||
f_write(&fp,"Appointment_Time:",strlen("Appointment_Time:"),&bws);
|
||||
f_write(&fp,Init_Data_Equipment.appointment_time,strlen(Init_Data_Equipment.appointment_time),&bws);
|
||||
f_write(&fp,"\r\n",2,&bws);
|
||||
|
||||
f_write(&fp,"Measure_Mode:",strlen("Measure_Mode:"),&bws);
|
||||
f_write(&fp,Init_Data_Equipment.measure_mode,strlen(Init_Data_Equipment.measure_mode),&bws);
|
||||
f_write(&fp,"\r\n",2,&bws);
|
||||
|
||||
f_write(&fp,"Equipment_ID,DateTime,Power-V,Latitude,N/S,Longitude,E/W,Ch1-SoilT_C,Ch1-SoilVWC_%,Ch1-Soil_DS,Ch2-SoilT_C,Ch2-SoilVWC_%,Ch2-Soil_DS,Ch3-SoilT_C,Ch3-SoilVWC_%,Ch3-Soil_DS,Ch4-SoilT_C,Ch4-SoilVWC_%,Ch4-Soil_DS,Ch5-SoilT_C,Ch5-SoilVWC_%,Ch5-Soil_DS,Ch6-SoilT_C,Ch6-SoilVWC_%,Ch6-Soil_DS,qxz-Temperature_C,qxz-Humidity_%RH,qxz-AirPressure_hPa,qxz-WindSpeed_m/s,qxz-WindDirection_<6E><5F>,qxz-Rainfall_mm,qxz-Illuminance_lux\r\n",
|
||||
strlen("Equipment_ID,DateTime,Power-V,Latitude,N/S,Longitude,E/W,Ch1-SoilT_C,Ch1-SoilVWC_%,Ch1-Soil_DS,Ch2-SoilT_C,Ch2-SoilVWC_%,Ch2-Soil_DS,Ch3-SoilT_C,Ch3-SoilVWC_%,Ch3-Soil_DS,Ch4-SoilT_C,Ch4-SoilVWC_%,Ch4-Soil_DS,Ch5-SoilT_C,Ch5-SoilVWC_%,Ch5-Soil_DS,Ch6-SoilT_C,Ch6-SoilVWC_%,Ch6-Soil_DS,qxz-Temperature_C,qxz-Humidity_%RH,qxz-AirPressure_hPa,qxz-WindSpeed_m/s,qxz-WindDirection_<6E><5F>,qxz-Rainfall_mm,qxz-Illuminance_lux\r\n"),&bws);
|
||||
f_close(&fp);
|
||||
//qxz<78><7A><EFBFBD><EFBFBD>վ<EFBFBD><D5BE><EFBFBD>ݣ<EFBFBD><DDA3>¶ȡ<C2B6>ʪ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD>١<EFBFBD><D9A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>գ<EFBFBD>
|
||||
//ʪ<><CAAA> <20>絼<EFBFBD><E7B5BC> <20>¶<EFBFBD>
|
||||
|
||||
}
|
||||
res=f_open(&fp,name,FA_READ | FA_WRITE | FA_OPEN_ALWAYS );//0:/
|
||||
if(res!=FR_OK) //<2F><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>
|
||||
{
|
||||
i=0;
|
||||
while((res!=FR_OK)&(i<100))
|
||||
{
|
||||
i++;
|
||||
f_close(&fp);
|
||||
f_mount(NULL, DiskPath, 0);
|
||||
f_mount(&fs1, "0:", 1);
|
||||
res=f_open(&fp,name,FA_READ | FA_WRITE | FA_OPEN_ALWAYS );//0:/
|
||||
}
|
||||
if(i>98)return FR_NO_PATH ;
|
||||
|
||||
}
|
||||
f_lseek (&fp,f_size(&fp));
|
||||
f_write(&fp,data_common1.Pack_data,strlen(data_common1.Pack_data),&bws);
|
||||
f_write(&fp,"\r\n",2,&bws);
|
||||
f_close(&fp);
|
||||
|
||||
|
||||
|
||||
f_mount(&fs1, "0:", 1);
|
||||
res=f_open(&fp,"BC25.txt",FA_WRITE);
|
||||
/*************<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>洢<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>BC25<32><35>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>*******************************/
|
||||
if((Init_Data_Equipment.par_change==1) || (res==FR_NO_FILE))//<2F>ж<EFBFBD><D0B6>ļ<EFBFBD><C4BC>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD>ͷ
|
||||
//if((Init_Data_Equipment.par_change==1)||(Init_Data_Equipment.Bc25_Send_Header!=dates.RTC_Date))//<2F>ж<EFBFBD><D0B6>ļ<EFBFBD><C4BC>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD>ͷ
|
||||
{
|
||||
//res=f_open(&fp,"BC25.txt",FA_READ | FA_WRITE | FA_OPEN_ALWAYS );
|
||||
Init_Data_Equipment.par_change=0;
|
||||
EEPROM_WriteBytes(185,0,1);
|
||||
EEPROM_WriteBytes(186,&dates.RTC_Date,1);
|
||||
f_close(&fp);
|
||||
f_open(&fp,"BC25.txt",FA_READ | FA_WRITE | FA_OPEN_ALWAYS );
|
||||
f_lseek (&fp,f_size(&fp));
|
||||
|
||||
f_write(&fp,"Equipment_ID:",strlen("Equipment_ID:"),&bws);
|
||||
f_write(&fp,Init_Data_Equipment.Equipment_ID,strlen(Init_Data_Equipment.Equipment_ID),&bws);
|
||||
f_write(&fp,"\r\n",2,&bws);
|
||||
|
||||
f_write(&fp,"TCP_Ip:",strlen("TCP_Ip:"),&bws);
|
||||
f_write(&fp,Init_Data_Equipment.Bc25_Ip,strlen(Init_Data_Equipment.Bc25_Ip),&bws);
|
||||
f_write(&fp,"\r\n",2,&bws);
|
||||
|
||||
f_write(&fp,"TCP_Port:",strlen("TCP_Port:"),&bws);
|
||||
f_write(&fp,Init_Data_Equipment.Bc25_Port,strlen(Init_Data_Equipment.Bc25_Port),&bws);
|
||||
f_write(&fp,"\r\n",2,&bws);
|
||||
|
||||
f_write(&fp,"Wifi_SSID:",strlen("Wifi_SSID:"),&bws);
|
||||
f_write(&fp,Init_Data_Equipment.ESP8266_AP_SSIDs,strlen(Init_Data_Equipment.ESP8266_AP_SSIDs),&bws);
|
||||
f_write(&fp,"\r\n",2,&bws);
|
||||
|
||||
f_write(&fp,"Wifi_Pwd:",strlen("Wifi_Pwd:"),&bws);
|
||||
f_write(&fp,Init_Data_Equipment.ESP8266_AP_PWDs,strlen(Init_Data_Equipment.ESP8266_AP_PWDs),&bws);
|
||||
f_write(&fp,"\r\n",2,&bws);
|
||||
|
||||
f_write(&fp,"Wifi_Port:",strlen("Wifi_Port:"),&bws);
|
||||
f_write(&fp,Init_Data_Equipment.ESP8266_AP_Ports,strlen(Init_Data_Equipment.ESP8266_AP_Ports),&bws);
|
||||
f_write(&fp,"\r\n",2,&bws);
|
||||
|
||||
f_write(&fp,"Measure_Interval:",strlen("Measure_Interval:"),&bws);
|
||||
f_write(&fp,Init_Data_Equipment.Measure_Interval,strlen(Init_Data_Equipment.Measure_Interval),&bws);
|
||||
f_write(&fp,"\r\n",2,&bws);
|
||||
|
||||
f_write(&fp,"Pub_Interval:",strlen("Pub_Interval:"),&bws);
|
||||
f_write(&fp,Init_Data_Equipment.Pub_Time,strlen(Init_Data_Equipment.Pub_Time),&bws);
|
||||
f_write(&fp,"\r\n",2,&bws);
|
||||
|
||||
f_write(&fp,"Appointment_Time:",strlen("Appointment_Time:"),&bws);
|
||||
f_write(&fp,Init_Data_Equipment.appointment_time,strlen(Init_Data_Equipment.appointment_time),&bws);
|
||||
f_write(&fp,"\r\n",2,&bws);
|
||||
|
||||
f_write(&fp,"Measure_Mode:",strlen("Measure_Mode:"),&bws);
|
||||
f_write(&fp,Init_Data_Equipment.measure_mode,strlen(Init_Data_Equipment.measure_mode),&bws);
|
||||
f_write(&fp,"\r\n",2,&bws);
|
||||
|
||||
// f_write(&fp,"IOT_Username:",strlen("IOT_Username:"),&bws);
|
||||
// f_write(&fp,Init_Data_Equipment.measure_mode,strlen(Init_Data_Equipment.IOT_Username),&bws);
|
||||
// f_write(&fp,"\r\n",2,&bws);
|
||||
|
||||
// f_write(&fp,"IOT_Password:",strlen("IOT_Password:"),&bws);
|
||||
// f_write(&fp,Init_Data_Equipment.measure_mode,strlen(Init_Data_Equipment.IOT_Password),&bws);
|
||||
// f_write(&fp,"\r\n",2,&bws);
|
||||
|
||||
// f_write(&fp,"IOT_Theme_name:",strlen("IOT_Theme_name:"),&bws);
|
||||
// f_write(&fp,Init_Data_Equipment.measure_mode,strlen(Init_Data_Equipment.IOT_Theme_name),&bws);
|
||||
// f_write(&fp,"\r\n",2,&bws);
|
||||
|
||||
f_write(&fp,"Equipment_ID,DateTime,Power-V,Latitude,N/S,Longitude,E/W,Ch1-SoilT_C,Ch1-SoilVWC_%,Ch1-Soil_DS,Ch2-SoilT_C,Ch2-SoilVWC_%,Ch2-Soil_DS,Ch3-SoilT_C,Ch3-SoilVWC_%,Ch3-Soil_DS,Ch4-SoilT_C,Ch4-SoilVWC_%,Ch4-Soil_DS,Ch5-SoilT_C,Ch5-SoilVWC_%,Ch5-Soil_DS,Ch6-SoilT_C,Ch6-SoilVWC_%,Ch6-Soil_DS,qxz-Temperature_C,qxz-Humidity_%RH,qxz-AirPressure_hPa,qxz-WindSpeed_m/s,qxz-WindDirection_<6E><5F>,qxz-Rainfall_mm,qxz-Illuminance_lux\r\n",
|
||||
strlen("Equipment_ID,DateTime,Power-V,Latitude,N/S,Longitude,E/W,Ch1-SoilT_C,Ch1-SoilVWC_%,Ch1-Soil_DS,Ch2-SoilT_C,Ch2-SoilVWC_%,Ch2-Soil_DS,Ch3-SoilT_C,Ch3-SoilVWC_%,Ch3-Soil_DS,Ch4-SoilT_C,Ch4-SoilVWC_%,Ch4-Soil_DS,Ch5-SoilT_C,Ch5-SoilVWC_%,Ch5-Soil_DS,Ch6-SoilT_C,Ch6-SoilVWC_%,Ch6-Soil_DS,qxz-Temperature_C,qxz-Humidity_%RH,qxz-AirPressure_hPa,qxz-WindSpeed_m/s,qxz-WindDirection_<6E><5F>,qxz-Rainfall_mm,qxz-Illuminance_lux\r\n"),&bws);
|
||||
f_close(&fp);
|
||||
}
|
||||
res=f_open(&fp,"BC25.txt",FA_READ | FA_WRITE | FA_OPEN_ALWAYS );//0:/
|
||||
if(res!=FR_OK) //<2F><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>
|
||||
{
|
||||
i=0;
|
||||
while((res!=FR_OK)&(i<100))
|
||||
{
|
||||
i++;
|
||||
f_close(&fp);
|
||||
f_mount(NULL, DiskPath, 0);;
|
||||
f_mount(&fs1, "0:", 1);
|
||||
res=f_open(&fp,"BC25.txt",FA_READ | FA_WRITE | FA_OPEN_ALWAYS );//0:/
|
||||
}
|
||||
if(i>98)
|
||||
{
|
||||
//u5_printf("open BC25.txt fail\r\n");
|
||||
return FR_NO_PATH ;
|
||||
}
|
||||
|
||||
}
|
||||
// if(res==FR_OK) //<2F>ɹ<F2BFAAB3>
|
||||
// {
|
||||
f_lseek (&fp,f_size(&fp));
|
||||
f_write(&fp,data_common1.Pack_data,strlen(data_common1.Pack_data),&bws);
|
||||
f_write(&fp,"\r\n",2,&bws);
|
||||
f_close(&fp);
|
||||
// }
|
||||
|
||||
f_mount(NULL, DiskPath, 0);
|
||||
return FR_OK;
|
||||
}
|
||||
|
||||
|
||||
void Write_Test(void)
|
||||
{
|
||||
f_mount(&fs1, "0:", 1);
|
||||
f_open(&fp,"test.txt",FA_READ | FA_WRITE | FA_OPEN_ALWAYS );
|
||||
f_lseek (&fp,f_size(&fp));
|
||||
f_write(&fp,"Equipment_ID,DateTime,Power-V,Latitude,N/S,Longitude,E/W,Ch1-SoilT_C,Ch1-SoilVWC_%,Ch1-Soil_DS,Ch2-SoilT_C,Ch2-SoilVWC_%,Ch2-Soil_DS,Ch3-SoilT_C,Ch3-SoilVWC_%,Ch3-Soil_DS,Ch4-SoilT_C,Ch4-SoilVWC_%,Ch4-Soil_DS,Ch5-SoilT_C,Ch5-SoilVWC_%,Ch5-Soil_DS,Ch6-SoilT_C,Ch6-SoilVWC_%,Ch6-Soil_DS,qxz-Temperature_C,qxz-Humidity_%RH,qxz-AirPressure_hPa,qxz-WindSpeed_m/s,qxz-WindDirection_<6E><5F>,qxz-Rainfall_mm,qxz-Illuminance_lux,IOT_Cpin,IOT_Csq,IOT_Net,Tf_Tol,Tf_Free\r\n",
|
||||
strlen("Equipment_ID,DateTime,Power-V,Latitude,N/S,Longitude,E/W,Ch1-SoilT_C,Ch1-SoilVWC_%,Ch1-Soil_DS,Ch2-SoilT_C,Ch2-SoilVWC_%,Ch2-Soil_DS,Ch3-SoilT_C,Ch3-SoilVWC_%,Ch3-Soil_DS,Ch4-SoilT_C,Ch4-SoilVWC_%,Ch4-Soil_DS,Ch5-SoilT_C,Ch5-SoilVWC_%,Ch5-Soil_DS,Ch6-SoilT_C,Ch6-SoilVWC_%,Ch6-Soil_DS,qxz-Temperature_C,qxz-Humidity_%RH,qxz-AirPressure_hPa,qxz-WindSpeed_m/s,qxz-WindDirection_<6E><5F>,qxz-Rainfall_mm,qxz-Illuminance_lux,IOT_Cpin,IOT_Csq,IOT_Net,Tf_Tol,Tf_Free\r\n"),&bws);
|
||||
f_write(&fp,data_common1.Pack_data,strlen(data_common1.Pack_data),&bws);
|
||||
f_write(&fp,"\r\n",2,&bws);
|
||||
f_close(&fp);
|
||||
f_mount(NULL, "0:", 1);
|
||||
// free(fs);
|
||||
}
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <09><> <20><> <20><>: Fil_delete()
|
||||
* <09><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: ɾ<><C9BE><EFBFBD>ļ<EFBFBD>
|
||||
* <09><> <20><> <20><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD> name
|
||||
* <20><> <20><> <20><><EFBFBD><EFBFBD>
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
FRESULT Fil_delete(char *names)
|
||||
{
|
||||
FRESULT result;
|
||||
char namebuff[10]="\0";
|
||||
sprintf(namebuff,"%s%s",names,".txt");
|
||||
f_mount(&fs1, "0:", 1);
|
||||
result = f_unlink(namebuff);
|
||||
f_close(&fp);
|
||||
if(result == FR_OK)
|
||||
{
|
||||
|
||||
}//u5_printf("delete sucess");
|
||||
f_mount(NULL, DiskPath, 0);;
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <09><> <20><> <20><>: txt_size_read()
|
||||
* <09><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <20><>ȡ<EFBFBD>ļ<EFBFBD><C4BC>Ĵ<EFBFBD>Сbyte
|
||||
* <09><> <20><> <20><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD> name
|
||||
* <20><> <20><> <20><><EFBFBD><EFBFBD>
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
u32 txt_size_read(char *fname)
|
||||
{
|
||||
// u8 i=0;
|
||||
FRESULT res;
|
||||
u32 txt_size;
|
||||
char name[20];
|
||||
sprintf(name,"%s%s",fname,".txt");
|
||||
res=f_mount(&fs1, "0:", 1);
|
||||
res=f_open(&fp,"0:/BC25.txt",FA_READ);
|
||||
if(res!=FR_OK) //<2F><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>
|
||||
{
|
||||
//u5_printf("open bc25txt size fail\r\n");
|
||||
return FR_NO_FILE;
|
||||
}
|
||||
txt_size=f_size(&fp);
|
||||
res=f_close(&fp);
|
||||
f_mount(NULL, DiskPath, 0);;
|
||||
return txt_size;
|
||||
}
|
||||
|
||||
uint16_t Count(char *P)
|
||||
{
|
||||
uint16_t count = 0;
|
||||
while((P[count++] != 0x0a)&&(P[count - 1] != 0x0d) && count < max_transmission+15);
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <09><> <20><> <20><>: FATFS_Read_TF()
|
||||
* <09><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: TF<54><46><EFBFBD><EFBFBD><EFBFBD>ݶ<EFBFBD>ȡ
|
||||
* <09><> <20><> <20><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD> name <20><>ʼλ<CABC><CEBB> start <20><><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD> len
|
||||
* <20><> <20><> <20><><EFBFBD><EFBFBD>
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
|
||||
void FATFS_Read_TF(char *fname,u32 start_pos,u32 len)
|
||||
{
|
||||
FRESULT res;
|
||||
u32 tf_sendpos=0;
|
||||
u16 size_buf,Send_Len = 0,Save_Addr = 0;
|
||||
u8 times;
|
||||
u32 i,lens_quotient,len_remainder;//<2F>̣<EFBFBD><CCA3><EFBFBD><EFBFBD><EFBFBD>
|
||||
char rname[10];
|
||||
|
||||
if(BC25_Status.socket==0)return;
|
||||
memset(Tf_Read_Buff,0,sizeof(Tf_Read_Buff));
|
||||
memset(Send_Buf,0,sizeof(Send_Buf));
|
||||
memset(Temp_Buf,0,sizeof(Temp_Buf));
|
||||
EEPROM_ReadDWords(180,&tf_sendpos,1);//<2F><>ȡTF<54><46><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>λ<EFBFBD><CEBB>
|
||||
if(tf_sendpos>len)tf_sendpos=0;//<2F><>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>ɾ<EFBFBD><C9BE>
|
||||
|
||||
sprintf(rname,"%s%s",fname,".txt");
|
||||
lens_quotient=(len-tf_sendpos)/max_transmission;
|
||||
len_remainder=(len-tf_sendpos)%max_transmission;
|
||||
|
||||
memset(Tf_Read_Buff,0,sizeof(Tf_Read_Buff));
|
||||
if(osEventFlagsGet(EventFlagID_PROCESS)&EVENT_TFstore_BIT_6)
|
||||
{
|
||||
osDelay(3000);
|
||||
}
|
||||
res=f_mount(&fs1, "0:", 1);
|
||||
res=f_open(&fp,rname,FA_READ);
|
||||
times=0;
|
||||
|
||||
while((res!=FR_OK)&(times<100))
|
||||
{
|
||||
res=f_close(&fp);
|
||||
res=f_mount(&fs1, "0:", 1);
|
||||
res=f_open(&fp,rname,FA_READ);
|
||||
}
|
||||
f_lseek(&fp, start_pos+tf_sendpos);
|
||||
|
||||
for(i=0;i<lens_quotient;lens_quotient=((len-tf_sendpos)/max_transmission))//<2F><><EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD><EFBFBD><EFBFBD>max_transmission<6F>ֽ<EFBFBD>
|
||||
{
|
||||
if(osEventFlagsGet(EventFlagID_PROCESS)&EVENT_TFstore_BIT_6)//<2F>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD>ݴ洢
|
||||
{
|
||||
osEventFlagsClear(EventFlagID_PROCESS,EVENT_TFstore_BIT_6);
|
||||
//u5_printf("BC25 WAIT\r\n");
|
||||
res=f_close(&fp);
|
||||
osEventFlagsSet(EventFlagID_PROCESS,EVENT_TFread2_BIT_7);
|
||||
osEventFlagsWait(EventFlagID_PROCESS,EVENT_TFstore2_BIT_8,osFlagsWaitAll,5000 );
|
||||
res=f_close(&fp);
|
||||
/******<2A><>ȡ<EFBFBD><C8A1><EFBFBD>º<EFBFBD><C2BA><EFBFBD><EFBFBD>ļ<EFBFBD>******/
|
||||
len=txt_size_read("BC25");//
|
||||
//u5_printf("second-len:%ld\r\n",len);
|
||||
while((len<10)&(times<50))
|
||||
{
|
||||
len=txt_size_read("BC25");
|
||||
//u5_printf("second-len:%ld\r\n",len);
|
||||
times++;
|
||||
}
|
||||
lens_quotient=(len-tf_sendpos)/max_transmission;
|
||||
lens_quotient+=i;
|
||||
len_remainder=(len-tf_sendpos)%max_transmission;
|
||||
//u5_printf("i=%d\r\n",i);
|
||||
//u5_printf("lens_quotient=%d\r\n",lens_quotient);
|
||||
//u5_printf("len_remainder=%d\r\n",len_remainder);
|
||||
f_mount(&fs1, "0:", 1);
|
||||
res=f_open(&fp,rname,FA_READ);
|
||||
times=0;
|
||||
while((res!=FR_OK)&(times<100))
|
||||
{
|
||||
res=f_open(&fp,rname,FA_READ);
|
||||
times++;
|
||||
}
|
||||
if(res!=FR_OK) //<2F><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>
|
||||
{
|
||||
EEPROM_WriteDWords(180,&tf_sendpos,1);
|
||||
return;
|
||||
}
|
||||
f_lseek(&fp,tf_sendpos);
|
||||
//u5_printf("BC25 resum\r\n");
|
||||
}
|
||||
res=f_read(&fp,Tf_Read_Buff,max_transmission,&bws);
|
||||
Send_Len = Count(Tf_Read_Buff);
|
||||
Save_Addr = Send_Len + 1;
|
||||
memset(Send_Buf,0,sizeof(Send_Buf));
|
||||
memset(Temp_Buf,0,sizeof(Temp_Buf));
|
||||
memcpy(Temp_Buf,Tf_Read_Buff,Send_Len + 1);
|
||||
|
||||
if(strstr((const char*)Temp_Buf,(const char*)"Ch1-SoilT_C"))
|
||||
{
|
||||
IOT_Theme_TYPE = IOT_Theme_tablehead;
|
||||
}
|
||||
else if((Temp_Buf[0] > 0x2F) && (Temp_Buf[0] < 0x3A)) // Temp_Buf[0] <20>ڡ<EFBFBD>0<EFBFBD><30>---<2D><>9<EFBFBD><39>֮<EFBFBD><D6AE>
|
||||
{
|
||||
IOT_Theme_TYPE = IOT_Theme_data;
|
||||
}
|
||||
else
|
||||
{
|
||||
IOT_Theme_TYPE = IOT_Theme_config;
|
||||
}
|
||||
|
||||
sprintf(Send_Buf,"Pub,%d,%s*",Send_Len+1,Temp_Buf);
|
||||
Send_Len = Count(Send_Buf);
|
||||
times=0;
|
||||
|
||||
if(IOT_Theme_TYPE != IOT_Theme_config)
|
||||
{
|
||||
if(BC25_Senddata_mode(Send_Len + 2,Send_Buf))
|
||||
{
|
||||
//u5_printf("bc25 send fail:%ld\r\n",tf_sendpos);
|
||||
return;//<2F><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
tf_sendpos += Save_Addr;//<2F><><EFBFBD><EFBFBD>һ<EFBFBD>Σ<EFBFBD><CEA3><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>λ<EFBFBD><CEBB>
|
||||
f_lseek(&fp, start_pos+tf_sendpos);
|
||||
EEPROM_WriteDWords(180,&tf_sendpos,1);
|
||||
}
|
||||
|
||||
|
||||
while(tf_sendpos < len)
|
||||
{
|
||||
|
||||
res=f_read(&fp,Tf_Read_Buff,max_transmission,&bws);
|
||||
Send_Len = Count(Tf_Read_Buff);
|
||||
Save_Addr = Send_Len + 1;
|
||||
memset(Send_Buf,0,sizeof(Send_Buf));
|
||||
memset(Temp_Buf,0,sizeof(Temp_Buf));
|
||||
memcpy(Temp_Buf,Tf_Read_Buff,Send_Len + 1);
|
||||
sprintf(Send_Buf,"Pub,%d,%s*",Send_Len+1,Temp_Buf);
|
||||
Send_Len = Count(Send_Buf);
|
||||
|
||||
if(IOT_Theme_TYPE != IOT_Theme_config)
|
||||
{
|
||||
if(BC25_Senddata_mode(Send_Len + 2,Send_Buf))
|
||||
{
|
||||
//u5_printf("bc25 send fail:%ld\r\n",tf_sendpos);
|
||||
return;//<2F><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>
|
||||
}
|
||||
}
|
||||
|
||||
tf_sendpos += Save_Addr;//<2F><><EFBFBD><EFBFBD>һ<EFBFBD>Σ<EFBFBD><CEA3><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>λ<EFBFBD><CEBB>
|
||||
f_lseek(&fp, start_pos+tf_sendpos);
|
||||
EEPROM_WriteDWords(180,&tf_sendpos,1);
|
||||
__nop();
|
||||
}
|
||||
tf_sendpos=0;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0
|
||||
EEPROM_WriteDWords(180,&tf_sendpos,1);
|
||||
res=f_close(&fp);
|
||||
f_mount(&fs1, "0:", 1);
|
||||
Fil_delete("BC25");//ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
}
|
||||
|
||||
/*
|
||||
*********************************************************************************************************
|
||||
* <09><> <20><> <20><>: Common_Data_Pack()
|
||||
* <09><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <20><><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD>
|
||||
* <09><> <20><> <20><><EFBFBD><EFBFBD>
|
||||
* <20><> <20><> <20><><EFBFBD><EFBFBD>
|
||||
*********************************************************************************************************
|
||||
*/
|
||||
void Common_Data_Pack(void)
|
||||
{
|
||||
|
||||
sprintf(data_common1.Time_DATA,"%c%c/%c%c/20%c%c %c%c:%c%c:%c%c",
|
||||
rtc_data[2],rtc_data[3],rtc_data[4],rtc_data[5],rtc_data[0],rtc_data[1],
|
||||
rtc_time[0],rtc_time[1],rtc_time[2],rtc_time[3],rtc_time[4],rtc_time[5]);//<2F><><EFBFBD>ں<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>洢
|
||||
memset(data_common1.Pack_data,0,sizeof(data_common1.Pack_data));
|
||||
sprintf(data_common1.Pack_data,"%s,%s,%s%s%s,%s,%s,%s,%s,%s,%s",
|
||||
Init_Data_Equipment.Equipment_ID,
|
||||
data_common1.Time_DATA,
|
||||
data_common1.ADC_DATA,
|
||||
data_common1.GPS_DATA,
|
||||
Sdi_Fram_Record_Structs.Ch1_RX_BUF,
|
||||
Sdi_Fram_Record_Structs.Ch2_RX_BUF,
|
||||
Sdi_Fram_Record_Structs.Ch3_RX_BUF,
|
||||
Sdi_Fram_Record_Structs.Ch4_RX_BUF,
|
||||
Sdi_Fram_Record_Structs.Ch5_RX_BUF,
|
||||
Sdi_Fram_Record_Structs.Ch6_RX_BUF,
|
||||
// Sdi_Fram_Record_Structs.Ch7_RX_BUF,
|
||||
// Sdi_Fram_Record_Structs.Ch8_RX_BUF,
|
||||
// Sdi_Fram_Record_Structs.Ch9_RX_BUF
|
||||
Sdi_Fram_Record_Structs.QXZ_RX_BUF
|
||||
|
||||
|
||||
);
|
||||
sprintf(data_common1.Pack_len,"%d,",strlen(data_common1.Pack_data)+2);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//<2F><><EFBFBD>Բ<EFBFBD><D4B2><EFBFBD>
|
||||
|
||||
if((data_common1.Pack_data[0] < 0x30) || (data_common1.Pack_data[0] > 0x39))
|
||||
{
|
||||
memset(data_common1.Pack_data,0,sizeof(data_common1.Pack_data));
|
||||
sprintf(data_common1.Pack_data,"%s\r\n","TESTTEST"
|
||||
|
||||
// Sdi_Fram_Record_Structs.Ch7_RX_BUF,
|
||||
// Sdi_Fram_Record_Structs.Ch8_RX_BUF,
|
||||
// Sdi_Fram_Record_Structs.Ch9_RX_BUF
|
||||
|
||||
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD>ʣ<EFBFBD><CAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//drv:<3A><><EFBFBD>̱<EFBFBD><CCB1><EFBFBD>("0:"/"1:")
|
||||
//total:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>λKB<4B><42>
|
||||
//free:ʣ<><CAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>λKB<4B><42>
|
||||
//<2F><><EFBFBD><EFBFBD>ֵ:0,<2C><><EFBFBD><EFBFBD>.<2E><><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
uint8_t exf_getfree(char *drv,u32 *total,u32 *frees)
|
||||
{
|
||||
FATFS *fs;
|
||||
|
||||
fs=malloc(700);
|
||||
FRESULT res;
|
||||
u32 fre_clust=0, fre_sect=0, tot_sect=0;
|
||||
//<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>
|
||||
res=f_mount(fs, "0", 1);
|
||||
res =f_getfree("0", (DWORD*)&fre_clust, &fs);
|
||||
if(res==0)
|
||||
{
|
||||
tot_sect=(fs->n_fatent-2)*fs->csize; //<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
fre_sect=fre_clust*fs->csize; //<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
*total=tot_sect>>1; //<2F><>λΪKB
|
||||
*frees=fre_sect>>1; //<2F><>λΪKB
|
||||
|
||||
*total=(*total)/1024; //<2F><>λΪM
|
||||
*frees=(*frees)/1024; //<2F><>λΪM
|
||||
}
|
||||
res=f_mount(NULL, "0", 1);
|
||||
free(fs);
|
||||
return res;
|
||||
}
|
||||
|
||||
/***************************** END OF FILE *********************************/
|
||||
35
RTX5_20220316/Driver/FATFS/data_handle.h
Normal file
@ -0,0 +1,35 @@
|
||||
#ifndef _DATA_HANDLE_H
|
||||
#define _DATA_HANDLE_H
|
||||
|
||||
#include "bsp.h"
|
||||
#define max_transmission 300
|
||||
#define DiskPath "0:"
|
||||
typedef struct
|
||||
{
|
||||
char Pack_data[500];
|
||||
char Time_DATA[30];
|
||||
char ADC_DATA[10];
|
||||
char GPS_DATA[100];
|
||||
char SDI_DATA[300];
|
||||
char Pack_len[10];
|
||||
char BC25_Net;
|
||||
char BC25_Csq[3];
|
||||
char BC25_Cpin;
|
||||
char TF_Tol[10];
|
||||
char TF_Free[10];
|
||||
// char RS485_DATA[10];
|
||||
|
||||
// char WIFI_DATA[100];
|
||||
}data_common;
|
||||
extern u32 tf_totals,tf_frees;
|
||||
extern data_common data_common1;
|
||||
FRESULT Data_Write_TF(void);//,char *dat,u16 len
|
||||
void FATFS_Read_TF(char *fname,u32 start_pos,u32 len);
|
||||
u32 txt_size_read(char *fname);
|
||||
void FATFS_WriteFile(char *fname,char *dat,u16 len); //д<><D0B4><EFBFBD>ݵ<EFBFBD>SD<53><44>
|
||||
void Common_Data_Pack(void);//<2F><><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
static void ViewRootDir(void);//<2F><>ȡ<EFBFBD>ļ<EFBFBD>Ŀ¼ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
FRESULT Fil_delete(char *names);//ɾ<><C9BE><EFBFBD><EFBFBD>Ŀ¼<C4BF>ļ<EFBFBD>
|
||||
void Write_Test(void);
|
||||
uint8_t exf_getfree(char *drv,u32 *total,u32 *free);
|
||||
#endif
|
||||
59
RTX5_20220316/Driver/FATFS/doc/css_e.css
Normal file
@ -0,0 +1,59 @@
|
||||
* {margin: 0; padding: 0; border-width: 0;}
|
||||
body {margin: 8px; background-color: #e0ffff; font-color: black; font-family: serif; line-height: 133%; max-width: 1024px;}
|
||||
a:link {color: blue;}
|
||||
a:visited {color: darkmagenta;}
|
||||
a:hover {background-color: #a0ffff;}
|
||||
a:active {color: darkmagenta; overflow: hidden; outline:none; position: relative; top: 1px; left: 1px;}
|
||||
abbr {border-width: 1px;}
|
||||
|
||||
p {margin: 0 0 0.3em 1em;}
|
||||
em {font-style: normal; font-weight: bold; margin: 0 0.1em;}
|
||||
pre em {font-style: italic; font-weight: normal;}
|
||||
strong {}
|
||||
pre {border: 1px dashed gray; margin: 0.5em 1em; padding: 0.5em; line-height: 1.2em; font-family: monospace; background-color: white;}
|
||||
pre span.c {color: green;}
|
||||
pre span.k {color: blue;}
|
||||
tt {margin: 0 0.2em; font-family: monospace; }
|
||||
ol {margin: 0 2.5em;}
|
||||
ul {margin: 0 2em;}
|
||||
dl {margin: 0 1em;}
|
||||
dt {font-family: monospace;}
|
||||
dl.par dt {margin: 0.5em 0 0 0 ; font-style: italic; }
|
||||
dl.ret dt {margin: 0.5em 0 0 0 ; font-weight: bold;}
|
||||
dd {margin: 0 2em;}
|
||||
hr {border-width: 1px; margin: 1em;}
|
||||
div.abst {font-family: sans-serif;}
|
||||
div.para {clear: both; font-family: serif;}
|
||||
div.ret a {font-family: monospace; }
|
||||
.equ {text-indent: 0; margin: 1em 2em 1em;}
|
||||
.indent {margin-left: 2em;}
|
||||
.rset {float: right; margin: 0 0 0.5em 0.5em;}
|
||||
.lset {float: left; margin: 0 0.5em 0.5em 0.5em;}
|
||||
ul.flat li {list-style-type: none; margin: 0;}
|
||||
a.imglnk img {border: 1px solid;}
|
||||
.iequ {white-space: nowrap; font-weight: bold;}
|
||||
.clr {clear: both;}
|
||||
.it {font-style: italic;}
|
||||
.mfd {font-size: 0.7em; padding: 0 1px; border: 1px solid; white-space : nowrap}
|
||||
|
||||
h1 {line-height: 1em; font-size: 2em; font-family: sans-serif; padding: 0.3em 0 0.3em;}
|
||||
p.hdd {float: right; text-align: right; margin-top: 0.5em;}
|
||||
hr.hds {clear: both; margin-bottom: 1em;}
|
||||
|
||||
h2 {font-size: 1.6em; font-family: sans-serif; background-color: #d8d8FF; padding: 0.2em 0.5em; margin: 0 0 0.5em;}
|
||||
h3 {font-size: 1.5em; font-family: sans-serif; margin: 1.5em 0 0.5em;}
|
||||
h4 {font-size: 1.2em; font-family: sans-serif; margin: 1em 0 0.2em;}
|
||||
h5 {font-size: 1em; font-family: sans-serif; margin: 0.5em 0 0em;}
|
||||
small {font-size: 80%;}
|
||||
.indent {margin-left: 2em;}
|
||||
|
||||
/* Tables */
|
||||
table {margin: 0.5em 1em; border-collapse: collapse; border: 2px solid black; }
|
||||
th {background-color: white; border-style: solid; border-width: 1px 1px 2px; border-color: black; padding: 0 3px; vertical-align: top; white-space: nowrap;}
|
||||
td {background-color: white; border: 1px solid black; padding: 0 3px; vertical-align: top; line-height: 1.3em;}
|
||||
table.lst td:first-child {font-family: monospace;}
|
||||
table.lst2 td {font-family: monospace;}
|
||||
table caption {font-family: sans-serif; font-weight: bold;}
|
||||
tr.lst3 td { border-width: 2px 1px 1px; }
|
||||
|
||||
p.foot {clear: both; text-indent: 0; margin: 1em 0.5em 1em;}
|
||||
62
RTX5_20220316/Driver/FATFS/doc/css_j.css
Normal file
@ -0,0 +1,62 @@
|
||||
@charset "Shift_JIS";
|
||||
/* Common style sheet for Tech Notes */
|
||||
|
||||
* {margin: 0; padding: 0; border-width: 0;}
|
||||
body {margin: 8px; background-color: #e0ffff; font-color: black; font-family:"<22>l<EFBFBD>r <20>o<EFBFBD><6F><EFBFBD><EFBFBD>", serif; line-height: 150%; letter-spacing: 1px; max-width: 1024px;}
|
||||
a:link {color: blue;}
|
||||
a:visited {color: darkmagenta;}
|
||||
a:hover {background-color: #a0ffff;}
|
||||
a:active {color: darkmagenta; overflow: hidden; outline:none; position: relative; top: 1px; left: 1px;}
|
||||
abbr {border-width: 1px;}
|
||||
|
||||
p {text-indent: 1em; margin: 0 0 0.3em 0.5em;}
|
||||
em {font-style: normal; font-weight: bold; margin: 0 0.1em;}
|
||||
pre em {font-style: italic; font-weight: normal;}
|
||||
strong {}
|
||||
pre {border: 1px dashed gray; margin: 0.5em 1em; padding: 0.5em; line-height: 1.2em; letter-spacing: 0; font-family: monospace; background-color: white;}
|
||||
pre span.c {color: green;}
|
||||
pre span.k {color: blue;}
|
||||
tt {margin: 0 0.2em; letter-spacing: 0; font-family: monospace; }
|
||||
ol {margin: 0 2.5em;}
|
||||
ul {margin: 0 2em;}
|
||||
dl {margin: 0 1em;}
|
||||
dt {font-family: monospace;}
|
||||
dl.par dt {margin: 0.5em 0 0 0 ; font-style: italic; letter-spacing: 0;}
|
||||
dl.ret dt {margin: 0.5em 0 0 0 ; font-family: monospace; letter-spacing: 0; font-weight: bold;}
|
||||
dd {margin: 0 2em;}
|
||||
hr {border-width: 1px; margin: 1em;}
|
||||
div.abst {font-family: "<22>l<EFBFBD>r <20>o<EFBFBD>S<EFBFBD>V<EFBFBD>b<EFBFBD>N",sans-serif;}
|
||||
div.para {clear: both; font-family: "<22>l<EFBFBD>r <20>o<EFBFBD><6F><EFBFBD><EFBFBD>",serif;}
|
||||
div.ret a {font-family: monospace; }
|
||||
.equ {text-indent: 0; margin: 1em 2em 1em;}
|
||||
.indent {margin-left: 2em;}
|
||||
.rset {float: right; margin: 0 0 0.5em 0.5em;}
|
||||
.lset {float: left; margin: 0 0.5em 0.5em 0.5em;}
|
||||
ul.flat li {list-style-type: none; margin: 0;}
|
||||
a.imglnk img {border: 1px solid;}
|
||||
.iequ {white-space: nowrap; font-weight: bold;}
|
||||
.clr {clear: both;}
|
||||
.it {font-style: italic;}
|
||||
.mfd {font-size: 0.7em; padding: 0 1px; border: 1px solid; white-space : nowrap}
|
||||
|
||||
h1 {line-height: 1em; font-size: 2em; font-family: sans-serif; padding: 0.3em 0 0.3em;}
|
||||
p.hdd {float: right; text-align: right; margin-top: 0.5em;}
|
||||
hr.hds {clear: both; margin-bottom: 1em;}
|
||||
|
||||
h2 {font-size: 1.6em; font-family: "<22>l<EFBFBD>r <20>o<EFBFBD>S<EFBFBD>V<EFBFBD>b<EFBFBD>N",sans-serif; background-color: #d8d8FF; padding: 0.2em 0.5em; margin: 0 0 0.5em;}
|
||||
h3 {font-size: 1.5em; font-family: "<22>l<EFBFBD>r <20>o<EFBFBD>S<EFBFBD>V<EFBFBD>b<EFBFBD>N",sans-serif; margin: 1.5em 0 0.5em;}
|
||||
h4 {font-size: 1.2em; font-family: "<22>l<EFBFBD>r <20>o<EFBFBD>S<EFBFBD>V<EFBFBD>b<EFBFBD>N",sans-serif; margin: 1em 0 0.2em;}
|
||||
h5 {font-size: 1em; font-family: "<22>l<EFBFBD>r <20>o<EFBFBD>S<EFBFBD>V<EFBFBD>b<EFBFBD>N",sans-serif; margin: 0.5em 0 0em;}
|
||||
small {font-size: 80%;}
|
||||
.indent {margin-left: 2em;}
|
||||
|
||||
/* Tables */
|
||||
table {margin: 0.5em 1em; border-collapse: collapse; border: 2px solid black; letter-spacing: 0;}
|
||||
th {background-color: white; border-style: solid; border-width: 1px 1px 2px; border-color: black; padding: 0 3px; vertical-align: top;}
|
||||
td {background-color: white; border: 1px solid black; padding: 0 3px; vertical-align: top; line-height: 1.3em;}
|
||||
table.lst td:first-child {font-family: monospace; white-space: nowrap;}
|
||||
table.lst2 td {font-family: monospace; white-space: nowrap;}
|
||||
table caption {font-family: sans-serif; font-weight: bold;}
|
||||
tr.lst3 td {border-width: 2px 1px 1px; }
|
||||
|
||||
p.foot {clear: both; text-indent: 0; margin: 1em 0.5em 1em;}
|
||||
BIN
RTX5_20220316/Driver/FATFS/doc/img/f1.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
RTX5_20220316/Driver/FATFS/doc/img/f2.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
RTX5_20220316/Driver/FATFS/doc/img/f3.png
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
BIN
RTX5_20220316/Driver/FATFS/doc/img/f4.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
RTX5_20220316/Driver/FATFS/doc/img/f5.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
BIN
RTX5_20220316/Driver/FATFS/doc/img/f6.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
RTX5_20220316/Driver/FATFS/doc/img/layers.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
RTX5_20220316/Driver/FATFS/doc/img/layers3.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
RTX5_20220316/Driver/FATFS/doc/img/rwtest.png
Normal file
|
After Width: | Height: | Size: 19 KiB |
BIN
RTX5_20220316/Driver/FATFS/doc/img/rwtest2.png
Normal file
|
After Width: | Height: | Size: 8.0 KiB |
BIN
RTX5_20220316/Driver/FATFS/doc/img/rwtest3.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
114
RTX5_20220316/Driver/FATFS/doc/updates.txt
Normal file
@ -0,0 +1,114 @@
|
||||
R0.09, Sep 6, 2011
|
||||
f_mkfs() supports multiple partition to finish the multiple partition feature.
|
||||
Added f_fdisk(). (_MULTI_PARTITION = 2)
|
||||
|
||||
R0.08b, Jan 15, 2011
|
||||
Fast seek feature is also applied to f_read() and f_write().
|
||||
f_lseek() reports required table size on creating CLMP.
|
||||
Extended format syntax of f_printf function.
|
||||
Ignores duplicated directory separators in given path names.
|
||||
|
||||
R0.08a, Aug 16, 2010
|
||||
Added f_getcwd(). (_FS_RPATH = 2)
|
||||
Added sector erase feature. (_USE_ERASE)
|
||||
Moved file lock semaphore table from fs object to the bss.
|
||||
Fixed a wrong directory entry is created on non-LFN cfg when the given name contains ';'.
|
||||
Fixed f_mkfs() creates wrong FAT32 volume.
|
||||
|
||||
R0.08, May 15, 2010
|
||||
Added a memory configuration option. (_USE_LFN)
|
||||
Added file lock feature. (_FS_SHARE)
|
||||
Added fast seek feature. (_USE_FASTSEEK)
|
||||
Changed some types on the API, XCHAR->TCHAR.
|
||||
Changed fname member in the FILINFO structure on Unicode cfg.
|
||||
String functions support UTF-8 encoding files on Unicode cfg.
|
||||
|
||||
R0.07e, Nov 3, 2009
|
||||
Separated out configuration options from ff.h to ffconf.h.
|
||||
Added a configuration option, _LFN_UNICODE.
|
||||
Fixed f_unlink() fails to remove a sub-dir on _FS_RPATH.
|
||||
Fixed name matching error on the 13 char boundary.
|
||||
Changed f_readdir() to return the SFN with always upper case on non-LFN cfg.
|
||||
|
||||
R0.07c, Jun 21, 2009
|
||||
Fixed f_unlink() may return FR_OK on error.
|
||||
Fixed wrong cache control in f_lseek().
|
||||
Added relative path feature.
|
||||
Added f_chdir().
|
||||
Added f_chdrive().
|
||||
Added proper case conversion to extended characters.
|
||||
|
||||
R0.07a, Apr 14, 2009
|
||||
Separated out OS dependent code on re-entrant configuration.
|
||||
Added multiple sector size support.
|
||||
|
||||
R0.07, Apr 01, 2009
|
||||
Merged Tiny-FatFs into FatFs as a buffer configuration option.
|
||||
Added long file name support.
|
||||
Added multiple code page support.
|
||||
Added re-entrancy for multitask operation.
|
||||
Added auto cluster size selection to f_mkfs().
|
||||
Added rewind option to f_readdir().
|
||||
Changed result code of critical errors.
|
||||
Renamed string functions to avoid name collision.
|
||||
|
||||
R0.06, Apr 01, 2008
|
||||
Added f_forward. (Tiny-FatFs)
|
||||
Added string functions: fgets, fputc, fputs and fprintf.
|
||||
Improved performance of f_lseek on moving to the same or following cluster.
|
||||
|
||||
R0.05a, Feb 03, 2008
|
||||
Added f_truncate.
|
||||
Added f_utime.
|
||||
Fixed off by one error at FAT sub-type determination.
|
||||
Fixed btr in f_read can be mistruncated.
|
||||
Fixed cached sector is left not flushed when create and close without write.
|
||||
|
||||
R0.05, Aug 26, 2007
|
||||
Changed arguments of f_read, f_write.
|
||||
Changed arguments of f_mkfs. (FatFs)
|
||||
Fixed f_mkfs on FAT32 creates incorrect FSInfo. (FatFs)
|
||||
Fixed f_mkdir on FAT32 creates incorrect directory. (FatFs)
|
||||
|
||||
R0.04b, May 05, 2007
|
||||
Added _USE_NTFLAG option.
|
||||
Added FSInfo support.
|
||||
Fixed some problems corresponds to FAT32. (Tiny-FatFs)
|
||||
Fixed DBCS name can result FR_INVALID_NAME.
|
||||
Fixed short seek (<= csize) collapses the file object.
|
||||
|
||||
R0.04a, Apr 01, 2007
|
||||
Supported multiple partitions on a plysical drive. (FatFs)
|
||||
Added minimization level 3.
|
||||
Added a capability of extending file size to f_lseek.
|
||||
Fixed an endian sensitive code in f_mkfs. (FatFs)
|
||||
Fixed a problem corresponds to FAT32 support. (Tiny-FatFs)
|
||||
|
||||
R0.04, Feb 04, 2007
|
||||
Supported multiple drive system. (FatFs)
|
||||
Changed some APIs for multiple drive system.
|
||||
Added f_mkfs. (FatFs)
|
||||
Added _USE_FAT32 option. (Tiny-FatFs)
|
||||
|
||||
R0.03a, Dec 11, 2006
|
||||
Improved cluster scan algolithm to write files fast.
|
||||
Fixed f_mkdir creates incorrect directory on FAT32.
|
||||
|
||||
R0.03, Sep 22, 2006
|
||||
Added f_rename.
|
||||
Changed option _FS_MINIMUM to _FS_MINIMIZE.
|
||||
|
||||
R0.02a, Jun 10, 2006
|
||||
Added a configuration option _FS_MINIMUM.
|
||||
|
||||
R0.02, Jun 01, 2006
|
||||
Added FAT12.
|
||||
Removed unbuffered mode.
|
||||
Fixed a problem on small (<32M) patition.
|
||||
|
||||
R0.01, Apr 29, 2006
|
||||
First release
|
||||
|
||||
R0.00, Feb 26, 2006
|
||||
Prototype (not released)
|
||||
|
||||
147
RTX5_20220316/Driver/FATFS/exfuns/exfuns.c
Normal file
@ -0,0 +1,147 @@
|
||||
#include "string.h"
|
||||
#include "exfuns.h"
|
||||
#include "fattester.h"
|
||||
#include "malloc.h"
|
||||
#include "usart.h"
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB>ѧϰʹ<CFB0>ã<EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD><C9A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>κ<EFBFBD><CEBA><EFBFBD>;
|
||||
//ALIENTEKս<4B><D5BD>STM32<33><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//FATFS <20><>չ<EFBFBD><D5B9><EFBFBD><EFBFBD>
|
||||
//<2F><><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD>@ALIENTEK
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̳:www.openedv.com
|
||||
//<2F><EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD>:2012/9/18
|
||||
//<2F>汾<EFBFBD><E6B1BE>V1.0
|
||||
//<2F><>Ȩ<EFBFBD><C8A8><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؾ<EFBFBD><D8BE><EFBFBD>
|
||||
//Copyright(C) <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӿƼ<D3BF><C6BC><EFBFBD><EFBFBD><EFBFBD>˾ 2009-2019
|
||||
//All rights reserved
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//<2F>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
|
||||
const u8 *FILE_TYPE_TBL[6][13]=
|
||||
{
|
||||
{"BIN"}, //BIN<49>ļ<EFBFBD>
|
||||
{"LRC"}, //LRC<52>ļ<EFBFBD>
|
||||
{"NES"}, //NES<45>ļ<EFBFBD>
|
||||
{"TXT","C","H"}, //<2F>ı<EFBFBD><C4B1>ļ<EFBFBD>
|
||||
{"MP1","MP2","MP3","MP4","M4A","3GP","3G2","OGG","ACC","WMA","WAV","MID","FLAC"},//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
||||
{"BMP","JPG","JPEG","GIF"},//ͼƬ<CDBC>ļ<EFBFBD>
|
||||
};
|
||||
///////////////////////////////<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>,ʹ<><CAB9>malloc<6F><63>ʱ<EFBFBD><CAB1>////////////////////////////////////////////
|
||||
FATFS *fs[2]; //<2F><EFBFBD><DFBC><EFBFBD><EFBFBD>̹<EFBFBD><CCB9><EFBFBD><EFBFBD><EFBFBD>.
|
||||
FIL *file; //<2F>ļ<EFBFBD>1
|
||||
FIL *ftemp; //<2F>ļ<EFBFBD>2.
|
||||
UINT br,bw; //<2F><>д<EFBFBD><D0B4><EFBFBD><EFBFBD>
|
||||
FILINFO fileinfo; //<2F>ļ<EFBFBD><C4BC><EFBFBD>Ϣ
|
||||
DIR dir; //Ŀ¼
|
||||
|
||||
u8 *fatbuf; //SD<53><44><EFBFBD><EFBFBD><EFBFBD>ݻ<EFBFBD><DDBB><EFBFBD><EFBFBD><EFBFBD>
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
//Ϊexfuns<6E><73><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>
|
||||
//<2F><><EFBFBD><EFBFBD>ֵ:0,<2C>ɹ<EFBFBD>
|
||||
//1,ʧ<><CAA7>
|
||||
u8 exfuns_init(void)
|
||||
{
|
||||
fs[0]=(FATFS*)mymalloc(SRAMIN,sizeof(FATFS)); //Ϊ<><CEAA><EFBFBD><EFBFBD>0<EFBFBD><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>
|
||||
fs[1]=(FATFS*)mymalloc(SRAMIN,sizeof(FATFS)); //Ϊ<><CEAA><EFBFBD><EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>
|
||||
file=(FIL*)mymalloc(SRAMIN,sizeof(FIL)); //Ϊfile<6C><65><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>
|
||||
ftemp=(FIL*)mymalloc(SRAMIN,sizeof(FIL)); //Ϊftemp<6D><70><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>
|
||||
fatbuf=(u8*)mymalloc(SRAMIN,512); //Ϊfatbuf<75><66><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>
|
||||
if(fs[0]&&fs[1]&&file&&ftemp&&fatbuf)return 0; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>ʧ<EFBFBD><CAA7>,<2C><>ʧ<EFBFBD><CAA7>.
|
||||
else return 1;
|
||||
}
|
||||
|
||||
//<2F><>Сд<D0A1><D0B4>ĸתΪ<D7AA><CEAA>д<EFBFBD><D0B4>ĸ,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C>ֲ<F2B1A3B3><D6B2><EFBFBD>.
|
||||
u8 char_upper(u8 c)
|
||||
{
|
||||
if(c<'A')return c;//<2F><><EFBFBD><EFBFBD>,<2C><><EFBFBD>ֲ<EFBFBD><D6B2><EFBFBD>.
|
||||
if(c>='a')return c-0x20;//<2F><>Ϊ<EFBFBD><CEAA>д.
|
||||
else return c;//<2F><>д,<2C><><EFBFBD>ֲ<EFBFBD><D6B2><EFBFBD>
|
||||
}
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//fname:<3A>ļ<EFBFBD><C4BC><EFBFBD>
|
||||
//<2F><><EFBFBD><EFBFBD>ֵ:0XFF,<2C><>ʾ<EFBFBD><EFBFBD>ʶ<EFBFBD><CAB6><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD>.
|
||||
// <20><><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>С<EFBFBD><D0A1>.
|
||||
u8 f_typetell(u8 *fname)
|
||||
{
|
||||
u8 tbuf[5];
|
||||
u8 *attr='\0';//<2F><><EFBFBD><D7BA>
|
||||
u8 i=0,j;
|
||||
while(i<250)
|
||||
{
|
||||
i++;
|
||||
if(*fname=='\0')break;//ƫ<>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||
fname++;
|
||||
}
|
||||
if(i==250)return 0XFF;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>.
|
||||
for(i=0;i<5;i++)//<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><D7BA>
|
||||
{
|
||||
fname--;
|
||||
if(*fname=='.')
|
||||
{
|
||||
fname++;
|
||||
attr=fname;
|
||||
break;
|
||||
}
|
||||
}
|
||||
strcpy((char *)tbuf,(const char*)attr);//copy
|
||||
for(i=0;i<4;i++)tbuf[i]=char_upper(tbuf[i]);//ȫ<><C8AB><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>д
|
||||
for(i=0;i<6;i++)
|
||||
{
|
||||
for(j=0;j<13;j++)
|
||||
{
|
||||
if(*FILE_TYPE_TBL[i][j]==0)break;//<2F><><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD>û<EFBFBD>пɶԱȵij<C8B5>Ա<EFBFBD><D4B1>.
|
||||
if(strcmp((const char *)FILE_TYPE_TBL[i][j],(const char *)tbuf)==0)//<2F>ҵ<EFBFBD><D2B5><EFBFBD>
|
||||
{
|
||||
return (i<<4)|j;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0XFF;//û<>ҵ<EFBFBD>
|
||||
}
|
||||
|
||||
//<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD>ʣ<EFBFBD><CAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//drv:<3A><><EFBFBD>̱<EFBFBD><CCB1><EFBFBD>("0:"/"1:")
|
||||
//total:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>λKB<4B><42>
|
||||
//free:ʣ<><CAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>λKB<4B><42>
|
||||
//<2F><><EFBFBD><EFBFBD>ֵ:0,<2C><><EFBFBD><EFBFBD>.<2E><><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
u8 exf_getfree(u8 *drv,u32 *total,u32 *free)
|
||||
{
|
||||
FATFS *fs1;
|
||||
u8 res;
|
||||
DWORD fre_clust=0, fre_sect=0, tot_sect=0;
|
||||
//<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>
|
||||
res = f_getfree((const TCHAR*)drv, &fre_clust, &fs1);
|
||||
if(res==0)
|
||||
{
|
||||
tot_sect=(fs1->n_fatent-2)*fs1->csize; //<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
fre_sect=fre_clust*fs1->csize; //<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#if _MAX_SS!=512 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD>512<31>ֽ<EFBFBD>,<2C><>ת<EFBFBD><D7AA>Ϊ512<31>ֽ<EFBFBD>
|
||||
tot_sect*=fs1->ssize/512;
|
||||
fre_sect*=fs1->ssize/512;
|
||||
#endif
|
||||
*total=tot_sect>>1; //<2F><>λΪKB
|
||||
*free=fre_sect>>1; //<2F><>λΪKB
|
||||
}
|
||||
return res;
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
42
RTX5_20220316/Driver/FATFS/exfuns/exfuns.h
Normal file
@ -0,0 +1,42 @@
|
||||
#ifndef __EXFUNS_H
|
||||
#define __EXFUNS_H
|
||||
//#include "sys.h"
|
||||
#include "ff.h"
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
extern FATFS *fs[2];
|
||||
extern FIL *file;
|
||||
extern FIL *ftemp;
|
||||
extern UINT br,bw;
|
||||
extern FILINFO fileinfo;
|
||||
extern DIR dir;
|
||||
extern u8 *fatbuf;//SD<53><44><EFBFBD><EFBFBD><EFBFBD>ݻ<EFBFBD><DDBB><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
|
||||
//f_typetell<6C><6C><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD>Ͷ<EFBFBD><CDB6><EFBFBD>
|
||||
//<2F><><EFBFBD>ݱ<EFBFBD>FILE_TYPE_TBL<42><4C><EFBFBD><EFBFBD>.<2E><>exfuns.c<><63><EFBFBD>涨<EFBFBD><E6B6A8>
|
||||
#define T_BIN 0X00 //bin<69>ļ<EFBFBD>
|
||||
#define T_LRC 0X10 //lrc<72>ļ<EFBFBD>
|
||||
#define T_NES 0X20 //nes<65>ļ<EFBFBD>
|
||||
#define T_TEXT 0X30 //.txt<78>ļ<EFBFBD>
|
||||
#define T_C 0X31 //.c<>ļ<EFBFBD>
|
||||
#define T_H 0X32 //.h<>ļ<EFBFBD>
|
||||
#define T_FLAC 0X4C //flac<61>ļ<EFBFBD>
|
||||
#define T_BMP 0X50 //bmp<6D>ļ<EFBFBD>
|
||||
#define T_JPG 0X51 //jpg<70>ļ<EFBFBD>
|
||||
#define T_JPEG 0X52 //jpeg<65>ļ<EFBFBD>
|
||||
#define T_GIF 0X53 //gif<69>ļ<EFBFBD>
|
||||
|
||||
|
||||
u8 exfuns_init(void); //<2F><><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>
|
||||
u8 f_typetell(u8 *fname); //ʶ<><CAB6><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
|
||||
u8 exf_getfree(u8 *drv,u32 *total,u32 *free);//<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʣ<EFBFBD><CAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
u32 exf_fdsize(u8 *fdname); //<2F>õ<EFBFBD><C3B5>ļ<EFBFBD><C4BC>д<EFBFBD>С
|
||||
u8* exf_get_src_dname(u8* dpfn);
|
||||
u8 exf_copy(u8(*fcpymsg)(u8*pname,u8 pct,u8 mode),u8 *psrc,u8 *pdst,u32 totsize,u32 cpdsize,u8 fwmode); //<2F>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
|
||||
u8 exf_fdcopy(u8(*fcpymsg)(u8*pname,u8 pct,u8 mode),u8 *psrc,u8 *pdst,u32 *totsize,u32 *cpdsize,u8 fwmode);//<2F>ļ<EFBFBD><C4BC>и<EFBFBD><D0B8><EFBFBD>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
308
RTX5_20220316/Driver/FATFS/exfuns/fattester.c
Normal file
@ -0,0 +1,308 @@
|
||||
#include "fattester.h"
|
||||
#include "mmc_sd.h"
|
||||
#include "usmart.h"
|
||||
#include "usart.h"
|
||||
#include "exfuns.h"
|
||||
#include "malloc.h"
|
||||
#include "ff.h"
|
||||
#include "string.h"
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB>ѧϰʹ<CFB0>ã<EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD><C9A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>κ<EFBFBD><CEBA><EFBFBD>;
|
||||
//ALIENTEKս<4B><D5BD>STM32<33><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//FATFS <20><><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD>
|
||||
//<2F><><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD>@ALIENTEK
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̳:www.openedv.com
|
||||
//<2F><EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD>:2012/9/18
|
||||
//<2F>汾<EFBFBD><E6B1BE>V1.0
|
||||
//<2F><>Ȩ<EFBFBD><C8A8><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؾ<EFBFBD><D8BE><EFBFBD>
|
||||
//Copyright(C) <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӿƼ<D3BF><C6BC><EFBFBD><EFBFBD><EFBFBD>˾ 2009-2019
|
||||
//All rights reserved
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//Ϊ<><CEAA><EFBFBD><EFBFBD>ע<EFBFBD>Ṥ<EFBFBD><E1B9A4><EFBFBD><EFBFBD>
|
||||
//drv:<3A>̷<EFBFBD>
|
||||
//<2F><><EFBFBD><EFBFBD>ֵ:ִ<>н<EFBFBD><D0BD><EFBFBD>
|
||||
u8 mf_mount(u8 drv)
|
||||
{
|
||||
return f_mount(drv,fs[drv]);
|
||||
}
|
||||
//<2F><><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD>µ<EFBFBD><C2B5>ļ<EFBFBD>
|
||||
//path:·<><C2B7>+<2B>ļ<EFBFBD><C4BC><EFBFBD>
|
||||
//mode:<3A><><EFBFBD><EFBFBD>ģʽ
|
||||
//<2F><><EFBFBD><EFBFBD>ֵ:ִ<>н<EFBFBD><D0BD><EFBFBD>
|
||||
u8 mf_open(u8*path,u8 mode)
|
||||
{
|
||||
u8 res;
|
||||
res=f_open(file,(const TCHAR*)path,mode);//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
||||
return res;
|
||||
}
|
||||
//<2F>ر<EFBFBD><D8B1>ļ<EFBFBD>
|
||||
//<2F><><EFBFBD><EFBFBD>ֵ:ִ<>н<EFBFBD><D0BD><EFBFBD>
|
||||
u8 mf_close(void)
|
||||
{
|
||||
f_close(file);
|
||||
return 0;
|
||||
}
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//len:<3A><><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><C4B3><EFBFBD>
|
||||
//<2F><><EFBFBD><EFBFBD>ֵ:ִ<>н<EFBFBD><D0BD><EFBFBD>
|
||||
u8 mf_read(u16 len)
|
||||
{
|
||||
u16 i,t;
|
||||
u8 res=0;
|
||||
u16 tlen=0;
|
||||
printf("\r\nRead file data is:\r\n");
|
||||
for(i=0;i<len/512;i++)
|
||||
{
|
||||
res=f_read(file,fatbuf,512,&br);
|
||||
if(res)
|
||||
{
|
||||
printf("Read Error:%d\r\n",res);
|
||||
break;
|
||||
}else
|
||||
{
|
||||
tlen+=br;
|
||||
for(t=0;t<br;t++)printf("%c",fatbuf[t]);
|
||||
}
|
||||
}
|
||||
if(len%512)
|
||||
{
|
||||
res=f_read(file,fatbuf,len%512,&br);
|
||||
if(res) //<2F><><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD><EFBFBD><EFBFBD>
|
||||
{
|
||||
printf("\r\nRead Error:%d\r\n",res);
|
||||
}else
|
||||
{
|
||||
tlen+=br;
|
||||
for(t=0;t<br;t++)printf("%c",fatbuf[t]);
|
||||
}
|
||||
}
|
||||
if(tlen)printf("\r\nReaded data len:%d\r\n",tlen);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||
printf("Read data over\r\n");
|
||||
return res;
|
||||
}
|
||||
//д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//dat:<3A><><EFBFBD>ݻ<EFBFBD><DDBB><EFBFBD><EFBFBD><EFBFBD>
|
||||
//len:д<>볤<EFBFBD><EBB3A4>
|
||||
//<2F><><EFBFBD><EFBFBD>ֵ:ִ<>н<EFBFBD><D0BD><EFBFBD>
|
||||
u8 mf_write(u8*dat,u16 len)
|
||||
{
|
||||
u8 res;
|
||||
|
||||
printf("\r\nBegin Write file...\r\n");
|
||||
printf("Write data len:%d\r\n",len);
|
||||
res=f_write(file,dat,len,&bw);
|
||||
if(res)
|
||||
{
|
||||
printf("Write Error:%d\r\n",res);
|
||||
}else printf("Writed data len:%d\r\n",bw);
|
||||
printf("Write data over.\r\n");
|
||||
return res;
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
||||
//path:·<><C2B7>
|
||||
//<2F><><EFBFBD><EFBFBD>ֵ:ִ<>н<EFBFBD><D0BD><EFBFBD>
|
||||
u8 mf_opendir(u8* path)
|
||||
{
|
||||
return f_opendir(&dir,(const TCHAR*)path);
|
||||
}
|
||||
//<2F><><EFBFBD><EFBFBD>ȡ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
||||
//<2F><><EFBFBD><EFBFBD>ֵ:ִ<>н<EFBFBD><D0BD><EFBFBD>
|
||||
u8 mf_readdir(void)
|
||||
{
|
||||
u8 res;
|
||||
char *fn;
|
||||
#if _USE_LFN
|
||||
fileinfo.lfsize = _MAX_LFN * 2 + 1;
|
||||
fileinfo.lfname = mymalloc(SRAMIN,fileinfo.lfsize);
|
||||
#endif
|
||||
res=f_readdir(&dir,&fileinfo);//<2F><>ȡһ<C8A1><D2BB><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||||
if(res!=FR_OK||fileinfo.fname[0]==0)
|
||||
{
|
||||
myfree(SRAMIN,fileinfo.lfname);
|
||||
return res;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||
}
|
||||
#if _USE_LFN
|
||||
fn=*fileinfo.lfname ? fileinfo.lfname : fileinfo.fname;
|
||||
#else
|
||||
fn=fileinfo.fname;;
|
||||
#endif
|
||||
printf("\r\n DIR info:\r\n");
|
||||
|
||||
printf("dir.id:%d\r\n",dir.id);
|
||||
printf("dir.index:%d\r\n",dir.index);
|
||||
printf("dir.sclust:%d\r\n",dir.sclust);
|
||||
printf("dir.clust:%d\r\n",dir.clust);
|
||||
printf("dir.sect:%d\r\n",dir.sect);
|
||||
|
||||
printf("\r\n");
|
||||
printf("File Name is:%s\r\n",fn);
|
||||
printf("File Size is:%d\r\n",fileinfo.fsize);
|
||||
printf("File data is:%d\r\n",fileinfo.fdate);
|
||||
printf("File time is:%d\r\n",fileinfo.ftime);
|
||||
printf("File Attr is:%d\r\n",fileinfo.fattrib);
|
||||
printf("\r\n");
|
||||
myfree(SRAMIN,fileinfo.lfname);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
||||
//path:·<><C2B7>
|
||||
//<2F><><EFBFBD><EFBFBD>ֵ:ִ<>н<EFBFBD><D0BD><EFBFBD>
|
||||
u8 mf_scan_files(u8 * path)
|
||||
{
|
||||
FRESULT res;
|
||||
char *fn; /* This function is assuming non-Unicode cfg. */
|
||||
#if _USE_LFN
|
||||
fileinfo.lfsize = _MAX_LFN * 2 + 1;
|
||||
fileinfo.lfname = mymalloc(SRAMIN,fileinfo.lfsize);
|
||||
#endif
|
||||
|
||||
res = f_opendir(&dir,(const TCHAR*)path); //<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>Ŀ¼
|
||||
if (res == FR_OK)
|
||||
{
|
||||
printf("\r\n");
|
||||
while(1)
|
||||
{
|
||||
res = f_readdir(&dir, &fileinfo); //<2F><>ȡĿ¼<C4BF>µ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ļ<EFBFBD>
|
||||
if (res != FR_OK || fileinfo.fname[0] == 0) break; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<2F><>ĩβ<C4A9><CEB2>,<2C>˳<EFBFBD>
|
||||
//if (fileinfo.fname[0] == '.') continue; //<2F><><EFBFBD><EFBFBD><EFBFBD>ϼ<EFBFBD>Ŀ¼
|
||||
#if _USE_LFN
|
||||
fn = *fileinfo.lfname ? fileinfo.lfname : fileinfo.fname;
|
||||
#else
|
||||
fn = fileinfo.fname;
|
||||
#endif /* It is a file. */
|
||||
printf("%s/", path);//<2F><>ӡ·<D3A1><C2B7>
|
||||
printf("%s\r\n", fn);//<2F><>ӡ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
||||
}
|
||||
}
|
||||
myfree(SRAMIN,fileinfo.lfname);
|
||||
return res;
|
||||
}
|
||||
//<2F><>ʾʣ<CABE><CAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//drv:<3A>̷<EFBFBD>
|
||||
//<2F><><EFBFBD><EFBFBD>ֵ:ʣ<><CAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28>ֽ<EFBFBD>)
|
||||
u32 mf_showfree(u8 *drv)
|
||||
{
|
||||
FATFS *fs1;
|
||||
u8 res;
|
||||
DWORD fre_clust=0, fre_sect=0, tot_sect=0;
|
||||
//<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>
|
||||
res = f_getfree((const TCHAR*)drv, &fre_clust, &fs1);
|
||||
if(res==0)
|
||||
{
|
||||
tot_sect = (fs1->n_fatent - 2) * fs1->csize;//<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
fre_sect = fre_clust * fs1->csize; //<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#if _MAX_SS!=512
|
||||
tot_sect*=fs1->ssize/512;
|
||||
fre_sect*=fs1->ssize/512;
|
||||
#endif
|
||||
if(tot_sect<20480)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1>10M
|
||||
{
|
||||
/* Print free space in unit of KB (assuming 512 bytes/sector) */
|
||||
printf("\r\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%d KB\r\n"
|
||||
"<EFBFBD><EFBFBD><EFBFBD>ÿռ<EFBFBD>:%d KB\r\n",
|
||||
tot_sect>>1,fre_sect>>1);
|
||||
}else
|
||||
{
|
||||
/* Print free space in unit of KB (assuming 512 bytes/sector) */
|
||||
printf("\r\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%d MB\r\n"
|
||||
"<EFBFBD><EFBFBD><EFBFBD>ÿռ<EFBFBD>:%d MB\r\n",
|
||||
tot_sect>>11,fre_sect>>11);
|
||||
}
|
||||
}
|
||||
return fre_sect;
|
||||
}
|
||||
//<2F>ļ<EFBFBD><C4BC><EFBFBD>дָ<D0B4><D6B8>ƫ<EFBFBD><C6AB>
|
||||
//offset:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7>ƫ<EFBFBD><C6AB><EFBFBD><EFBFBD>
|
||||
//<2F><><EFBFBD><EFBFBD>ֵ:ִ<>н<EFBFBD><D0BD><EFBFBD>.
|
||||
u8 mf_lseek(u32 offset)
|
||||
{
|
||||
return f_lseek(file,offset);
|
||||
}
|
||||
//<2F><>ȡ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>ǰ<EFBFBD><C7B0>дָ<D0B4><D6B8><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>.
|
||||
//<2F><><EFBFBD><EFBFBD>ֵ:λ<><CEBB>
|
||||
u32 mf_tell(void)
|
||||
{
|
||||
return f_tell(file);
|
||||
}
|
||||
//<2F><>ȡ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>С
|
||||
//<2F><><EFBFBD><EFBFBD>ֵ:<3A>ļ<EFBFBD><C4BC><EFBFBD>С
|
||||
u32 mf_size(void)
|
||||
{
|
||||
return f_size(file);
|
||||
}
|
||||
//<2F><><EFBFBD><EFBFBD>Ŀ¼
|
||||
//pname:Ŀ¼·<C2BC><C2B7>+<2B><><EFBFBD><EFBFBD>
|
||||
//<2F><><EFBFBD><EFBFBD>ֵ:ִ<>н<EFBFBD><D0BD><EFBFBD>
|
||||
u8 mf_mkdir(u8*pname)
|
||||
{
|
||||
return f_mkdir((const TCHAR *)pname);
|
||||
}
|
||||
//<2F><>ʽ<EFBFBD><CABD>
|
||||
//drv:<3A>̷<EFBFBD>
|
||||
//mode:ģʽ
|
||||
//au:<3A>ش<EFBFBD>С
|
||||
//<2F><><EFBFBD><EFBFBD>ֵ:ִ<>н<EFBFBD><D0BD><EFBFBD>
|
||||
u8 mf_fmkfs(u8 drv,u8 mode,u16 au)
|
||||
{
|
||||
return f_mkfs(drv,mode,au);//<2F><>ʽ<EFBFBD><CABD>,drv:<3A>̷<EFBFBD>;mode:ģʽ;au:<3A>ش<EFBFBD>С
|
||||
}
|
||||
//ɾ<><C9BE><EFBFBD>ļ<EFBFBD>/Ŀ¼
|
||||
//pname:<3A>ļ<EFBFBD>/Ŀ¼·<C2BC><C2B7>+<2B><><EFBFBD><EFBFBD>
|
||||
//<2F><><EFBFBD><EFBFBD>ֵ:ִ<>н<EFBFBD><D0BD><EFBFBD>
|
||||
u8 mf_unlink(u8 *pname)
|
||||
{
|
||||
return f_unlink((const TCHAR *)pname);
|
||||
}
|
||||
|
||||
//<2F><EFBFBD><DEB8>ļ<EFBFBD>/Ŀ¼<C4BF><C2BC><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD>Ŀ¼<C4BF><C2BC>ͬ,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6>ļ<EFBFBD>Ŷ!)
|
||||
//oldname:֮ǰ<D6AE><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//newname:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//<2F><><EFBFBD><EFBFBD>ֵ:ִ<>н<EFBFBD><D0BD><EFBFBD>
|
||||
u8 mf_rename(u8 *oldname,u8* newname)
|
||||
{
|
||||
return f_rename((const TCHAR *)oldname,(const TCHAR *)newname);
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡһ<C8A1><D2BB><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
||||
//size:Ҫ<><D2AA>ȡ<EFBFBD>ij<EFBFBD><C4B3><EFBFBD>
|
||||
void mf_gets(u16 size)
|
||||
{
|
||||
TCHAR* rbuf;
|
||||
rbuf=f_gets((TCHAR*)fatbuf,size,file);
|
||||
if(*rbuf==0)return ;//û<><C3BB><EFBFBD><EFBFBD><EFBFBD>ݶ<EFBFBD><DDB6><EFBFBD>
|
||||
else
|
||||
{
|
||||
printf("\r\nThe String Readed Is:%s\r\n",rbuf);
|
||||
}
|
||||
}
|
||||
//<2F><>Ҫ_USE_STRFUNC>=1
|
||||
//дһ<D0B4><D2BB><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>ļ<EFBFBD>
|
||||
//c:Ҫд<D2AA><D0B4><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD>
|
||||
//<2F><><EFBFBD><EFBFBD>ֵ:ִ<>н<EFBFBD><D0BD><EFBFBD>
|
||||
u8 mf_putc(u8 c)
|
||||
{
|
||||
return f_putc((TCHAR)c,file);
|
||||
}
|
||||
//д<>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
||||
//c:Ҫд<D2AA><D0B4><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
||||
//<2F><><EFBFBD><EFBFBD>ֵ:д<><D0B4><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
u8 mf_puts(u8*c)
|
||||
{
|
||||
return f_puts((TCHAR*)c,file);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
56
RTX5_20220316/Driver/FATFS/exfuns/fattester.h
Normal file
@ -0,0 +1,56 @@
|
||||
#ifndef __FATTESTER_H
|
||||
#define __FATTESTER_H
|
||||
#include "ff.h"
|
||||
#include "sys.h"
|
||||
|
||||
|
||||
u8 mf_mount(u8 drv);
|
||||
u8 mf_open(u8*path,u8 mode);
|
||||
u8 mf_close(void);
|
||||
u8 mf_read(u16 len);
|
||||
u8 mf_write(u8*dat,u16 len);
|
||||
u8 mf_opendir(u8* path);
|
||||
u8 mf_readdir(void);
|
||||
u8 mf_scan_files(u8 * path);
|
||||
u32 mf_showfree(u8 *drv);
|
||||
u8 mf_lseek(u32 offset);
|
||||
u32 mf_tell(void);
|
||||
u32 mf_size(void);
|
||||
u8 mf_mkdir(u8*pname);
|
||||
u8 mf_fmkfs(u8 drv,u8 mode,u16 au);
|
||||
u8 mf_unlink(u8 *pname);
|
||||
u8 mf_rename(u8 *oldname,u8* newname);
|
||||
void mf_gets(u16 size);
|
||||
u8 mf_putc(u8 c);
|
||||
u8 mf_puts(u8*c);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
62
RTX5_20220316/Driver/FATFS/exfuns/mycc936.c
Normal file
@ -0,0 +1,62 @@
|
||||
#include "ff.h"
|
||||
#include "fontupd.h"
|
||||
//#include "flash.h"
|
||||
|
||||
WCHAR ff_convert ( /* Converted code, 0 means conversion error */
|
||||
WCHAR src, /* Character code to be converted */
|
||||
UINT dir /* 0: Unicode to OEMCP, 1: OEMCP to Unicode */
|
||||
)
|
||||
{
|
||||
WCHAR t[2];
|
||||
WCHAR c;
|
||||
u32 i, li, hi;
|
||||
u16 n;
|
||||
u32 gbk2uni_offset=0;
|
||||
|
||||
if (src < 0x80)c = src;//ASCII,ֱ<>Ӳ<EFBFBD><D3B2><EFBFBD>ת<EFBFBD><D7AA>.
|
||||
else
|
||||
{
|
||||
if(dir) //GBK 2 UNICODE
|
||||
{
|
||||
gbk2uni_offset=ftinfo.ugbksize/2;
|
||||
}else //UNICODE 2 GBK
|
||||
{
|
||||
gbk2uni_offset=0;
|
||||
}
|
||||
//if(UK_FLAG)//<2F><><EFBFBD><EFBFBD>
|
||||
{
|
||||
/* Unicode to OEMCP */
|
||||
hi=ftinfo.ugbksize/2;//<2F>뿪.
|
||||
hi =hi / 4 - 1;
|
||||
li = 0;
|
||||
for (n = 16; n; n--)
|
||||
{
|
||||
i = li + (hi - li) / 2;
|
||||
SPI_Flash_Read((u8*)&t,ftinfo.ugbkaddr+i*4+gbk2uni_offset,4);//<2F><><EFBFBD><EFBFBD>8<EFBFBD><38><EFBFBD>ֽ<EFBFBD>
|
||||
if (src == t[0]) break;
|
||||
if (src > t[0])li = i;
|
||||
else hi = i;
|
||||
}
|
||||
c = n ? t[1] : 0;
|
||||
}
|
||||
//else c=0;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
WCHAR ff_wtoupper ( /* Upper converted character */
|
||||
WCHAR chr /* Input character */
|
||||
)
|
||||
{
|
||||
static const WCHAR tbl_lower[] = { 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0xA1, 0x00A2, 0x00A3, 0x00A5, 0x00AC, 0x00AF, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0x0FF, 0x101, 0x103, 0x105, 0x107, 0x109, 0x10B, 0x10D, 0x10F, 0x111, 0x113, 0x115, 0x117, 0x119, 0x11B, 0x11D, 0x11F, 0x121, 0x123, 0x125, 0x127, 0x129, 0x12B, 0x12D, 0x12F, 0x131, 0x133, 0x135, 0x137, 0x13A, 0x13C, 0x13E, 0x140, 0x142, 0x144, 0x146, 0x148, 0x14B, 0x14D, 0x14F, 0x151, 0x153, 0x155, 0x157, 0x159, 0x15B, 0x15D, 0x15F, 0x161, 0x163, 0x165, 0x167, 0x169, 0x16B, 0x16D, 0x16F, 0x171, 0x173, 0x175, 0x177, 0x17A, 0x17C, 0x17E, 0x192, 0x3B1, 0x3B2, 0x3B3, 0x3B4, 0x3B5, 0x3B6, 0x3B7, 0x3B8, 0x3B9, 0x3BA, 0x3BB, 0x3BC, 0x3BD, 0x3BE, 0x3BF, 0x3C0, 0x3C1, 0x3C3, 0x3C4, 0x3C5, 0x3C6, 0x3C7, 0x3C8, 0x3C9, 0x3CA, 0x430, 0x431, 0x432, 0x433, 0x434, 0x435, 0x436, 0x437, 0x438, 0x439, 0x43A, 0x43B, 0x43C, 0x43D, 0x43E, 0x43F, 0x440, 0x441, 0x442, 0x443, 0x444, 0x445, 0x446, 0x447, 0x448, 0x449, 0x44A, 0x44B, 0x44C, 0x44D, 0x44E, 0x44F, 0x451, 0x452, 0x453, 0x454, 0x455, 0x456, 0x457, 0x458, 0x459, 0x45A, 0x45B, 0x45C, 0x45E, 0x45F, 0x2170, 0x2171, 0x2172, 0x2173, 0x2174, 0x2175, 0x2176, 0x2177, 0x2178, 0x2179, 0x217A, 0x217B, 0x217C, 0x217D, 0x217E, 0x217F, 0xFF41, 0xFF42, 0xFF43, 0xFF44, 0xFF45, 0xFF46, 0xFF47, 0xFF48, 0xFF49, 0xFF4A, 0xFF4B, 0xFF4C, 0xFF4D, 0xFF4E, 0xFF4F, 0xFF50, 0xFF51, 0xFF52, 0xFF53, 0xFF54, 0xFF55, 0xFF56, 0xFF57, 0xFF58, 0xFF59, 0xFF5A, 0 };
|
||||
static const WCHAR tbl_upper[] = { 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x21, 0xFFE0, 0xFFE1, 0xFFE5, 0xFFE2, 0xFFE3, 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0x178, 0x100, 0x102, 0x104, 0x106, 0x108, 0x10A, 0x10C, 0x10E, 0x110, 0x112, 0x114, 0x116, 0x118, 0x11A, 0x11C, 0x11E, 0x120, 0x122, 0x124, 0x126, 0x128, 0x12A, 0x12C, 0x12E, 0x130, 0x132, 0x134, 0x136, 0x139, 0x13B, 0x13D, 0x13F, 0x141, 0x143, 0x145, 0x147, 0x14A, 0x14C, 0x14E, 0x150, 0x152, 0x154, 0x156, 0x158, 0x15A, 0x15C, 0x15E, 0x160, 0x162, 0x164, 0x166, 0x168, 0x16A, 0x16C, 0x16E, 0x170, 0x172, 0x174, 0x176, 0x179, 0x17B, 0x17D, 0x191, 0x391, 0x392, 0x393, 0x394, 0x395, 0x396, 0x397, 0x398, 0x399, 0x39A, 0x39B, 0x39C, 0x39D, 0x39E, 0x39F, 0x3A0, 0x3A1, 0x3A3, 0x3A4, 0x3A5, 0x3A6, 0x3A7, 0x3A8, 0x3A9, 0x3AA, 0x410, 0x411, 0x412, 0x413, 0x414, 0x415, 0x416, 0x417, 0x418, 0x419, 0x41A, 0x41B, 0x41C, 0x41D, 0x41E, 0x41F, 0x420, 0x421, 0x422, 0x423, 0x424, 0x425, 0x426, 0x427, 0x428, 0x429, 0x42A, 0x42B, 0x42C, 0x42D, 0x42E, 0x42F, 0x401, 0x402, 0x403, 0x404, 0x405, 0x406, 0x407, 0x408, 0x409, 0x40A, 0x40B, 0x40C, 0x40E, 0x40F, 0x2160, 0x2161, 0x2162, 0x2163, 0x2164, 0x2165, 0x2166, 0x2167, 0x2168, 0x2169, 0x216A, 0x216B, 0x216C, 0x216D, 0x216E, 0x216F, 0xFF21, 0xFF22, 0xFF23, 0xFF24, 0xFF25, 0xFF26, 0xFF27, 0xFF28, 0xFF29, 0xFF2A, 0xFF2B, 0xFF2C, 0xFF2D, 0xFF2E, 0xFF2F, 0xFF30, 0xFF31, 0xFF32, 0xFF33, 0xFF34, 0xFF35, 0xFF36, 0xFF37, 0xFF38, 0xFF39, 0xFF3A, 0 };
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0; tbl_lower[i] && chr != tbl_lower[i]; i++) ;
|
||||
|
||||
return tbl_lower[i] ? tbl_upper[i] : chr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
299
RTX5_20220316/Driver/FATFS/fattester.c
Normal file
@ -0,0 +1,299 @@
|
||||
#include "fattester.h"
|
||||
#include "mmc_sd.h"
|
||||
#include "usmart.h"
|
||||
#include "usart.h"
|
||||
#include "malloc.h"
|
||||
|
||||
#include "ff.h"
|
||||
|
||||
FATFS *fs[2]; // Work area (file system object) for logical drive
|
||||
FIL *file;
|
||||
FIL *ftemp;
|
||||
|
||||
UINT br,bw;
|
||||
FILINFO fileinfo;
|
||||
DIR dir;
|
||||
|
||||
|
||||
u8 *fatbuf;//SD<53><44><EFBFBD><EFBFBD><EFBFBD>ݻ<EFBFBD><DDBB><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
u8 test_init(void)
|
||||
{
|
||||
fs[0]=(FATFS*)mymalloc(SRAMIN,sizeof(FATFS)); //Ϊ<><CEAA><EFBFBD><EFBFBD>0<EFBFBD><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>
|
||||
fs[1]=(FATFS*)mymalloc(SRAMIN,sizeof(FATFS)); //Ϊ<><CEAA><EFBFBD><EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>
|
||||
file=(FIL*)mymalloc(SRAMIN,sizeof(FIL)); //Ϊfile<6C><65><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>
|
||||
ftemp=(FIL*)mymalloc(SRAMIN,sizeof(FIL)); //Ϊftemp<6D><70><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>
|
||||
fatbuf=(u8*)mymalloc(SRAMIN,512); //Ϊfatbuf<75><66><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>
|
||||
if(fs[0]&&fs[1]&&file&&ftemp&&fatbuf)return 0; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>ʧ<EFBFBD><CAA7>,<2C><>ʧ<EFBFBD><CAA7>.
|
||||
else return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//<2F><><EFBFBD>ش<EFBFBD><D8B4><EFBFBD>
|
||||
u8 mf_mount(u8 drv)
|
||||
{
|
||||
return f_mount(drv,fs[drv]);
|
||||
}
|
||||
//<2F><><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD>µ<EFBFBD><C2B5>ļ<EFBFBD>
|
||||
u8 mf_open(u8*path,u8 mode)
|
||||
{
|
||||
u8 res;
|
||||
res=f_open(file,(const TCHAR*)path,mode);//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
||||
return res;
|
||||
}
|
||||
//<2F>ر<EFBFBD><D8B1>ļ<EFBFBD>
|
||||
u8 mf_close(void)
|
||||
{
|
||||
f_close(file);
|
||||
return 0;
|
||||
}
|
||||
u8 mf_read(u16 len)
|
||||
{
|
||||
u16 i,t;
|
||||
u8 res=0;
|
||||
u16 tlen=0;
|
||||
printf("\r\nRead file data is:\r\n");
|
||||
for(i=0;i<len/512;i++)
|
||||
{
|
||||
res=f_read(file,fatbuf,512,&br);
|
||||
if(res)
|
||||
{
|
||||
printf("Read Error:%d\r\n",res);
|
||||
break;
|
||||
}else
|
||||
{
|
||||
tlen+=br;
|
||||
for(t=0;t<br;t++)printf("%c",fatbuf[t]);
|
||||
}
|
||||
}
|
||||
if(len%512)
|
||||
{
|
||||
res=f_read(file,fatbuf,len%512,&br);
|
||||
if(res) //<2F><><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD><EFBFBD><EFBFBD>
|
||||
{
|
||||
printf("Read Error:%d\r\n",res);
|
||||
}else
|
||||
{
|
||||
tlen+=br;
|
||||
for(t=0;t<br;t++)printf("%c",fatbuf[t]);
|
||||
}
|
||||
}
|
||||
if(tlen)printf("Readed data len:%d\r\n",tlen);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
||||
printf("Read data over\r\n");
|
||||
return res;
|
||||
}
|
||||
//д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
u8 mf_write(u8*dat,u16 len)
|
||||
{
|
||||
u8 res;
|
||||
|
||||
printf("\r\nWriting file data.\r\n");
|
||||
printf("Write data len:%d\r\n",len);
|
||||
res=f_write(file,dat,len,&bw);
|
||||
if(res)
|
||||
{
|
||||
printf("Write Error:%d\r\n",res);
|
||||
}else printf("Writed data len:%d\r\n",bw);
|
||||
printf("Write data over.\r\n");
|
||||
return res;
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
||||
u8 mf_opendir(u8* path)
|
||||
{
|
||||
return f_opendir(&dir,(const TCHAR*)path);
|
||||
}
|
||||
//<2F><><EFBFBD><EFBFBD>ȡ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
||||
u8 mf_readdir(void)
|
||||
{
|
||||
u8 res;
|
||||
char *fn;
|
||||
#if _USE_LFN
|
||||
fileinfo.lfsize = _MAX_LFN * 2 + 1;
|
||||
fileinfo.lfname = mymalloc(SRAMIN,fileinfo.lfsize);
|
||||
#endif
|
||||
res=f_readdir(&dir,&fileinfo);//<2F><>ȡһ<C8A1><D2BB><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||||
if(res!=FR_OK||fileinfo.fname[0]==0)
|
||||
{
|
||||
myfree(SRAMIN,fileinfo.lfname);
|
||||
return res;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||
}
|
||||
#if _USE_LFN
|
||||
fn=*fileinfo.lfname ? fileinfo.lfname : fileinfo.fname;
|
||||
#else
|
||||
fn=fileinfo.fname;;
|
||||
#endif
|
||||
printf("\r\n DIR info:\r\n");
|
||||
|
||||
printf("dir.id:%d\r\n",dir.id);
|
||||
printf("dir.index:%d\r\n",dir.index);
|
||||
printf("dir.sclust:%d\r\n",dir.sclust);
|
||||
printf("dir.clust:%d\r\n",dir.clust);
|
||||
printf("dir.sect:%d\r\n",dir.sect);
|
||||
|
||||
printf("\r\n");
|
||||
printf("File Name is:%s\r\n",fn);
|
||||
printf("File Size is:%d\r\n",fileinfo.fsize);
|
||||
printf("File data is:%d\r\n",fileinfo.fdate);
|
||||
printf("File time is:%d\r\n",fileinfo.ftime);
|
||||
printf("File Attr is:%d\r\n",fileinfo.fattrib);
|
||||
printf("\r\n");
|
||||
myfree(SRAMIN,fileinfo.lfname);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
||||
u8 mf_scan_files(u8 * path)
|
||||
{
|
||||
FRESULT res;
|
||||
char *fn; /* This function is assuming non-Unicode cfg. */
|
||||
#if _USE_LFN
|
||||
fileinfo.lfsize = _MAX_LFN * 2 + 1;
|
||||
fileinfo.lfname = mymalloc(SRAMIN,fileinfo.lfsize);
|
||||
#endif
|
||||
|
||||
res = f_opendir(&dir,(const TCHAR*)path); //<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>Ŀ¼
|
||||
if (res == FR_OK)
|
||||
{
|
||||
printf("\r\n");
|
||||
while(1)
|
||||
{
|
||||
res = f_readdir(&dir, &fileinfo); //<2F><>ȡĿ¼<C4BF>µ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ļ<EFBFBD>
|
||||
if (res != FR_OK || fileinfo.fname[0] == 0) break; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<2F><>ĩβ<C4A9><CEB2>,<2C>˳<EFBFBD>
|
||||
//if (fileinfo.fname[0] == '.') continue; //<2F><><EFBFBD><EFBFBD><EFBFBD>ϼ<EFBFBD>Ŀ¼
|
||||
#if _USE_LFN
|
||||
fn = *fileinfo.lfname ? fileinfo.lfname : fileinfo.fname;
|
||||
#else
|
||||
fn = fileinfo.fname;
|
||||
#endif /* It is a file. */
|
||||
printf("%s/", path);//<2F><>ӡ·<D3A1><C2B7>
|
||||
printf("%s\r\n", fn);//<2F><>ӡ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
||||
}
|
||||
}
|
||||
myfree(SRAMIN,fileinfo.lfname);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
//<2F><>ʾʣ<CABE><CAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
u32 mf_showfree(u8 *drv)
|
||||
{
|
||||
FATFS *fs1;
|
||||
u8 res;
|
||||
u32 fre_clust=0, fre_sect=0, tot_sect=0;
|
||||
//<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>
|
||||
res = f_getfree((const TCHAR*)drv, &fre_clust, &fs1);
|
||||
if(res==0)
|
||||
{
|
||||
tot_sect = (fs1->n_fatent - 2) * fs1->csize;//<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
fre_sect = fre_clust * fs1->csize; //<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#if _MAX_SS!=512
|
||||
tot_sect*=fs1->ssize/512;
|
||||
fre_sect*=fs1->ssize/512;
|
||||
#endif
|
||||
if(tot_sect<20480)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1>10M
|
||||
{
|
||||
/* Print free space in unit of KB (assuming 512 bytes/sector) */
|
||||
printf("\r\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%d KB\r\n"
|
||||
"<EFBFBD><EFBFBD><EFBFBD>ÿռ<EFBFBD>:%d KB\r\n",
|
||||
tot_sect>>1,fre_sect>>1);
|
||||
}else
|
||||
{
|
||||
/* Print free space in unit of KB (assuming 512 bytes/sector) */
|
||||
printf("\r\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%d MB\r\n"
|
||||
"<EFBFBD><EFBFBD><EFBFBD>ÿռ<EFBFBD>:%d MB\r\n",
|
||||
tot_sect>>11,fre_sect>>11);
|
||||
}
|
||||
}
|
||||
return fre_sect;
|
||||
}
|
||||
//<2F>ļ<EFBFBD><C4BC><EFBFBD>дָ<D0B4><D6B8>ƫ<EFBFBD><C6AB>
|
||||
//offset:<3A><EFBFBD>ַƫ<D6B7>Ƶ<EFBFBD><C6B5><EFBFBD>
|
||||
//<2F><><EFBFBD><EFBFBD>ֵ:ִ<>н<EFBFBD><D0BD><EFBFBD>.
|
||||
u8 mf_lseek(u32 offset)
|
||||
{
|
||||
return f_lseek(file,offset);
|
||||
}
|
||||
//<2F><>ȡ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>ǰ<EFBFBD><C7B0>дָ<D0B4><D6B8><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>.
|
||||
//<2F><><EFBFBD><EFBFBD>ֵ:λ<><CEBB>
|
||||
u32 mf_tell(void)
|
||||
{
|
||||
return f_tell(file);
|
||||
}
|
||||
//<2F><>ȡ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>С
|
||||
//<2F><><EFBFBD><EFBFBD>ֵ:<3A>ļ<EFBFBD><C4BC><EFBFBD>С
|
||||
u32 mf_size(void)
|
||||
{
|
||||
return f_size(file);
|
||||
}
|
||||
//<2F><><EFBFBD><EFBFBD>Ŀ¼
|
||||
u8 mf_mkdir(u8*name)
|
||||
{
|
||||
return f_mkdir((const TCHAR *)name);
|
||||
}
|
||||
//<2F><>ʽ<EFBFBD><CABD>
|
||||
u8 mf_fmkfs(u8 drv,u8 mode,u16 au)
|
||||
{
|
||||
return f_mkfs(drv,mode,au);//<2F><>ʽ<EFBFBD><CABD>,drv:<3A>̷<EFBFBD>;mode:ģʽ;au:<3A>ش<EFBFBD>С
|
||||
}
|
||||
//ɾ<><C9BE><EFBFBD>ļ<EFBFBD>/Ŀ¼
|
||||
u8 mf_unlink(u8 *name)
|
||||
{
|
||||
return f_unlink((const TCHAR *)name);
|
||||
}
|
||||
//<2F><EFBFBD><DEB8>ļ<EFBFBD>/Ŀ¼<C4BF><C2BC><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD>Ŀ¼<C4BF><C2BC>ͬ,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6>ļ<EFBFBD>Ŷ!)
|
||||
//oldname:֮ǰ<D6AE><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//newname:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
u8 mf_rename(u8 *oldname,u8* newname)
|
||||
{
|
||||
return f_rename((const TCHAR *)oldname,(const TCHAR *)newname);
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡһ<C8A1><D2BB><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
||||
void mf_gets(u16 size)
|
||||
{
|
||||
TCHAR* rbuf;
|
||||
rbuf=f_gets((TCHAR*)fatbuf,size,file);
|
||||
if(*rbuf==0)return ;//û<><C3BB><EFBFBD><EFBFBD><EFBFBD>ݶ<EFBFBD><DDB6><EFBFBD>
|
||||
else
|
||||
{
|
||||
printf("\r\nThe String Readed Is:%s\r\n",rbuf);
|
||||
}
|
||||
}
|
||||
//<2F><>Ҫ_USE_STRFUNC>=1
|
||||
//дһ<D0B4><D2BB><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>ļ<EFBFBD>
|
||||
u8 mf_putc(u8 c)
|
||||
{
|
||||
return f_putc((TCHAR)c,file);
|
||||
}
|
||||
//д<>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
||||
u8 mf_puts(u8*c)
|
||||
{
|
||||
return f_puts((TCHAR*)c,file);
|
||||
}
|
||||
//<2F>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>ʾ
|
||||
//mode:
|
||||
//[0]:<3A><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
||||
//[1]:<3A><><EFBFBD>°ٷֱ<D9B7>pct
|
||||
//[2]:<3A><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
||||
//[3~7]:<3A><><EFBFBD><EFBFBD>
|
||||
//<2F><><EFBFBD><EFBFBD>ֵ:0,<2C><><EFBFBD><EFBFBD>;
|
||||
// 1,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
u8 mf_cpymsg(u8*pname,u8 pct,u8 mode)
|
||||
{
|
||||
if(mode&0X01)printf("\r\nCopy File:%s\r\n",pname);
|
||||
if(mode&0X02)printf("File Copyed:%d\r\n",pct);
|
||||
if(mode&0X04)printf("Copy Folder:%s\r\n",pname);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
67
RTX5_20220316/Driver/FATFS/fattester.h
Normal file
@ -0,0 +1,67 @@
|
||||
#ifndef __FATTESTER_H
|
||||
#define __FATTESTER_H
|
||||
#include "ff.h"
|
||||
#include "sys.h"
|
||||
|
||||
|
||||
u8 mf_mount(u8 drv);
|
||||
u8 mf_open(u8*path,u8 mode);
|
||||
u8 mf_close(void);
|
||||
u8 mf_read(u16 len);
|
||||
u8 mf_write(u8*dat,u16 len);
|
||||
u8 mf_opendir(u8* path);
|
||||
u8 mf_readdir(void);
|
||||
|
||||
u8 mf_scan_files(u8 * path);
|
||||
u32 mf_showfree(u8 *drv);
|
||||
u8 mf_lseek(u32 offset);
|
||||
u32 mf_tell(void);
|
||||
u32 mf_size(void);
|
||||
u8 mf_mkdir(u8*name);
|
||||
u8 mf_fmkfs(u8 drv,u8 mode,u16 au);
|
||||
u8 mf_unlink(u8 *name);
|
||||
u8 mf_rename(u8 *oldname,u8* newname);
|
||||
void mf_gets(u16 size);
|
||||
u8 mf_putc(u8 c);
|
||||
u8 mf_puts(u8*c);
|
||||
|
||||
u8 mf_pfnmg_init(u8*path,u8 type);
|
||||
u8 mf_pfnmg_get_pname(void);
|
||||
u8 mf_pfnmg_get_plfname(void);
|
||||
u8 mf_pfnmg_get_lfname(void);
|
||||
u8 mf_pfnmg_get_ifname(u16 index);
|
||||
|
||||
u8 mf_cpymsg(u8*pname,u8 pct,u8 mode);
|
||||
u32 mf_fdsize(u8 *fdname);//<2F>õ<EFBFBD><C3B5>ļ<EFBFBD><C4BC>д<EFBFBD>С
|
||||
u8 mf_fcopy(u8 *psrc,u8 *pdst);
|
||||
u8 mf_fdcopy(u8 *psrc,u8 *pdst);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
359
RTX5_20220316/Driver/FATFS/source/00history.txt
Normal file
@ -0,0 +1,359 @@
|
||||
----------------------------------------------------------------------------
|
||||
Revision history of FatFs module
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
R0.00 (February 26, 2006)
|
||||
|
||||
Prototype.
|
||||
|
||||
|
||||
|
||||
R0.01 (April 29, 2006)
|
||||
|
||||
The first release.
|
||||
|
||||
|
||||
|
||||
R0.02 (June 01, 2006)
|
||||
|
||||
Added FAT12 support.
|
||||
Removed unbuffered mode.
|
||||
Fixed a problem on small (<32M) partition.
|
||||
|
||||
|
||||
|
||||
R0.02a (June 10, 2006)
|
||||
|
||||
Added a configuration option (_FS_MINIMUM).
|
||||
|
||||
|
||||
|
||||
R0.03 (September 22, 2006)
|
||||
|
||||
Added f_rename().
|
||||
Changed option _FS_MINIMUM to _FS_MINIMIZE.
|
||||
|
||||
|
||||
|
||||
R0.03a (December 11, 2006)
|
||||
|
||||
Improved cluster scan algorithm to write files fast.
|
||||
Fixed f_mkdir() creates incorrect directory on FAT32.
|
||||
|
||||
|
||||
|
||||
R0.04 (February 04, 2007)
|
||||
|
||||
Added f_mkfs().
|
||||
Supported multiple drive system.
|
||||
Changed some interfaces for multiple drive system.
|
||||
Changed f_mountdrv() to f_mount().
|
||||
|
||||
|
||||
|
||||
R0.04a (April 01, 2007)
|
||||
|
||||
Supported multiple partitions on a physical drive.
|
||||
Added a capability of extending file size to f_lseek().
|
||||
Added minimization level 3.
|
||||
Fixed an endian sensitive code in f_mkfs().
|
||||
|
||||
|
||||
|
||||
R0.04b (May 05, 2007)
|
||||
|
||||
Added a configuration option _USE_NTFLAG.
|
||||
Added FSINFO support.
|
||||
Fixed DBCS name can result FR_INVALID_NAME.
|
||||
Fixed short seek (<= csize) collapses the file object.
|
||||
|
||||
|
||||
|
||||
R0.05 (August 25, 2007)
|
||||
|
||||
Changed arguments of f_read(), f_write() and f_mkfs().
|
||||
Fixed f_mkfs() on FAT32 creates incorrect FSINFO.
|
||||
Fixed f_mkdir() on FAT32 creates incorrect directory.
|
||||
|
||||
|
||||
|
||||
R0.05a (February 03, 2008)
|
||||
|
||||
Added f_truncate() and f_utime().
|
||||
Fixed off by one error at FAT sub-type determination.
|
||||
Fixed btr in f_read() can be mistruncated.
|
||||
Fixed cached sector is not flushed when create and close without write.
|
||||
|
||||
|
||||
|
||||
R0.06 (April 01, 2008)
|
||||
|
||||
Added fputc(), fputs(), fprintf() and fgets().
|
||||
Improved performance of f_lseek() on moving to the same or following cluster.
|
||||
|
||||
|
||||
|
||||
R0.07 (April 01, 2009)
|
||||
|
||||
Merged Tiny-FatFs as a configuration option. (_FS_TINY)
|
||||
Added long file name feature. (_USE_LFN)
|
||||
Added multiple code page feature. (_CODE_PAGE)
|
||||
Added re-entrancy for multitask operation. (_FS_REENTRANT)
|
||||
Added auto cluster size selection to f_mkfs().
|
||||
Added rewind option to f_readdir().
|
||||
Changed result code of critical errors.
|
||||
Renamed string functions to avoid name collision.
|
||||
|
||||
|
||||
|
||||
R0.07a (April 14, 2009)
|
||||
|
||||
Septemberarated out OS dependent code on reentrant cfg.
|
||||
Added multiple sector size feature.
|
||||
|
||||
|
||||
|
||||
R0.07c (June 21, 2009)
|
||||
|
||||
Fixed f_unlink() can return FR_OK on error.
|
||||
Fixed wrong cache control in f_lseek().
|
||||
Added relative path feature.
|
||||
Added f_chdir() and f_chdrive().
|
||||
Added proper case conversion to extended character.
|
||||
|
||||
|
||||
|
||||
R0.07e (November 03, 2009)
|
||||
|
||||
Septemberarated out configuration options from ff.h to ffconf.h.
|
||||
Fixed f_unlink() fails to remove a sub-directory on _FS_RPATH.
|
||||
Fixed name matching error on the 13 character boundary.
|
||||
Added a configuration option, _LFN_UNICODE.
|
||||
Changed f_readdir() to return the SFN with always upper case on non-LFN cfg.
|
||||
|
||||
|
||||
|
||||
R0.08 (May 15, 2010)
|
||||
|
||||
Added a memory configuration option. (_USE_LFN = 3)
|
||||
Added file lock feature. (_FS_SHARE)
|
||||
Added fast seek feature. (_USE_FASTSEEK)
|
||||
Changed some types on the API, XCHAR->TCHAR.
|
||||
Changed .fname in the FILINFO structure on Unicode cfg.
|
||||
String functions support UTF-8 encoding files on Unicode cfg.
|
||||
|
||||
|
||||
|
||||
R0.08a (August 16, 2010)
|
||||
|
||||
Added f_getcwd(). (_FS_RPATH = 2)
|
||||
Added sector erase feature. (_USE_ERASE)
|
||||
Moved file lock semaphore table from fs object to the bss.
|
||||
Fixed f_mkfs() creates wrong FAT32 volume.
|
||||
|
||||
|
||||
|
||||
R0.08b (January 15, 2011)
|
||||
|
||||
Fast seek feature is also applied to f_read() and f_write().
|
||||
f_lseek() reports required table size on creating CLMP.
|
||||
Extended format syntax of f_printf().
|
||||
Ignores duplicated directory separators in given path name.
|
||||
|
||||
|
||||
|
||||
R0.09 (September 06, 2011)
|
||||
|
||||
f_mkfs() supports multiple partition to complete the multiple partition feature.
|
||||
Added f_fdisk().
|
||||
|
||||
|
||||
|
||||
R0.09a (August 27, 2012)
|
||||
|
||||
Changed f_open() and f_opendir() reject null object pointer to avoid crash.
|
||||
Changed option name _FS_SHARE to _FS_LOCK.
|
||||
Fixed assertion failure due to OS/2 EA on FAT12/16 volume.
|
||||
|
||||
|
||||
|
||||
R0.09b (January 24, 2013)
|
||||
|
||||
Added f_setlabel() and f_getlabel().
|
||||
|
||||
|
||||
|
||||
R0.10 (October 02, 2013)
|
||||
|
||||
Added selection of character encoding on the file. (_STRF_ENCODE)
|
||||
Added f_closedir().
|
||||
Added forced full FAT scan for f_getfree(). (_FS_NOFSINFO)
|
||||
Added forced mount feature with changes of f_mount().
|
||||
Improved behavior of volume auto detection.
|
||||
Improved write throughput of f_puts() and f_printf().
|
||||
Changed argument of f_chdrive(), f_mkfs(), disk_read() and disk_write().
|
||||
Fixed f_write() can be truncated when the file size is close to 4GB.
|
||||
Fixed f_open(), f_mkdir() and f_setlabel() can return incorrect value on error.
|
||||
|
||||
|
||||
|
||||
R0.10a (January 15, 2014)
|
||||
|
||||
Added arbitrary strings as drive number in the path name. (_STR_VOLUME_ID)
|
||||
Added a configuration option of minimum sector size. (_MIN_SS)
|
||||
2nd argument of f_rename() can have a drive number and it will be ignored.
|
||||
Fixed f_mount() with forced mount fails when drive number is >= 1. (appeared at R0.10)
|
||||
Fixed f_close() invalidates the file object without volume lock.
|
||||
Fixed f_closedir() returns but the volume lock is left acquired. (appeared at R0.10)
|
||||
Fixed creation of an entry with LFN fails on too many SFN collisions. (appeared at R0.07)
|
||||
|
||||
|
||||
|
||||
R0.10b (May 19, 2014)
|
||||
|
||||
Fixed a hard error in the disk I/O layer can collapse the directory entry.
|
||||
Fixed LFN entry is not deleted when delete/rename an object with lossy converted SFN. (appeared at R0.07)
|
||||
|
||||
|
||||
|
||||
R0.10c (November 09, 2014)
|
||||
|
||||
Added a configuration option for the platforms without RTC. (_FS_NORTC)
|
||||
Changed option name _USE_ERASE to _USE_TRIM.
|
||||
Fixed volume label created by Mac OS X cannot be retrieved with f_getlabel(). (appeared at R0.09b)
|
||||
Fixed a potential problem of FAT access that can appear on disk error.
|
||||
Fixed null pointer dereference on attempting to delete the root direcotry. (appeared at R0.08)
|
||||
|
||||
|
||||
|
||||
R0.11 (February 09, 2015)
|
||||
|
||||
Added f_findfirst(), f_findnext() and f_findclose(). (_USE_FIND)
|
||||
Fixed f_unlink() does not remove cluster chain of the file. (appeared at R0.10c)
|
||||
Fixed _FS_NORTC option does not work properly. (appeared at R0.10c)
|
||||
|
||||
|
||||
|
||||
R0.11a (September 05, 2015)
|
||||
|
||||
Fixed wrong media change can lead a deadlock at thread-safe configuration.
|
||||
Added code page 771, 860, 861, 863, 864, 865 and 869. (_CODE_PAGE)
|
||||
Removed some code pages actually not exist on the standard systems. (_CODE_PAGE)
|
||||
Fixed errors in the case conversion teble of code page 437 and 850 (ff.c).
|
||||
Fixed errors in the case conversion teble of Unicode (cc*.c).
|
||||
|
||||
|
||||
|
||||
R0.12 (April 12, 2016)
|
||||
|
||||
Added support for exFAT file system. (_FS_EXFAT)
|
||||
Added f_expand(). (_USE_EXPAND)
|
||||
Changed some members in FINFO structure and behavior of f_readdir().
|
||||
Added an option _USE_CHMOD.
|
||||
Removed an option _WORD_ACCESS.
|
||||
Fixed errors in the case conversion table of Unicode (cc*.c).
|
||||
|
||||
|
||||
|
||||
R0.12a (July 10, 2016)
|
||||
|
||||
Added support for creating exFAT volume with some changes of f_mkfs().
|
||||
Added a file open method FA_OPEN_APPEND. An f_lseek() following f_open() is no longer needed.
|
||||
f_forward() is available regardless of _FS_TINY.
|
||||
Fixed f_mkfs() creates wrong volume. (appeared at R0.12)
|
||||
Fixed wrong memory read in create_name(). (appeared at R0.12)
|
||||
Fixed compilation fails at some configurations, _USE_FASTSEEK and _USE_FORWARD.
|
||||
|
||||
|
||||
|
||||
R0.12b (September 04, 2016)
|
||||
|
||||
Made f_rename() be able to rename objects with the same name but case.
|
||||
Fixed an error in the case conversion teble of code page 866. (ff.c)
|
||||
Fixed writing data is truncated at the file offset 4GiB on the exFAT volume. (appeared at R0.12)
|
||||
Fixed creating a file in the root directory of exFAT volume can fail. (appeared at R0.12)
|
||||
Fixed f_mkfs() creating exFAT volume with too small cluster size can collapse unallocated memory. (appeared at R0.12)
|
||||
Fixed wrong object name can be returned when read directory at Unicode cfg. (appeared at R0.12)
|
||||
Fixed large file allocation/removing on the exFAT volume collapses allocation bitmap. (appeared at R0.12)
|
||||
Fixed some internal errors in f_expand() and f_lseek(). (appeared at R0.12)
|
||||
|
||||
|
||||
|
||||
R0.12c (March 04, 2017)
|
||||
|
||||
Improved write throughput at the fragmented file on the exFAT volume.
|
||||
Made memory usage for exFAT be able to be reduced as decreasing _MAX_LFN.
|
||||
Fixed successive f_getfree() can return wrong count on the FAT12/16 volume. (appeared at R0.12)
|
||||
Fixed configuration option _VOLUMES cannot be set 10. (appeared at R0.10c)
|
||||
|
||||
|
||||
|
||||
R0.13 (May 21, 2017)
|
||||
|
||||
Changed heading character of configuration keywords "_" to "FF_".
|
||||
Removed ASCII-only configuration, FF_CODE_PAGE = 1. Use FF_CODE_PAGE = 437 instead.
|
||||
Added f_setcp(), run-time code page configuration. (FF_CODE_PAGE = 0)
|
||||
Improved cluster allocation time on stretch a deep buried cluster chain.
|
||||
Improved processing time of f_mkdir() with large cluster size by using FF_USE_LFN = 3.
|
||||
Improved NoFatChain flag of the fragmented file to be set after it is truncated and got contiguous.
|
||||
Fixed archive attribute is left not set when a file on the exFAT volume is renamed. (appeared at R0.12)
|
||||
Fixed exFAT FAT entry can be collapsed when write or lseek operation to the existing file is done. (appeared at R0.12c)
|
||||
Fixed creating a file can fail when a new cluster allocation to the exFAT directory occures. (appeared at R0.12c)
|
||||
|
||||
|
||||
|
||||
R0.13a (October 14, 2017)
|
||||
|
||||
Added support for UTF-8 encoding on the API. (FF_LFN_UNICODE = 2)
|
||||
Added options for file name output buffer. (FF_LFN_BUF, FF_SFN_BUF).
|
||||
Added dynamic memory allocation option for working buffer of f_mkfs() and f_fdisk().
|
||||
Fixed f_fdisk() and f_mkfs() create the partition table with wrong CHS parameters. (appeared at R0.09)
|
||||
Fixed f_unlink() can cause lost clusters at fragmented file on the exFAT volume. (appeared at R0.12c)
|
||||
Fixed f_setlabel() rejects some valid characters for exFAT volume. (appeared at R0.12)
|
||||
|
||||
|
||||
|
||||
R0.13b (April 07, 2018)
|
||||
|
||||
Added support for UTF-32 encoding on the API. (FF_LFN_UNICODE = 3)
|
||||
Added support for Unix style volume ID. (FF_STR_VOLUME_ID = 2)
|
||||
Fixed accesing any object on the exFAT root directory beyond the cluster boundary can fail. (appeared at R0.12c)
|
||||
Fixed f_setlabel() does not reject some invalid characters. (appeared at R0.09b)
|
||||
|
||||
|
||||
|
||||
R0.13c (October 14, 2018)
|
||||
Supported stdint.h for C99 and later. (integer.h was included in ff.h)
|
||||
Fixed reading a directory gets infinite loop when the last directory entry is not empty. (appeared at R0.12)
|
||||
Fixed creating a sub-directory in the fragmented sub-directory on the exFAT volume collapses FAT chain of the parent directory. (appeared at R0.12)
|
||||
Fixed f_getcwd() cause output buffer overrun when the buffer has a valid drive number. (appeared at R0.13b)
|
||||
|
||||
|
||||
|
||||
R0.14 (October 14, 2019)
|
||||
Added support for 64-bit LBA and GUID partition table (FF_LBA64 = 1)
|
||||
Changed some API functions, f_mkfs() and f_fdisk().
|
||||
Fixed f_open() function cannot find the file with file name in length of FF_MAX_LFN characters.
|
||||
Fixed f_readdir() function cannot retrieve long file names in length of FF_MAX_LFN - 1 characters.
|
||||
Fixed f_readdir() function returns file names with wrong case conversion. (appeared at R0.12)
|
||||
Fixed f_mkfs() function can fail to create exFAT volume in the second partition. (appeared at R0.12)
|
||||
|
||||
|
||||
R0.14a (December 5, 2020)
|
||||
Limited number of recursive calls in f_findnext().
|
||||
Fixed old floppy disks formatted with MS-DOS 2.x and 3.x cannot be mounted.
|
||||
Fixed some compiler warnings.
|
||||
|
||||
|
||||
|
||||
R0.14b (April 17, 2021)
|
||||
Made FatFs uses standard library <string.h> for copy, compare and search instead of built-in string functions.
|
||||
Added support for long long integer and floating point to f_printf(). (FF_STRF_LLI and FF_STRF_FP)
|
||||
Made path name parser ignore the terminating separator to allow "dir/".
|
||||
Improved the compatibility in Unix style path name feature.
|
||||
Fixed the file gets dead-locked when f_open() failed with some conditions. (appeared at R0.12a)
|
||||
Fixed f_mkfs() can create wrong exFAT volume due to a timing dependent error. (appeared at R0.12)
|
||||
Fixed code page 855 cannot be set by f_setcp().
|
||||
Fixed some compiler warnings.
|
||||
|
||||
|
||||
21
RTX5_20220316/Driver/FATFS/source/00readme.txt
Normal file
@ -0,0 +1,21 @@
|
||||
FatFs Module Source Files R0.14b
|
||||
|
||||
|
||||
FILES
|
||||
|
||||
00readme.txt This file.
|
||||
00history.txt Revision history.
|
||||
ff.c FatFs module.
|
||||
ffconf.h Configuration file of FatFs module.
|
||||
ff.h Common include file for FatFs and application module.
|
||||
diskio.h Common include file for FatFs and disk I/O module.
|
||||
diskio.c An example of glue function to attach existing disk I/O module to FatFs.
|
||||
ffunicode.c Optional Unicode utility functions.
|
||||
ffsystem.c An example of optional O/S related functions.
|
||||
|
||||
|
||||
Low level disk I/O module is not included in this archive because the FatFs
|
||||
module is only a generic file system layer and it does not depend on any specific
|
||||
storage device. You need to provide a low level disk I/O module written to
|
||||
control the storage device that attached to the target system.
|
||||
|
||||
274
RTX5_20220316/Driver/FATFS/source/diskio.c
Normal file
@ -0,0 +1,274 @@
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Low level disk I/O module SKELETON for FatFs (C)ChaN, 2019 */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* If a working storage control module is available, it should be */
|
||||
/* attached to the FatFs via a glue function rather than modifying it. */
|
||||
/* This is an example of glue functions to attach various exsisting */
|
||||
/* storage control modules to the FatFs module with a defined API. */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
#include "ff.h" /* Obtains integer types */
|
||||
#include "diskio.h" /* Declarations of disk functions */
|
||||
|
||||
#include "SPI_SD_driver.h"
|
||||
#include "diskio.h"
|
||||
//#include "flash.h"
|
||||
#include "spi.h"
|
||||
|
||||
/* Definitions of physical drive number for each drive */
|
||||
#define DEV_RAM 0 /* Example: Map Ramdisk to physical drive 0 */
|
||||
#define DEV_MMC 1 /* Example: Map MMC/SD card to physical drive 1 */
|
||||
#define DEV_USB 2 /* Example: Map USB MSD to physical drive 2 */
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Get Drive Status */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
#define SD_CARD 0 //SD<53><44>,<2C><><EFBFBD><EFBFBD>Ϊ0
|
||||
#define EX_FLASH 1 //<2F>ⲿflash,<2C><><EFBFBD><EFBFBD>Ϊ1
|
||||
|
||||
DSTATUS disk_status (
|
||||
BYTE pdrv /* Physical drive nmuber to identify the drive */
|
||||
)
|
||||
{
|
||||
//DSTATUS stat;
|
||||
//int result;
|
||||
uint8_t res=0;
|
||||
switch (pdrv) {
|
||||
case SD_CARD :
|
||||
res = SD_Initialize();
|
||||
if(res)//STM32 SPI<50><49>bug,<2C><>sd<73><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܵ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD>ܵ<EFBFBD><DCB5><EFBFBD>SPI<50><49>д<EFBFBD>쳣
|
||||
{
|
||||
SD_SPI_SpeedLow();
|
||||
SD_SPI_ReadWriteByte(0xff);//<2F>ṩ<EFBFBD><E1B9A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>8<EFBFBD><38>ʱ<EFBFBD><CAB1>
|
||||
SD_SPI_SpeedHigh();
|
||||
}
|
||||
break;
|
||||
// translate the reslut code here
|
||||
|
||||
//return stat;
|
||||
|
||||
// case DEV_MMC :
|
||||
// result = MMC_disk_status();
|
||||
|
||||
// // translate the reslut code here
|
||||
|
||||
// return stat;
|
||||
|
||||
// case DEV_USB :
|
||||
// result = USB_disk_status();
|
||||
|
||||
// // translate the reslut code here
|
||||
|
||||
// return stat;
|
||||
}
|
||||
if(res)return STA_NOINIT;
|
||||
else return 0; //<2F><>ʼ<EFBFBD><CABC><EFBFBD>ɹ<EFBFBD>
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Inidialize a Drive */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
DSTATUS disk_initialize (
|
||||
BYTE pdrv /* Physical drive nmuber to identify the drive */
|
||||
)
|
||||
{
|
||||
uint8_t res=0;
|
||||
switch(pdrv)
|
||||
{
|
||||
case SD_CARD://SD<53><44>
|
||||
res = SD_Initialize();//SD_Initialize()
|
||||
if(res)//STM32 SPI<50><49>bug,<2C><>sd<73><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܵ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD>ܵ<EFBFBD><DCB5><EFBFBD>SPI<50><49>д<EFBFBD>쳣
|
||||
{
|
||||
SD_SPI_SpeedLow();
|
||||
SD_SPI_ReadWriteByte(0xff);//<2F>ṩ<EFBFBD><E1B9A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>8<EFBFBD><38>ʱ<EFBFBD><CAB1>
|
||||
SD_SPI_SpeedHigh();
|
||||
}
|
||||
break;
|
||||
case EX_FLASH://<2F>ⲿflash
|
||||
//SPI_Flash_Init();
|
||||
// if(SPI_FLASH_TYPE==W25Q64)FLASH_SECTOR_COUNT=2048*6;//W25Q64
|
||||
// else FLASH_SECTOR_COUNT=2048*2; //<2F><><EFBFBD><EFBFBD>
|
||||
break;
|
||||
default:
|
||||
res=1;
|
||||
}
|
||||
if(res)return STA_NOINIT;
|
||||
else return 0; //<2F><>ʼ<EFBFBD><CABC><EFBFBD>ɹ<EFBFBD>
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Read Sector(s) */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
DRESULT disk_read (
|
||||
BYTE pdrv, /* Physical drive nmuber to identify the drive */
|
||||
BYTE *buff, /* Data buffer to store read data */
|
||||
LBA_t sector, /* Start sector in LBA */
|
||||
UINT count /* Number of sectors to read */
|
||||
)
|
||||
{
|
||||
uint8_t res=0;
|
||||
if (!count)return RES_PARERR;//count<6E><74><EFBFBD>ܵ<EFBFBD><DCB5><EFBFBD>0<EFBFBD><30><EFBFBD><EFBFBD><EFBFBD>ز<F2B7B5BB><D8B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
switch(pdrv)
|
||||
{
|
||||
case SD_CARD://SD<53><44>
|
||||
res=SD_ReadDisk(buff,sector,count);
|
||||
if(res)//STM32 SPI<50><49>bug,<2C><>sd<73><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܵ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD>ܵ<EFBFBD><DCB5><EFBFBD>SPI<50><49>д<EFBFBD>쳣
|
||||
{
|
||||
SD_SPI_SpeedLow();
|
||||
SD_SPI_ReadWriteByte(0xff);//<2F>ṩ<EFBFBD><E1B9A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>8<EFBFBD><38>ʱ<EFBFBD><CAB1>
|
||||
SD_SPI_SpeedHigh();
|
||||
}
|
||||
break;
|
||||
case EX_FLASH://<2F>ⲿflash
|
||||
// for(;count>0;count--)
|
||||
// {
|
||||
// //SPI_Flash_Read(buff,sector*FLASH_SECTOR_SIZE,FLASH_SECTOR_SIZE);
|
||||
// sector++;
|
||||
// buff+=FLASH_SECTOR_SIZE;
|
||||
// }
|
||||
res=0;
|
||||
break;
|
||||
default:
|
||||
res=1;
|
||||
}
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>SPI_SD_driver.c<>ķ<EFBFBD><C4B7><EFBFBD>ֵת<D6B5><D7AA>ff.c<>ķ<EFBFBD><C4B7><EFBFBD>ֵ
|
||||
if(res==0x00)return RES_OK;
|
||||
else return RES_ERROR;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Write Sector(s) */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
#if FF_FS_READONLY == 0
|
||||
|
||||
DRESULT disk_write (
|
||||
BYTE pdrv, /* Physical drive nmuber to identify the drive */
|
||||
const BYTE *buff, /* Data to be written */
|
||||
LBA_t sector, /* Start sector in LBA */
|
||||
UINT count /* Number of sectors to write */
|
||||
)
|
||||
{
|
||||
uint8_t res=0;
|
||||
if (!count)return RES_PARERR;//count<6E><74><EFBFBD>ܵ<EFBFBD><DCB5><EFBFBD>0<EFBFBD><30><EFBFBD><EFBFBD><EFBFBD>ز<F2B7B5BB><D8B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
switch(pdrv)
|
||||
{
|
||||
case SD_CARD://SD<53><44>
|
||||
res=SD_WriteDisk((u8*)buff,sector,count);
|
||||
break;
|
||||
case EX_FLASH://<2F>ⲿflash
|
||||
// for(;count>0;count--)
|
||||
// {
|
||||
// //SPI_Flash_Write((u8*)buff,sector*FLASH_SECTOR_SIZE,FLASH_SECTOR_SIZE);
|
||||
// sector++;
|
||||
// buff+=FLASH_SECTOR_SIZE;
|
||||
// }
|
||||
// res=0;
|
||||
break;
|
||||
default:
|
||||
res=1;
|
||||
}
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>SPI_SD_driver.c<>ķ<EFBFBD><C4B7><EFBFBD>ֵת<D6B5><D7AA>ff.c<>ķ<EFBFBD><C4B7><EFBFBD>ֵ
|
||||
if(res == 0x00)return RES_OK;
|
||||
else return RES_ERROR;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Miscellaneous Functions */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
DRESULT disk_ioctl (
|
||||
BYTE pdrv, /* Physical drive nmuber (0..) */
|
||||
BYTE cmd, /* Control code */
|
||||
void *buff /* Buffer to send/receive control data */
|
||||
)
|
||||
{
|
||||
DRESULT res;
|
||||
if(pdrv==SD_CARD)//SD<53><44>
|
||||
{
|
||||
switch(cmd)
|
||||
{
|
||||
case CTRL_SYNC:
|
||||
SD_CS_ENABLE();
|
||||
if(SD_WaitReady()==0)res = RES_OK;
|
||||
else res = RES_ERROR;
|
||||
SD_CS_DISABLE();
|
||||
break;
|
||||
case GET_SECTOR_SIZE:
|
||||
*(WORD*)buff = 512;
|
||||
res = RES_OK;
|
||||
break;
|
||||
case GET_BLOCK_SIZE:
|
||||
*(WORD*)buff = 8;
|
||||
res = RES_OK;
|
||||
break;
|
||||
case GET_SECTOR_COUNT:
|
||||
*(DWORD*)buff = SD_GetSectorCount();
|
||||
res = RES_OK;
|
||||
break;
|
||||
default:
|
||||
res = RES_PARERR;
|
||||
break;
|
||||
}
|
||||
}else if(pdrv==EX_FLASH) //<2F>ⲿFLASH
|
||||
{
|
||||
switch(cmd)
|
||||
{
|
||||
case CTRL_SYNC:
|
||||
res = RES_OK;
|
||||
break;
|
||||
case GET_SECTOR_SIZE:
|
||||
// *(WORD*)buff = FLASH_SECTOR_SIZE;
|
||||
res = RES_OK;
|
||||
break;
|
||||
case GET_BLOCK_SIZE:
|
||||
// *(WORD*)buff = FLASH_BLOCK_SIZE;
|
||||
res = RES_OK;
|
||||
break;
|
||||
case GET_SECTOR_COUNT:
|
||||
// *(DWORD*)buff = FLASH_SECTOR_COUNT;
|
||||
res = RES_OK;
|
||||
break;
|
||||
default:
|
||||
res = RES_PARERR;
|
||||
break;
|
||||
}
|
||||
}else res=RES_ERROR;//<2F><><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD>֧<EFBFBD><D6A7>
|
||||
return res;
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
//User defined function to give a current time to fatfs module */
|
||||
//31-25: Year(0-127 org.1980), 24-21: Month(1-12), 20-16: Day(1-31) */
|
||||
//15-11: Hour(0-23), 10-5: Minute(0-59), 4-0: Second(0-29 *2) */
|
||||
//<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
//User defined function to give a current time to fatfs module */
|
||||
//31-25: Year(0-127 org.1980), 24-21: Month(1-12), 20-16: Day(1-31) */
|
||||
//15-11: Hour(0-23), 10-5: Minute(0-59), 4-0: Second(0-29 *2) */
|
||||
DWORD get_fattime (void)
|
||||
{
|
||||
RTC_TimeTypeDef time;
|
||||
RTC_DateTypeDef date;
|
||||
RTC_GetTime(RTC_Format_BIN,&time);
|
||||
RTC_GetDate(RTC_Format_BIN,&date);
|
||||
return ((date.RTC_Year+2000-1980)<<25|
|
||||
date.RTC_Month<<21|
|
||||
date.RTC_Date<<16|
|
||||
time.RTC_Hours<<11|
|
||||
time.RTC_Minutes<<5|
|
||||
time.RTC_Seconds>>1
|
||||
);
|
||||
}
|
||||
77
RTX5_20220316/Driver/FATFS/source/diskio.h
Normal file
@ -0,0 +1,77 @@
|
||||
/*-----------------------------------------------------------------------/
|
||||
/ Low level disk interface modlue include file (C)ChaN, 2019 /
|
||||
/-----------------------------------------------------------------------*/
|
||||
|
||||
#ifndef _DISKIO_DEFINED
|
||||
#define _DISKIO_DEFINED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Status of Disk Functions */
|
||||
typedef BYTE DSTATUS;
|
||||
|
||||
/* Results of Disk Functions */
|
||||
typedef enum {
|
||||
RES_OK = 0, /* 0: Successful */
|
||||
RES_ERROR, /* 1: R/W Error */
|
||||
RES_WRPRT, /* 2: Write Protected */
|
||||
RES_NOTRDY, /* 3: Not Ready */
|
||||
RES_PARERR /* 4: Invalid Parameter */
|
||||
} DRESULT;
|
||||
|
||||
|
||||
/*---------------------------------------*/
|
||||
/* Prototypes for disk control functions */
|
||||
|
||||
|
||||
DSTATUS disk_initialize (BYTE pdrv);
|
||||
DSTATUS disk_status (BYTE pdrv);
|
||||
DRESULT disk_read (BYTE pdrv, BYTE* buff, LBA_t sector, UINT count);
|
||||
DRESULT disk_write (BYTE pdrv, const BYTE* buff, LBA_t sector, UINT count);
|
||||
DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff);
|
||||
|
||||
|
||||
/* Disk Status Bits (DSTATUS) */
|
||||
|
||||
#define STA_NOINIT 0x01 /* Drive not initialized */
|
||||
#define STA_NODISK 0x02 /* No medium in the drive */
|
||||
#define STA_PROTECT 0x04 /* Write protected */
|
||||
|
||||
|
||||
/* Command code for disk_ioctrl fucntion */
|
||||
|
||||
/* Generic command (Used by FatFs) */
|
||||
#define CTRL_SYNC 0 /* Complete pending write process (needed at FF_FS_READONLY == 0) */
|
||||
#define GET_SECTOR_COUNT 1 /* Get media size (needed at FF_USE_MKFS == 1) */
|
||||
#define GET_SECTOR_SIZE 2 /* Get sector size (needed at FF_MAX_SS != FF_MIN_SS) */
|
||||
#define GET_BLOCK_SIZE 3 /* Get erase block size (needed at FF_USE_MKFS == 1) */
|
||||
#define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at FF_USE_TRIM == 1) */
|
||||
|
||||
/* Generic command (Not used by FatFs) */
|
||||
#define CTRL_POWER 5 /* Get/Set power status */
|
||||
#define CTRL_LOCK 6 /* Lock/Unlock media removal */
|
||||
#define CTRL_EJECT 7 /* Eject media */
|
||||
#define CTRL_FORMAT 8 /* Create physical format on the media */
|
||||
|
||||
/* MMC/SDC specific ioctl command */
|
||||
#define MMC_GET_TYPE 10 /* Get card type */
|
||||
#define MMC_GET_CSD 11 /* Get CSD */
|
||||
#define MMC_GET_CID 12 /* Get CID */
|
||||
#define MMC_GET_OCR 13 /* Get OCR */
|
||||
#define MMC_GET_SDSTAT 14 /* Get SD status */
|
||||
#define ISDIO_READ 55 /* Read data form SD iSDIO register */
|
||||
#define ISDIO_WRITE 56 /* Write data to SD iSDIO register */
|
||||
#define ISDIO_MRITE 57 /* Masked write data to SD iSDIO register */
|
||||
|
||||
/* ATA/CF specific ioctl command */
|
||||
#define ATA_GET_REV 20 /* Get F/W revision */
|
||||
#define ATA_GET_MODEL 21 /* Get model name */
|
||||
#define ATA_GET_SN 22 /* Get serial number */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
6982
RTX5_20220316/Driver/FATFS/source/ff.c
Normal file
422
RTX5_20220316/Driver/FATFS/source/ff.h
Normal file
@ -0,0 +1,422 @@
|
||||
/*----------------------------------------------------------------------------/
|
||||
/ FatFs - Generic FAT Filesystem module R0.14b /
|
||||
/-----------------------------------------------------------------------------/
|
||||
/
|
||||
/ Copyright (C) 2021, ChaN, all right reserved.
|
||||
/
|
||||
/ FatFs module is an open source software. Redistribution and use of FatFs in
|
||||
/ source and binary forms, with or without modification, are permitted provided
|
||||
/ that the following condition is met:
|
||||
|
||||
/ 1. Redistributions of source code must retain the above copyright notice,
|
||||
/ this condition and the following disclaimer.
|
||||
/
|
||||
/ This software is provided by the copyright holder and contributors "AS IS"
|
||||
/ and any warranties related to this software are DISCLAIMED.
|
||||
/ The copyright owner or contributors be NOT LIABLE for any damages caused
|
||||
/ by use of this software.
|
||||
/
|
||||
/----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifndef FF_DEFINED
|
||||
#define FF_DEFINED 86631 /* Revision ID */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "ffconf.h" /* FatFs configuration options */
|
||||
|
||||
#if FF_DEFINED != FFCONF_DEF
|
||||
#error Wrong configuration file (ffconf.h).
|
||||
#endif
|
||||
|
||||
|
||||
/* Integer types used for FatFs API */
|
||||
|
||||
#if defined(_WIN32) /* Windows VC++ (for development only) */
|
||||
#define FF_INTDEF 2
|
||||
#include <windows.h>
|
||||
typedef unsigned __int64 QWORD;
|
||||
#include <float.h>
|
||||
#define isnan(v) _isnan(v)
|
||||
#define isinf(v) (!_finite(v))
|
||||
|
||||
#elif (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__cplusplus) /* C99 or later */
|
||||
#define FF_INTDEF 2
|
||||
#include <stdint.h>
|
||||
typedef unsigned int UINT; /* int must be 16-bit or 32-bit */
|
||||
typedef unsigned char BYTE; /* char must be 8-bit */
|
||||
typedef uint16_t WORD; /* 16-bit unsigned integer */
|
||||
typedef uint32_t DWORD; /* 32-bit unsigned integer */
|
||||
typedef uint64_t QWORD; /* 64-bit unsigned integer */
|
||||
typedef WORD WCHAR; /* UTF-16 character type */
|
||||
|
||||
#else /* Earlier than C99 */
|
||||
#define FF_INTDEF 1
|
||||
typedef unsigned int UINT; /* int must be 16-bit or 32-bit */
|
||||
typedef unsigned char BYTE; /* char must be 8-bit */
|
||||
typedef unsigned short WORD; /* 16-bit unsigned integer */
|
||||
typedef unsigned long DWORD; /* 32-bit unsigned integer */
|
||||
typedef WORD WCHAR; /* UTF-16 character type */
|
||||
#endif
|
||||
|
||||
|
||||
/* Type of file size and LBA variables */
|
||||
|
||||
#if FF_FS_EXFAT
|
||||
#if FF_INTDEF != 2
|
||||
#error exFAT feature wants C99 or later
|
||||
#endif
|
||||
typedef QWORD FSIZE_t;
|
||||
#if FF_LBA64
|
||||
typedef QWORD LBA_t;
|
||||
#else
|
||||
typedef DWORD LBA_t;
|
||||
#endif
|
||||
#else
|
||||
#if FF_LBA64
|
||||
#error exFAT needs to be enabled when enable 64-bit LBA
|
||||
#endif
|
||||
typedef DWORD FSIZE_t;
|
||||
typedef DWORD LBA_t;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* Type of path name strings on FatFs API (TCHAR) */
|
||||
|
||||
#if FF_USE_LFN && FF_LFN_UNICODE == 1 /* Unicode in UTF-16 encoding */
|
||||
typedef WCHAR TCHAR;
|
||||
#define _T(x) L ## x
|
||||
#define _TEXT(x) L ## x
|
||||
#elif FF_USE_LFN && FF_LFN_UNICODE == 2 /* Unicode in UTF-8 encoding */
|
||||
typedef char TCHAR;
|
||||
#define _T(x) u8 ## x
|
||||
#define _TEXT(x) u8 ## x
|
||||
#elif FF_USE_LFN && FF_LFN_UNICODE == 3 /* Unicode in UTF-32 encoding */
|
||||
typedef DWORD TCHAR;
|
||||
#define _T(x) U ## x
|
||||
#define _TEXT(x) U ## x
|
||||
#elif FF_USE_LFN && (FF_LFN_UNICODE < 0 || FF_LFN_UNICODE > 3)
|
||||
#error Wrong FF_LFN_UNICODE setting
|
||||
#else /* ANSI/OEM code in SBCS/DBCS */
|
||||
typedef char TCHAR;
|
||||
#define _T(x) x
|
||||
#define _TEXT(x) x
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* Definitions of volume management */
|
||||
|
||||
#if FF_MULTI_PARTITION /* Multiple partition configuration */
|
||||
typedef struct {
|
||||
BYTE pd; /* Physical drive number */
|
||||
BYTE pt; /* Partition: 0:Auto detect, 1-4:Forced partition) */
|
||||
} PARTITION;
|
||||
extern PARTITION VolToPart[]; /* Volume - Partition mapping table */
|
||||
#endif
|
||||
|
||||
#if FF_STR_VOLUME_ID
|
||||
#ifndef FF_VOLUME_STRS
|
||||
extern const char* VolumeStr[FF_VOLUMES]; /* User defied volume ID */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* Filesystem object structure (FATFS) */
|
||||
|
||||
typedef struct {
|
||||
BYTE fs_type; /* Filesystem type (0:not mounted) */
|
||||
BYTE pdrv; /* Associated physical drive */
|
||||
BYTE n_fats; /* Number of FATs (1 or 2) */
|
||||
BYTE wflag; /* win[] flag (b0:dirty) */
|
||||
BYTE fsi_flag; /* FSINFO flags (b7:disabled, b0:dirty) */
|
||||
WORD id; /* Volume mount ID */
|
||||
WORD n_rootdir; /* Number of root directory entries (FAT12/16) */
|
||||
WORD csize; /* Cluster size [sectors] */
|
||||
#if FF_MAX_SS != FF_MIN_SS
|
||||
WORD ssize; /* Sector size (512, 1024, 2048 or 4096) */
|
||||
#endif
|
||||
#if FF_USE_LFN
|
||||
WCHAR* lfnbuf; /* LFN working buffer */
|
||||
#endif
|
||||
#if FF_FS_EXFAT
|
||||
BYTE* dirbuf; /* Directory entry block scratchpad buffer for exFAT */
|
||||
#endif
|
||||
#if FF_FS_REENTRANT
|
||||
FF_SYNC_t sobj; /* Identifier of sync object */
|
||||
#endif
|
||||
#if !FF_FS_READONLY
|
||||
DWORD last_clst; /* Last allocated cluster */
|
||||
DWORD free_clst; /* Number of free clusters */
|
||||
#endif
|
||||
#if FF_FS_RPATH
|
||||
DWORD cdir; /* Current directory start cluster (0:root) */
|
||||
#if FF_FS_EXFAT
|
||||
DWORD cdc_scl; /* Containing directory start cluster (invalid when cdir is 0) */
|
||||
DWORD cdc_size; /* b31-b8:Size of containing directory, b7-b0: Chain status */
|
||||
DWORD cdc_ofs; /* Offset in the containing directory (invalid when cdir is 0) */
|
||||
#endif
|
||||
#endif
|
||||
DWORD n_fatent; /* Number of FAT entries (number of clusters + 2) */
|
||||
DWORD fsize; /* Size of an FAT [sectors] */
|
||||
LBA_t volbase; /* Volume base sector */
|
||||
LBA_t fatbase; /* FAT base sector */
|
||||
LBA_t dirbase; /* Root directory base sector/cluster */
|
||||
LBA_t database; /* Data base sector */
|
||||
#if FF_FS_EXFAT
|
||||
LBA_t bitbase; /* Allocation bitmap base sector */
|
||||
#endif
|
||||
LBA_t winsect; /* Current sector appearing in the win[] */
|
||||
BYTE win[FF_MAX_SS]; /* Disk access window for Directory, FAT (and file data at tiny cfg) */
|
||||
} FATFS;
|
||||
|
||||
|
||||
|
||||
/* Object ID and allocation information (FFOBJID) */
|
||||
|
||||
typedef struct {
|
||||
FATFS* fs; /* Pointer to the hosting volume of this object */
|
||||
WORD id; /* Hosting volume mount ID */
|
||||
BYTE attr; /* Object attribute */
|
||||
BYTE stat; /* Object chain status (b1-0: =0:not contiguous, =2:contiguous, =3:fragmented in this session, b2:sub-directory stretched) */
|
||||
DWORD sclust; /* Object data start cluster (0:no cluster or root directory) */
|
||||
FSIZE_t objsize; /* Object size (valid when sclust != 0) */
|
||||
#if FF_FS_EXFAT
|
||||
DWORD n_cont; /* Size of first fragment - 1 (valid when stat == 3) */
|
||||
DWORD n_frag; /* Size of last fragment needs to be written to FAT (valid when not zero) */
|
||||
DWORD c_scl; /* Containing directory start cluster (valid when sclust != 0) */
|
||||
DWORD c_size; /* b31-b8:Size of containing directory, b7-b0: Chain status (valid when c_scl != 0) */
|
||||
DWORD c_ofs; /* Offset in the containing directory (valid when file object and sclust != 0) */
|
||||
#endif
|
||||
#if FF_FS_LOCK
|
||||
UINT lockid; /* File lock ID origin from 1 (index of file semaphore table Files[]) */
|
||||
#endif
|
||||
} FFOBJID;
|
||||
|
||||
|
||||
|
||||
/* File object structure (FIL) */
|
||||
|
||||
typedef struct {
|
||||
FFOBJID obj; /* Object identifier (must be the 1st member to detect invalid object pointer) */
|
||||
BYTE flag; /* File status flags */
|
||||
BYTE err; /* Abort flag (error code) */
|
||||
FSIZE_t fptr; /* File read/write pointer (Zeroed on file open) */
|
||||
DWORD clust; /* Current cluster of fpter (invalid when fptr is 0) */
|
||||
LBA_t sect; /* Sector number appearing in buf[] (0:invalid) */
|
||||
#if !FF_FS_READONLY
|
||||
LBA_t dir_sect; /* Sector number containing the directory entry (not used at exFAT) */
|
||||
BYTE* dir_ptr; /* Pointer to the directory entry in the win[] (not used at exFAT) */
|
||||
#endif
|
||||
#if FF_USE_FASTSEEK
|
||||
DWORD* cltbl; /* Pointer to the cluster link map table (nulled on open, set by application) */
|
||||
#endif
|
||||
#if !FF_FS_TINY
|
||||
BYTE buf[FF_MAX_SS]; /* File private data read/write window */
|
||||
#endif
|
||||
} FIL;
|
||||
|
||||
|
||||
|
||||
/* Directory object structure (DIR) */
|
||||
|
||||
typedef struct {
|
||||
FFOBJID obj; /* Object identifier */
|
||||
DWORD dptr; /* Current read/write offset */
|
||||
DWORD clust; /* Current cluster */
|
||||
LBA_t sect; /* Current sector (0:Read operation has terminated) */
|
||||
BYTE* dir; /* Pointer to the directory item in the win[] */
|
||||
BYTE fn[12]; /* SFN (in/out) {body[8],ext[3],status[1]} */
|
||||
#if FF_USE_LFN
|
||||
DWORD blk_ofs; /* Offset of current entry block being processed (0xFFFFFFFF:Invalid) */
|
||||
#endif
|
||||
#if FF_USE_FIND
|
||||
const TCHAR* pat; /* Pointer to the name matching pattern */
|
||||
#endif
|
||||
} DIR;
|
||||
|
||||
|
||||
|
||||
/* File information structure (FILINFO) */
|
||||
|
||||
typedef struct {
|
||||
FSIZE_t fsize; /* File size */
|
||||
WORD fdate; /* Modified date */
|
||||
WORD ftime; /* Modified time */
|
||||
BYTE fattrib; /* File attribute */
|
||||
#if FF_USE_LFN
|
||||
TCHAR altname[FF_SFN_BUF + 1];/* Altenative file name */
|
||||
TCHAR fname[FF_LFN_BUF + 1]; /* Primary file name */
|
||||
#else
|
||||
TCHAR fname[12 + 1]; /* File name */
|
||||
#endif
|
||||
} FILINFO;
|
||||
|
||||
|
||||
|
||||
/* Format parameter structure (MKFS_PARM) */
|
||||
|
||||
typedef struct {
|
||||
BYTE fmt; /* Format option (FM_FAT, FM_FAT32, FM_EXFAT and FM_SFD) */
|
||||
BYTE n_fat; /* Number of FATs */
|
||||
UINT align; /* Data area alignment (sector) */
|
||||
UINT n_root; /* Number of root directory entries */
|
||||
DWORD au_size; /* Cluster size (byte) */
|
||||
} MKFS_PARM;
|
||||
|
||||
|
||||
|
||||
/* File function return code (FRESULT) */
|
||||
|
||||
typedef enum {
|
||||
FR_OK = 0, /* (0) Succeeded */
|
||||
FR_DISK_ERR, /* (1) A hard error occurred in the low level disk I/O layer */
|
||||
FR_INT_ERR, /* (2) Assertion failed */
|
||||
FR_NOT_READY, /* (3) The physical drive cannot work */
|
||||
FR_NO_FILE, /* (4) Could not find the file */
|
||||
FR_NO_PATH, /* (5) Could not find the path */
|
||||
FR_INVALID_NAME, /* (6) The path name format is invalid */
|
||||
FR_DENIED, /* (7) Access denied due to prohibited access or directory full */
|
||||
FR_EXIST, /* (8) Access denied due to prohibited access */
|
||||
FR_INVALID_OBJECT, /* (9) The file/directory object is invalid */
|
||||
FR_WRITE_PROTECTED, /* (10) The physical drive is write protected */
|
||||
FR_INVALID_DRIVE, /* (11) The logical drive number is invalid */
|
||||
FR_NOT_ENABLED, /* (12) The volume has no work area */
|
||||
FR_NO_FILESYSTEM, /* (13) There is no valid FAT volume */
|
||||
FR_MKFS_ABORTED, /* (14) The f_mkfs() aborted due to any problem */
|
||||
FR_TIMEOUT, /* (15) Could not get a grant to access the volume within defined period */
|
||||
FR_LOCKED, /* (16) The operation is rejected according to the file sharing policy */
|
||||
FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */
|
||||
FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files > FF_FS_LOCK */
|
||||
FR_INVALID_PARAMETER /* (19) Given parameter is invalid */
|
||||
} FRESULT;
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------------------------------*/
|
||||
/* FatFs module application interface */
|
||||
|
||||
FRESULT f_open (FIL* fp, const TCHAR* path, BYTE mode); /* Open or create a file */
|
||||
FRESULT f_close (FIL* fp); /* Close an open file object */
|
||||
FRESULT f_read (FIL* fp, void* buff, UINT btr, UINT* br); /* Read data from the file */
|
||||
FRESULT f_write (FIL* fp, const void* buff, UINT btw, UINT* bw); /* Write data to the file */
|
||||
FRESULT f_lseek (FIL* fp, FSIZE_t ofs); /* Move file pointer of the file object */
|
||||
FRESULT f_truncate (FIL* fp); /* Truncate the file */
|
||||
FRESULT f_sync (FIL* fp); /* Flush cached data of the writing file */
|
||||
FRESULT f_opendir (DIR* dp, const TCHAR* path); /* Open a directory */
|
||||
FRESULT f_closedir (DIR* dp); /* Close an open directory */
|
||||
FRESULT f_readdir (DIR* dp, FILINFO* fno); /* Read a directory item */
|
||||
FRESULT f_findfirst (DIR* dp, FILINFO* fno, const TCHAR* path, const TCHAR* pattern); /* Find first file */
|
||||
FRESULT f_findnext (DIR* dp, FILINFO* fno); /* Find next file */
|
||||
FRESULT f_mkdir (const TCHAR* path); /* Create a sub directory */
|
||||
FRESULT f_unlink (const TCHAR* path); /* Delete an existing file or directory */
|
||||
FRESULT f_rename (const TCHAR* path_old, const TCHAR* path_new); /* Rename/Move a file or directory */
|
||||
FRESULT f_stat (const TCHAR* path, FILINFO* fno); /* Get file status */
|
||||
FRESULT f_chmod (const TCHAR* path, BYTE attr, BYTE mask); /* Change attribute of a file/dir */
|
||||
FRESULT f_utime (const TCHAR* path, const FILINFO* fno); /* Change timestamp of a file/dir */
|
||||
FRESULT f_chdir (const TCHAR* path); /* Change current directory */
|
||||
FRESULT f_chdrive (const TCHAR* path); /* Change current drive */
|
||||
FRESULT f_getcwd (TCHAR* buff, UINT len); /* Get current directory */
|
||||
FRESULT f_getfree (const TCHAR* path, DWORD* nclst, FATFS** fatfs); /* Get number of free clusters on the drive */
|
||||
FRESULT f_getlabel (const TCHAR* path, TCHAR* label, DWORD* vsn); /* Get volume label */
|
||||
FRESULT f_setlabel (const TCHAR* label); /* Set volume label */
|
||||
FRESULT f_forward (FIL* fp, UINT(*func)(const BYTE*,UINT), UINT btf, UINT* bf); /* Forward data to the stream */
|
||||
FRESULT f_expand (FIL* fp, FSIZE_t fsz, BYTE opt); /* Allocate a contiguous block to the file */
|
||||
FRESULT f_mount (FATFS* fs, const TCHAR* path, BYTE opt); /* Mount/Unmount a logical drive */
|
||||
FRESULT f_mkfs (const TCHAR* path, const MKFS_PARM* opt, void* work, UINT len); /* Create a FAT volume */
|
||||
FRESULT f_fdisk (BYTE pdrv, const LBA_t ptbl[], void* work); /* Divide a physical drive into some partitions */
|
||||
FRESULT f_setcp (WORD cp); /* Set current code page */
|
||||
int f_putc (TCHAR c, FIL* fp); /* Put a character to the file */
|
||||
int f_puts (const TCHAR* str, FIL* cp); /* Put a string to the file */
|
||||
int f_printf (FIL* fp, const TCHAR* str, ...); /* Put a formatted string to the file */
|
||||
TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the file */
|
||||
|
||||
#define f_eof(fp) ((int)((fp)->fptr == (fp)->obj.objsize))
|
||||
#define f_error(fp) ((fp)->err)
|
||||
#define f_tell(fp) ((fp)->fptr)
|
||||
#define f_size(fp) ((fp)->obj.objsize)
|
||||
#define f_rewind(fp) f_lseek((fp), 0)
|
||||
#define f_rewinddir(dp) f_readdir((dp), 0)
|
||||
#define f_rmdir(path) f_unlink(path)
|
||||
#define f_unmount(path) f_mount(0, path, 0)
|
||||
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------------------------------*/
|
||||
/* Additional user defined functions */
|
||||
|
||||
/* RTC function */
|
||||
#if !FF_FS_READONLY && !FF_FS_NORTC
|
||||
DWORD get_fattime (void);
|
||||
#endif
|
||||
|
||||
/* LFN support functions */
|
||||
#if FF_USE_LFN >= 1 /* Code conversion (defined in unicode.c) */
|
||||
WCHAR ff_oem2uni (WCHAR oem, WORD cp); /* OEM code to Unicode conversion */
|
||||
WCHAR ff_uni2oem (DWORD uni, WORD cp); /* Unicode to OEM code conversion */
|
||||
DWORD ff_wtoupper (DWORD uni); /* Unicode upper-case conversion */
|
||||
#endif
|
||||
#if FF_USE_LFN == 3 /* Dynamic memory allocation */
|
||||
void* ff_memalloc (UINT msize); /* Allocate memory block */
|
||||
void ff_memfree (void* mblock); /* Free memory block */
|
||||
#endif
|
||||
|
||||
/* Sync functions */
|
||||
#if FF_FS_REENTRANT
|
||||
int ff_cre_syncobj (BYTE vol, FF_SYNC_t* sobj); /* Create a sync object */
|
||||
int ff_req_grant (FF_SYNC_t sobj); /* Lock sync object */
|
||||
void ff_rel_grant (FF_SYNC_t sobj); /* Unlock sync object */
|
||||
int ff_del_syncobj (FF_SYNC_t sobj); /* Delete a sync object */
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------------------------------*/
|
||||
/* Flags and offset address */
|
||||
|
||||
|
||||
/* File access mode and open method flags (3rd argument of f_open) */
|
||||
#define FA_READ 0x01
|
||||
#define FA_WRITE 0x02
|
||||
#define FA_OPEN_EXISTING 0x00
|
||||
#define FA_CREATE_NEW 0x04
|
||||
#define FA_CREATE_ALWAYS 0x08
|
||||
#define FA_OPEN_ALWAYS 0x10
|
||||
#define FA_OPEN_APPEND 0x30
|
||||
|
||||
/* Fast seek controls (2nd argument of f_lseek) */
|
||||
#define CREATE_LINKMAP ((FSIZE_t)0 - 1)
|
||||
|
||||
/* Format options (2nd argument of f_mkfs) */
|
||||
#define FM_FAT 0x01
|
||||
#define FM_FAT32 0x02
|
||||
#define FM_EXFAT 0x04
|
||||
#define FM_ANY 0x07
|
||||
#define FM_SFD 0x08
|
||||
|
||||
/* Filesystem type (FATFS.fs_type) */
|
||||
#define FS_FAT12 1
|
||||
#define FS_FAT16 2
|
||||
#define FS_FAT32 3
|
||||
#define FS_EXFAT 4
|
||||
|
||||
/* File attribute bits for directory entry (FILINFO.fattrib) */
|
||||
#define AM_RDO 0x01 /* Read only */
|
||||
#define AM_HID 0x02 /* Hidden */
|
||||
#define AM_SYS 0x04 /* System */
|
||||
#define AM_DIR 0x10 /* Directory */
|
||||
#define AM_ARC 0x20 /* Archive */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* FF_DEFINED */
|
||||
316
RTX5_20220316/Driver/FATFS/source/ffconf.h
Normal file
@ -0,0 +1,316 @@
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ FatFs Functional Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define FFCONF_DEF 86631 /* Revision ID */
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ Function Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define FF_FS_READONLY 0
|
||||
/* This option switches read-only configuration. (0:Read/Write or 1:Read-only)
|
||||
/ Read-only configuration removes writing API functions, f_write(), f_sync(),
|
||||
/ f_unlink(), f_mkdir(), f_chmod(), f_rename(), f_truncate(), f_getfree()
|
||||
/ and optional writing functions as well. */
|
||||
|
||||
|
||||
#define FF_FS_MINIMIZE 0
|
||||
/* This option defines minimization level to remove some basic API functions.
|
||||
/
|
||||
/ 0: Basic functions are fully enabled.
|
||||
/ 1: f_stat(), f_getfree(), f_unlink(), f_mkdir(), f_truncate() and f_rename()
|
||||
/ are removed.
|
||||
/ 2: f_opendir(), f_readdir() and f_closedir() are removed in addition to 1.
|
||||
/ 3: f_lseek() function is removed in addition to 2. */
|
||||
|
||||
|
||||
#define FF_USE_FIND 0
|
||||
/* This option switches filtered directory read functions, f_findfirst() and
|
||||
/ f_findnext(). (0:Disable, 1:Enable 2:Enable with matching altname[] too) */
|
||||
|
||||
|
||||
#define FF_USE_MKFS 1
|
||||
/* This option switches f_mkfs() function. (0:Disable or 1:Enable) */
|
||||
|
||||
|
||||
#define FF_USE_FASTSEEK 1
|
||||
/* This option switches fast seek function. (0:Disable or 1:Enable) */
|
||||
|
||||
|
||||
#define FF_USE_EXPAND 0
|
||||
/* This option switches f_expand function. (0:Disable or 1:Enable) */
|
||||
|
||||
|
||||
#define FF_USE_CHMOD 0
|
||||
/* This option switches attribute manipulation functions, f_chmod() and f_utime().
|
||||
/ (0:Disable or 1:Enable) Also FF_FS_READONLY needs to be 0 to enable this option. */
|
||||
|
||||
|
||||
#define FF_USE_LABEL 0
|
||||
/* This option switches volume label functions, f_getlabel() and f_setlabel().
|
||||
/ (0:Disable or 1:Enable) */
|
||||
|
||||
|
||||
#define FF_USE_FORWARD 0
|
||||
/* This option switches f_forward() function. (0:Disable or 1:Enable) */
|
||||
|
||||
|
||||
#define FF_USE_STRFUNC 0
|
||||
#define FF_PRINT_LLI 0
|
||||
#define FF_PRINT_FLOAT 0
|
||||
#define FF_STRF_ENCODE 0
|
||||
/* FF_USE_STRFUNC switches string functions, f_gets(), f_putc(), f_puts() and
|
||||
/ f_printf().
|
||||
/
|
||||
/ 0: Disable. FF_PRINT_LLI, FF_PRINT_FLOAT and FF_STRF_ENCODE have no effect.
|
||||
/ 1: Enable without LF-CRLF conversion.
|
||||
/ 2: Enable with LF-CRLF conversion.
|
||||
/
|
||||
/ FF_PRINT_LLI = 1 makes f_printf() support long long argument and FF_PRINT_FLOAT = 1/2
|
||||
makes f_printf() support floating point argument. These features want C99 or later.
|
||||
/ When FF_LFN_UNICODE >= 1 with LFN enabled, string functions convert the character
|
||||
/ encoding in it. FF_STRF_ENCODE selects assumption of character encoding ON THE FILE
|
||||
/ to be read/written via those functions.
|
||||
/
|
||||
/ 0: ANSI/OEM in current CP
|
||||
/ 1: Unicode in UTF-16LE
|
||||
/ 2: Unicode in UTF-16BE
|
||||
/ 3: Unicode in UTF-8
|
||||
*/
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ Locale and Namespace Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define FF_CODE_PAGE 437
|
||||
/* This option specifies the OEM code page to be used on the target system.
|
||||
/ Incorrect code page setting can cause a file open failure.
|
||||
/
|
||||
/ 437 - U.S.
|
||||
/ 720 - Arabic
|
||||
/ 737 - Greek
|
||||
/ 771 - KBL
|
||||
/ 775 - Baltic
|
||||
/ 850 - Latin 1
|
||||
/ 852 - Latin 2
|
||||
/ 855 - Cyrillic
|
||||
/ 857 - Turkish
|
||||
/ 860 - Portuguese
|
||||
/ 861 - Icelandic
|
||||
/ 862 - Hebrew
|
||||
/ 863 - Canadian French
|
||||
/ 864 - Arabic
|
||||
/ 865 - Nordic
|
||||
/ 866 - Russian
|
||||
/ 869 - Greek 2
|
||||
/ 932 - Japanese (DBCS)
|
||||
/ 936 - Simplified Chinese (DBCS)
|
||||
/ 949 - Korean (DBCS)
|
||||
/ 950 - Traditional Chinese (DBCS)
|
||||
/ 0 - Include all code pages above and configured by f_setcp()
|
||||
*/
|
||||
|
||||
|
||||
#define FF_USE_LFN 3
|
||||
#define FF_MAX_LFN 255
|
||||
/* The FF_USE_LFN switches the support for LFN (long file name).
|
||||
/
|
||||
/ 0: Disable LFN. FF_MAX_LFN has no effect.
|
||||
/ 1: Enable LFN with static working buffer on the BSS. Always NOT thread-safe.
|
||||
/ 2: Enable LFN with dynamic working buffer on the STACK.
|
||||
/ 3: Enable LFN with dynamic working buffer on the HEAP.
|
||||
/
|
||||
/ To enable the LFN, ffunicode.c needs to be added to the project. The LFN function
|
||||
/ requiers certain internal working buffer occupies (FF_MAX_LFN + 1) * 2 bytes and
|
||||
/ additional (FF_MAX_LFN + 44) / 15 * 32 bytes when exFAT is enabled.
|
||||
/ The FF_MAX_LFN defines size of the working buffer in UTF-16 code unit and it can
|
||||
/ be in range of 12 to 255. It is recommended to be set it 255 to fully support LFN
|
||||
/ specification.
|
||||
/ When use stack for the working buffer, take care on stack overflow. When use heap
|
||||
/ memory for the working buffer, memory management functions, ff_memalloc() and
|
||||
/ ff_memfree() exemplified in ffsystem.c, need to be added to the project. */
|
||||
|
||||
|
||||
#define FF_LFN_UNICODE 0
|
||||
/* This option switches the character encoding on the API when LFN is enabled.
|
||||
/
|
||||
/ 0: ANSI/OEM in current CP (TCHAR = char)
|
||||
/ 1: Unicode in UTF-16 (TCHAR = WCHAR)
|
||||
/ 2: Unicode in UTF-8 (TCHAR = char)
|
||||
/ 3: Unicode in UTF-32 (TCHAR = DWORD)
|
||||
/
|
||||
/ Also behavior of string I/O functions will be affected by this option.
|
||||
/ When LFN is not enabled, this option has no effect. */
|
||||
|
||||
|
||||
#define FF_LFN_BUF 255
|
||||
#define FF_SFN_BUF 12
|
||||
/* This set of options defines size of file name members in the FILINFO structure
|
||||
/ which is used to read out directory items. These values should be suffcient for
|
||||
/ the file names to read. The maximum possible length of the read file name depends
|
||||
/ on character encoding. When LFN is not enabled, these options have no effect. */
|
||||
|
||||
|
||||
#define FF_FS_RPATH 1
|
||||
/* This option configures support for relative path.
|
||||
/
|
||||
/ 0: Disable relative path and remove related functions.
|
||||
/ 1: Enable relative path. f_chdir() and f_chdrive() are available.
|
||||
/ 2: f_getcwd() function is available in addition to 1.
|
||||
*/
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ Drive/Volume Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define FF_VOLUMES 1
|
||||
/* Number of volumes (logical drives) to be used. (1-10) */
|
||||
|
||||
|
||||
#define FF_STR_VOLUME_ID 0
|
||||
#define FF_VOLUME_STRS "RAM","NAND","CF","SD","SD2","USB","USB2","USB3"
|
||||
/* FF_STR_VOLUME_ID switches support for volume ID in arbitrary strings.
|
||||
/ When FF_STR_VOLUME_ID is set to 1 or 2, arbitrary strings can be used as drive
|
||||
/ number in the path name. FF_VOLUME_STRS defines the volume ID strings for each
|
||||
/ logical drives. Number of items must not be less than FF_VOLUMES. Valid
|
||||
/ characters for the volume ID strings are A-Z, a-z and 0-9, however, they are
|
||||
/ compared in case-insensitive. If FF_STR_VOLUME_ID >= 1 and FF_VOLUME_STRS is
|
||||
/ not defined, a user defined volume string table needs to be defined as:
|
||||
/
|
||||
/ const char* VolumeStr[FF_VOLUMES] = {"ram","flash","sd","usb",...
|
||||
*/
|
||||
|
||||
|
||||
#define FF_MULTI_PARTITION 0
|
||||
/* This option switches support for multiple volumes on the physical drive.
|
||||
/ By default (0), each logical drive number is bound to the same physical drive
|
||||
/ number and only an FAT volume found on the physical drive will be mounted.
|
||||
/ When this function is enabled (1), each logical drive number can be bound to
|
||||
/ arbitrary physical drive and partition listed in the VolToPart[]. Also f_fdisk()
|
||||
/ funciton will be available. */
|
||||
|
||||
|
||||
#define FF_MIN_SS 512
|
||||
#define FF_MAX_SS 512
|
||||
/* This set of options configures the range of sector size to be supported. (512,
|
||||
/ 1024, 2048 or 4096) Always set both 512 for most systems, generic memory card and
|
||||
/ harddisk, but a larger value may be required for on-board flash memory and some
|
||||
/ type of optical media. When FF_MAX_SS is larger than FF_MIN_SS, FatFs is configured
|
||||
/ for variable sector size mode and disk_ioctl() function needs to implement
|
||||
/ GET_SECTOR_SIZE command. */
|
||||
|
||||
|
||||
#define FF_LBA64 0
|
||||
/* This option switches support for 64-bit LBA. (0:Disable or 1:Enable)
|
||||
/ To enable the 64-bit LBA, also exFAT needs to be enabled. (FF_FS_EXFAT == 1) */
|
||||
|
||||
|
||||
#define FF_MIN_GPT 0x10000000
|
||||
/* Minimum number of sectors to switch GPT as partitioning format in f_mkfs and
|
||||
/ f_fdisk function. 0x100000000 max. This option has no effect when FF_LBA64 == 0. */
|
||||
|
||||
|
||||
#define FF_USE_TRIM 0
|
||||
/* This option switches support for ATA-TRIM. (0:Disable or 1:Enable)
|
||||
/ To enable Trim function, also CTRL_TRIM command should be implemented to the
|
||||
/ disk_ioctl() function. */
|
||||
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ System Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define FF_FS_TINY 0
|
||||
/* This option switches tiny buffer configuration. (0:Normal or 1:Tiny)
|
||||
/ At the tiny configuration, size of file object (FIL) is shrinked FF_MAX_SS bytes.
|
||||
/ Instead of private sector buffer eliminated from the file object, common sector
|
||||
/ buffer in the filesystem object (FATFS) is used for the file data transfer. */
|
||||
|
||||
|
||||
#define FF_FS_EXFAT 0
|
||||
/* This option switches support for exFAT filesystem. (0:Disable or 1:Enable)
|
||||
/ To enable exFAT, also LFN needs to be enabled. (FF_USE_LFN >= 1)
|
||||
/ Note that enabling exFAT discards ANSI C (C89) compatibility. */
|
||||
|
||||
|
||||
#define FF_FS_NORTC 0
|
||||
#define FF_NORTC_MON 1
|
||||
#define FF_NORTC_MDAY 1
|
||||
#define FF_NORTC_YEAR 2020
|
||||
/* The option FF_FS_NORTC switches timestamp functiton. If the system does not have
|
||||
/ any RTC function or valid timestamp is not needed, set FF_FS_NORTC = 1 to disable
|
||||
/ the timestamp function. Every object modified by FatFs will have a fixed timestamp
|
||||
/ defined by FF_NORTC_MON, FF_NORTC_MDAY and FF_NORTC_YEAR in local time.
|
||||
/ To enable timestamp function (FF_FS_NORTC = 0), get_fattime() function need to be
|
||||
/ added to the project to read current time form real-time clock. FF_NORTC_MON,
|
||||
/ FF_NORTC_MDAY and FF_NORTC_YEAR have no effect.
|
||||
/ These options have no effect in read-only configuration (FF_FS_READONLY = 1). */
|
||||
|
||||
|
||||
#define FF_FS_NOFSINFO 0
|
||||
/* If you need to know correct free space on the FAT32 volume, set bit 0 of this
|
||||
/ option, and f_getfree() function at first time after volume mount will force
|
||||
/ a full FAT scan. Bit 1 controls the use of last allocated cluster number.
|
||||
/
|
||||
/ bit0=0: Use free cluster count in the FSINFO if available.
|
||||
/ bit0=1: Do not trust free cluster count in the FSINFO.
|
||||
/ bit1=0: Use last allocated cluster number in the FSINFO if available.
|
||||
/ bit1=1: Do not trust last allocated cluster number in the FSINFO.
|
||||
*/
|
||||
|
||||
|
||||
#define FF_FS_LOCK 2
|
||||
/* The option FF_FS_LOCK switches file lock function to control duplicated file open
|
||||
/ and illegal operation to open objects. This option must be 0 when FF_FS_READONLY
|
||||
/ is 1.
|
||||
/
|
||||
/ 0: Disable file lock function. To avoid volume corruption, application program
|
||||
/ should avoid illegal open, remove and rename to the open objects.
|
||||
/ >0: Enable file lock function. The value defines how many files/sub-directories
|
||||
/ can be opened simultaneously under file lock control. Note that the file
|
||||
/ lock control is independent of re-entrancy. */
|
||||
|
||||
|
||||
/* #include <somertos.h> // O/S definitions */
|
||||
#define FF_FS_REENTRANT 0
|
||||
#define FF_FS_TIMEOUT 1000
|
||||
#define FF_SYNC_t HANDLE
|
||||
/* The option FF_FS_REENTRANT switches the re-entrancy (thread safe) of the FatFs
|
||||
/ module itself. Note that regardless of this option, file access to different
|
||||
/ volume is always re-entrant and volume control functions, f_mount(), f_mkfs()
|
||||
/ and f_fdisk() function, are always not re-entrant. Only file/directory access
|
||||
/ to the same volume is under control of this function.
|
||||
/
|
||||
/ 0: Disable re-entrancy. FF_FS_TIMEOUT and FF_SYNC_t have no effect.
|
||||
/ 1: Enable re-entrancy. Also user provided synchronization handlers,
|
||||
/ ff_req_grant(), ff_rel_grant(), ff_del_syncobj() and ff_cre_syncobj()
|
||||
/ function, must be added to the project. Samples are available in
|
||||
/ option/syscall.c.
|
||||
/
|
||||
/ The FF_FS_TIMEOUT defines timeout period in unit of time tick.
|
||||
/ The FF_SYNC_t defines O/S dependent sync object type. e.g. HANDLE, ID, OS_EVENT*,
|
||||
/ SemaphoreHandle_t and etc. A header file for O/S definitions needs to be
|
||||
/ included somewhere in the scope of ff.h. */
|
||||
|
||||
|
||||
|
||||
#if FF_USE_LFN == 3
|
||||
#if !defined(ff_malloc) || !defined(ff_free)
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#if !defined(ff_malloc)
|
||||
#define ff_malloc malloc
|
||||
#endif
|
||||
|
||||
#if !defined(ff_free)
|
||||
#define ff_free free
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/*--- End of configuration options ---*/
|
||||
171
RTX5_20220316/Driver/FATFS/source/ffsystem.c
Normal file
@ -0,0 +1,171 @@
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Sample Code of OS Dependent Functions for FatFs */
|
||||
/* (C)ChaN, 2018 */
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#include "ff.h"
|
||||
|
||||
|
||||
#if FF_USE_LFN == 3 /* Dynamic memory allocation */
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Allocate a memory block */
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
void* ff_memalloc ( /* Returns pointer to the allocated memory block (null if not enough core) */
|
||||
UINT msize /* Number of bytes to allocate */
|
||||
)
|
||||
{
|
||||
return malloc(msize); /* Allocate a new memory block with POSIX API */
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Free a memory block */
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
void ff_memfree (
|
||||
void* mblock /* Pointer to the memory block to free (nothing to do if null) */
|
||||
)
|
||||
{
|
||||
free(mblock); /* Free the memory block with POSIX API */
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if FF_FS_REENTRANT /* Mutal exclusion */
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Create a Synchronization Object */
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* This function is called in f_mount() function to create a new
|
||||
/ synchronization object for the volume, such as semaphore and mutex.
|
||||
/ When a 0 is returned, the f_mount() function fails with FR_INT_ERR.
|
||||
*/
|
||||
|
||||
//const osMutexDef_t Mutex[FF_VOLUMES]; /* Table of CMSIS-RTOS mutex */
|
||||
|
||||
|
||||
int ff_cre_syncobj ( /* 1:Function succeeded, 0:Could not create the sync object */
|
||||
BYTE vol, /* Corresponding volume (logical drive number) */
|
||||
FF_SYNC_t* sobj /* Pointer to return the created sync object */
|
||||
)
|
||||
{
|
||||
/* Win32 */
|
||||
*sobj = CreateMutex(NULL, FALSE, NULL);
|
||||
return (int)(*sobj != INVALID_HANDLE_VALUE);
|
||||
|
||||
/* uITRON */
|
||||
// T_CSEM csem = {TA_TPRI,1,1};
|
||||
// *sobj = acre_sem(&csem);
|
||||
// return (int)(*sobj > 0);
|
||||
|
||||
/* uC/OS-II */
|
||||
// OS_ERR err;
|
||||
// *sobj = OSMutexCreate(0, &err);
|
||||
// return (int)(err == OS_NO_ERR);
|
||||
|
||||
/* FreeRTOS */
|
||||
// *sobj = xSemaphoreCreateMutex();
|
||||
// return (int)(*sobj != NULL);
|
||||
|
||||
/* CMSIS-RTOS */
|
||||
// *sobj = osMutexCreate(&Mutex[vol]);
|
||||
// return (int)(*sobj != NULL);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Delete a Synchronization Object */
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* This function is called in f_mount() function to delete a synchronization
|
||||
/ object that created with ff_cre_syncobj() function. When a 0 is returned,
|
||||
/ the f_mount() function fails with FR_INT_ERR.
|
||||
*/
|
||||
|
||||
int ff_del_syncobj ( /* 1:Function succeeded, 0:Could not delete due to an error */
|
||||
FF_SYNC_t sobj /* Sync object tied to the logical drive to be deleted */
|
||||
)
|
||||
{
|
||||
/* Win32 */
|
||||
return (int)CloseHandle(sobj);
|
||||
|
||||
/* uITRON */
|
||||
// return (int)(del_sem(sobj) == E_OK);
|
||||
|
||||
/* uC/OS-II */
|
||||
// OS_ERR err;
|
||||
// OSMutexDel(sobj, OS_DEL_ALWAYS, &err);
|
||||
// return (int)(err == OS_NO_ERR);
|
||||
|
||||
/* FreeRTOS */
|
||||
// vSemaphoreDelete(sobj);
|
||||
// return 1;
|
||||
|
||||
/* CMSIS-RTOS */
|
||||
// return (int)(osMutexDelete(sobj) == osOK);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Request Grant to Access the Volume */
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* This function is called on entering file functions to lock the volume.
|
||||
/ When a 0 is returned, the file function fails with FR_TIMEOUT.
|
||||
*/
|
||||
|
||||
int ff_req_grant ( /* 1:Got a grant to access the volume, 0:Could not get a grant */
|
||||
FF_SYNC_t sobj /* Sync object to wait */
|
||||
)
|
||||
{
|
||||
/* Win32 */
|
||||
return (int)(WaitForSingleObject(sobj, FF_FS_TIMEOUT) == WAIT_OBJECT_0);
|
||||
|
||||
/* uITRON */
|
||||
// return (int)(wai_sem(sobj) == E_OK);
|
||||
|
||||
/* uC/OS-II */
|
||||
// OS_ERR err;
|
||||
// OSMutexPend(sobj, FF_FS_TIMEOUT, &err));
|
||||
// return (int)(err == OS_NO_ERR);
|
||||
|
||||
/* FreeRTOS */
|
||||
// return (int)(xSemaphoreTake(sobj, FF_FS_TIMEOUT) == pdTRUE);
|
||||
|
||||
/* CMSIS-RTOS */
|
||||
// return (int)(osMutexWait(sobj, FF_FS_TIMEOUT) == osOK);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Release Grant to Access the Volume */
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* This function is called on leaving file functions to unlock the volume.
|
||||
*/
|
||||
|
||||
void ff_rel_grant (
|
||||
FF_SYNC_t sobj /* Sync object to be signaled */
|
||||
)
|
||||
{
|
||||
/* Win32 */
|
||||
ReleaseMutex(sobj);
|
||||
|
||||
/* uITRON */
|
||||
// sig_sem(sobj);
|
||||
|
||||
/* uC/OS-II */
|
||||
// OSMutexPost(sobj);
|
||||
|
||||
/* FreeRTOS */
|
||||
// xSemaphoreGive(sobj);
|
||||
|
||||
/* CMSIS-RTOS */
|
||||
// osMutexRelease(sobj);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||