341的并口模式,包中加入延遲的問題

在spi通信中加入延遲mBuffer[ k++ ] = mCH341A_CMD_UIO_STM_DLY | delay;,加入后一個字節(jié)需要5*8=40字節(jié), 因?yàn)橐粋€包長度32字節(jié),于是將j=8的循環(huán)分為2個循環(huán),構(gòu)造2個包,即2個包才完成一個字節(jié)有效數(shù)據(jù)的發(fā)送和接收。但是結(jié)果不正確。是不是CH341WriteRead( index, k, mBuffer, 8, OutLen, &j, mBuffer );的參數(shù)也要修改???

沒有加入延遲的代碼如下: for( i = 0; i != OutLen; i++ ) { tem = *p; mBuffer[ k++ ] = mCH341A_CMD_UIO_STREAM; // 命令碼 for( j = 0; j != 8; j++ ) { c = tem & 0x80 ? 0x20 : 0; // D5 數(shù)據(jù)輸出 mBuffer[ k++ ] = mCH341A_CMD_UIO_STM_OUT | c; // D3=0, I/O_CLOCK=LOW mBuffer[ k++ ] = mCH341A_CMD_UIO_STM_OUT | c | 0x08; // D3=1, I/O_CLOCK=HIGH mBuffer[ k++ ] = mCH341A_CMD_UIO_STM_IN; // input from D7 tem <<= 1; } mBuffer[ k++ ] = mCH341A_CMD_UIO_STM_OUT | c | 0x00; // D3=0, I/O_CLOCK=LOW mBuffer[ k++ ] = mCH341A_CMD_UIO_STM_END; // 當(dāng)前命令包提前結(jié)束 k += mCH341_PACKET_LENGTH - 1; k &= ~ ( mCH341_PACKET_LENGTH - 1 ); p++; } i = CH341WriteRead( index, k, mBuffer, 8, OutLen, &j, mBuffer );

不明白你的意思,下面是關(guān)于延時的操作代碼: while ( iDelay ) { //mCH341A_CMD_I2C_STM_DLY = 0x0F,單次最大延時16ms 2008-9-11 szk add mLength = iDelay >= mCH341A_CMD_I2C_STM_DLY ? mCH341A_CMD_I2C_STM_DLY : iDelay; iDelay -= mLength; mBuffer[0] = mCH341A_CMD_I2C_STREAM; mBuffer[1] = (UCHAR)( mCH341A_CMD_I2C_STM_MS | mLength ); // 以亳秒為單位延時,位3-位0為延時值 mBuffer[2] = mCH341A_CMD_I2C_STM_END; mLength = 3; if ( CH341WriteData( iIndex, mBuffer, &mLength ) == FALSE ) return( FALSE ); // 寫出數(shù)據(jù)塊 }


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

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