UINT8 i,s; PUINT8 name; PUINT8 buff; PUINT8 PathName;
unsigned char FDname[] = {"06-22"}; unsigned char Fname[] = {"T.TXT"}; unsigned char PutIn[]= {"testing of write the file"}; unsigned char nFname[] = {"/06-22/T.TXT"};
TRISBbits.TRISB0 = 1; /* INT設(shè)為輸入,監(jiān)控U盤連接 */
TRISEbits.TRISE0 = 0; TRISEbits.TRISE1 = 0; TRISEbits.TRISE2 = 0; TRISAbits.TRISA0 = 0;
s = mInitCH376Host(); /* 初始化CH376 */ mStopIfError(s);
DelayUS(1); s = CKECK_connect(); /* 檢查連接 */ mStopIfError(s);
DelayUS(1); s = CH376DiskMount(); /* U盤初始化 */ mStopIfError(s);
name = &FDname[0]; s = CH376DirCreate( name ); mStopIfError(s);
name = &Fname[0]; s = CH376FileCreate( name ); mStopIfError(s);
buff = &PutIn[0]; s = CH376ByteWrite( buff, sizeof(PutIn), NULL ); mStopIfError(s);
s = CH376FileClose( TURE ); /* 關(guān)閉文件,自動(dòng)計(jì)算文件長(zhǎng)度,以字節(jié)為單位寫文件,建議讓程序庫(kù)關(guān)閉文件以便自動(dòng)更新文件長(zhǎng)度 */ mStopIfError( s );
PutIn[0] = '1'; PutIn[1] = 'F'; /* 寫入數(shù)據(jù)稍作修改,準(zhǔn)備追寫 */
PathName = &nFname[0]; s = CH376FileOpenPath( PathName ); mStopIfError(s);
CH376GetFileSize( ); s = CH376ByteLocate( 0xFFFFFFFF ); /* 移動(dòng)當(dāng)前文件指針到末尾 */ mStopIfError(s);
s = CH376ByteWrite( buff, sizeof(PutIn), NULL ); mStopIfError(s);
s = CH376FileClose( TURE ); /* 關(guān)閉文件,自動(dòng)計(jì)算文件長(zhǎng)度,以字節(jié)為單位寫文件,建議讓程序庫(kù)關(guān)閉文件以便自動(dòng)更新文件長(zhǎng)度 */ mStopIfError( s );