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设为输入,监控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 ); /* 关闭文件,自动计算文件长度,以字节为单位写文件,建议让程序库关闭文件以便自动更新文件长度 */ mStopIfError( s );
PutIn[0] = '1'; PutIn[1] = 'F'; /* 写入数据稍作修改,准备追写 */
PathName = &nFname[0]; s = CH376FileOpenPath( PathName ); mStopIfError(s);
CH376GetFileSize( ); s = CH376ByteLocate( 0xFFFFFFFF ); /* 移动当前文件指针到末尾 */ mStopIfError(s);
s = CH376ByteWrite( buff, sizeof(PutIn), NULL ); mStopIfError(s);
s = CH376FileClose( TURE ); /* 关闭文件,自动计算文件长度,以字节为单位写文件,建议让程序库关闭文件以便自动更新文件长度 */ mStopIfError( s );