CH376ByteWrite字節(jié)寫數(shù)據(jù)有問題

通過例程里面的CH376ByteWrite函數(shù)發(fā)送數(shù)據(jù),發(fā)現(xiàn)死在if ( s == USB_INT_DISK_WRITE )這步,返回的都是14,寫不進(jìn)去數(shù)據(jù),自己修改后不加這步直接寫入可以,但是后續(xù)發(fā)現(xiàn)只能寫255byte,超過一個(gè)字節(jié)就寫不進(jìn)去,求解

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 );? /* ?í?ó */

//? ? return( s );? /* ?í?ó */

////}

? ??

? ? s = Wait376Interrupt();

? ? xWriteCH376Cmd(CMD_WR_REQ_DATA);?

? ? if(ReqCount)

? ? {

? ? ? ? do

? ? ? ? {

? ? ? ? ? ? xWriteCH376Data(*buf);

? ? ? ? ? ? buf++;

? ? ? ? }while(--ReqCount);

? ? }?


? ? xWriteCH376Cmd(CMD_BYTE_WR_GO);?

? ? s = Wait376Interrupt();? ? ? ??

? ??

? ? return s;

}


您好字節(jié)寫可以寫入多字節(jié)。UINT8CH376ByteWrite( PUINT8 buf, UINT16 ReqCount, PUINT16 RealCount ) ,長度為uint16。您如果寫入超過255就無法寫入的話,看一下存放數(shù)據(jù)的緩沖區(qū)大小是否大于255,其次調(diào)用字節(jié)寫函數(shù)的實(shí)參長度是否正確。最后您可以確認(rèn)一下字節(jié)寫函數(shù)的參數(shù)定義是否為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("1\r\n");

mStopIfError( s );

printf("1\r\n");

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 );


以下為驅(qū)動代碼。

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 )卡在這個(gè)判斷條件,說明還在做請求寫入的操作。您最好看一下長度是否給對。



只有登錄才能回復(fù),可以選擇微信賬號登錄

国产91精品新入口,国产成人综合网在线播放,九热这里只有精品,本道在线观看,美女视频a美女视频,韩国美女激情视频,日本美女pvp视频