FIL *fsrc;
const u8 write_test[] = "write U-Disk OK!
";
void write_data_to_usb(u8* data_buffer, u8 data_len)
{
u8 res;
UINT bw;
//u32 file_size;
fsrc =(FIL*)mymalloc(SRAMIN,sizeof(FIL));
res = f_open(fsrc, "2:/test.txt" , FA_OPEN_ALWAYS| FA_READ | FA_WRITE);
if(res == 0)
{
f_lseek (fsrc , f_size(fsrc));
f_write(fsrc , data_buffer , data_len, &bw);
delay_ms (500);
}
myfree(SRAMIN, file);
f_close(fsrc);
} |