您好字节写可以写入多字节。UINT8CH376ByteWrite( PUINT8 buf, UINT16 ReqCount, PUINT16 RealCount ) ,长度为uint16。您如果写入超过255就无法写入的话,看一下存放数据的缓冲区大小是否大于255,其次调用字节写函数的实参长度是否正确。最后您可以确认一下字节写函数的参数定义是否为uint16类型。这边贴出部分代码提供参考。
//此处为while(1)里面的部分代码。
s = CreateFileAndTime( "/123.TXT", 1, MAKE_FILE_DATE( 2020, 6, 8 ), MAKE_FILE_TIME( 15, 39, 20 ), MAKE_FILE_DATE( 2020, 6, 8 ), MAKE_FILE_TIME( 15, 39, 20 ) );
printf("1rn");
mStopIfError( s );
printf("1rn");
s=CH376FileOpen("/123.TXT");
mStopIfError( s );
//s=DataToChar( 45678, buf1 );
//
//s=sizeof(buf_long1);
s = CH376ByteWrite( buf_long1, 512, p );
s = CH376FileClose( TRUE );
Delay_Ms( 20 );
以下为驱动代码。
UINT8CH376ByteWrite( PUINT8 buf, UINT16 ReqCount, PUINT16 RealCount ) /* ??×??????????ò?±?°?????????????é */
{
UINT8s;
xWriteCH376Cmd( CMD2H_BYTE_WRITE );
xWriteCH376Data( (UINT8)ReqCount );
xWriteCH376Data( (UINT8)(ReqCount>>8) );
xEndCH376Cmd( );
if ( RealCount ) *RealCount = 0;
while ( 1 ) {
s = Wait376Interrupt( );
if ( s == USB_INT_DISK_WRITE ) {
s = CH376WriteReqBlock( buf ); /* ?ò???????¨?????????????ó???????é,·????¤?? */
xWriteCH376Cmd( CMD0H_BYTE_WR_GO );
xEndCH376Cmd( );
buf += s;
if ( RealCount ) *RealCount += s;
}
/*else if ( s == USB_INT_SUCCESS ) return( s );*/ /* ?á?? */
else return( s ); /* ?í?ó */
}
}
if ( s == USB_INT_DISK_WRITE )卡在这个判断条件,说明还在做请求写入的操作。您最好看一下长度是否给对。
您好字节写可以写入多字节。UINT8CH376ByteWrite( PUINT8 buf, UINT16 ReqCount, PUINT16 RealCount ) ,长度为uint16。您如果写入超过255就无法写入的话,看一下存放数据的缓冲区大小是否大于255,其次调用字节写函数的实参长度是否正确。最后您可以确认一下字节写函数的参数定义是否为uint16类型。这边贴出部分代码提供参考。
//此处为while(1)里面的部分代码。
s = CreateFileAndTime( "/123.TXT", 1, MAKE_FILE_DATE( 2020, 6, 8 ), MAKE_FILE_TIME( 15, 39, 20 ), MAKE_FILE_DATE( 2020, 6, 8 ), MAKE_FILE_TIME( 15, 39, 20 ) );
printf("1rn");
mStopIfError( s );
printf("1rn");
s=CH376FileOpen("/123.TXT");
mStopIfError( s );
//s=DataToChar( 45678, buf1 );
//
//s=sizeof(buf_long1);
s = CH376ByteWrite( buf_long1, 512, p );
s = CH376FileClose( TRUE );
Delay_Ms( 20 );
以下为驱动代码。
UINT8CH376ByteWrite( PUINT8 buf, UINT16 ReqCount, PUINT16 RealCount ) /* ??×??????????ò?±?°?????????????é */
{
UINT8s;
xWriteCH376Cmd( CMD2H_BYTE_WRITE );
xWriteCH376Data( (UINT8)ReqCount );
xWriteCH376Data( (UINT8)(ReqCount>>8) );
xEndCH376Cmd( );
if ( RealCount ) *RealCount = 0;
while ( 1 ) {
s = Wait376Interrupt( );
if ( s == USB_INT_DISK_WRITE ) {
s = CH376WriteReqBlock( buf ); /* ?ò???????¨?????????????ó???????é,·????¤?? */
xWriteCH376Cmd( CMD0H_BYTE_WR_GO );
xEndCH376Cmd( );
buf += s;
if ( RealCount ) *RealCount += s;
}
/*else if ( s == USB_INT_SUCCESS ) return( s );*/ /* ?á?? */
else return( s ); /* ?í?ó */
}
}
if ( s == USB_INT_DISK_WRITE )卡在这个判断条件,说明还在做请求写入的操作。您最好看一下长度是否给对。
举报