查看庫(kù)頭文件CH341DLL.H中有如下定義
#define?? ??? ?mCH341A_CMD_I2C_STM_STA?? ?0x74?? ??? ?// I2C接口的命令流:產(chǎn)生起始位
#define?? ??? ?mCH341A_CMD_I2C_STM_STO?? ?0x75?? ??? ?// I2C接口的命令流:產(chǎn)生停止位
#define?? ??? ?mCH341A_CMD_I2C_STM_OUT?? ?0x80?? ??? ?// I2C接口的命令流:輸出數(shù)據(jù),位5-位0為長(zhǎng)度,后續(xù)字節(jié)為數(shù)據(jù),0長(zhǎng)度則只發(fā)送一個(gè)字節(jié)并返回應(yīng)答
#define?? ??? ?mCH341A_CMD_I2C_STM_IN?? ?0xC0?? ??? ?// I2C接口的命令流:輸入數(shù)據(jù),位5-位0為長(zhǎng)度,0長(zhǎng)度則只接收一個(gè)字節(jié)并發(fā)送無應(yīng)答
#define?? ??? ?mCH341A_CMD_I2C_STM_MAX?? ?( min( 0x3F, mCH341_PACKET_LENGTH ) )?? ?// I2C接口的命令流單個(gè)命令輸入輸出數(shù)據(jù)的最大長(zhǎng)度
#define?? ??? ?mCH341A_CMD_I2C_STM_SET?? ?0x60?? ??? ?// I2C接口的命令流:設(shè)置參數(shù),位2=SPI的I/O數(shù)(0=單入單出,1=雙入雙出),位1位0=I2C速度(00=低速,01=標(biāo)準(zhǔn),10=快速,11=高速)
#define?? ??? ?mCH341A_CMD_I2C_STM_US?? ?0x40?? ??? ?// I2C接口的命令流:以微秒為單位延時(shí),位3-位0為延時(shí)值
#define?? ??? ?mCH341A_CMD_I2C_STM_MS?? ?0x50?? ??? ?// I2C接口的命令流:以亳秒為單位延時(shí),位3-位0為延時(shí)值
#define?? ??? ?mCH341A_CMD_I2C_STM_DLY?? ?0x0F?? ??? ?// I2C接口的命令流單個(gè)命令延時(shí)的最大值
#define?? ??? ?mCH341A_CMD_I2C_STM_END?? ?0x00?? ??? ?// I2C接口的命令流:命令包提前結(jié)束
以及I2C相關(guān)函數(shù)
BOOL?? ?WINAPI?? ?CH341ReadI2C(? // 從I2C接口讀取一個(gè)字節(jié)數(shù)據(jù)
?? ?ULONG?? ??? ??? ?iIndex,? // 指定CH341設(shè)備序號(hào)
?? ?UCHAR?? ??? ??? ?iDevice,? // 低7位指定I2C設(shè)備地址
?? ?UCHAR?? ??? ??? ?iAddr,? // 指定數(shù)據(jù)單元的地址
?? ?PUCHAR?? ??? ??? ?oByte );? // 指向一個(gè)字節(jié)單元,用于保存讀取的字節(jié)數(shù)據(jù)
BOOL?? ?WINAPI?? ?CH341WriteI2C(? // 向I2C接口寫入一個(gè)字節(jié)數(shù)據(jù)
?? ?ULONG?? ??? ??? ?iIndex,? // 指定CH341設(shè)備序號(hào)
?? ?UCHAR?? ??? ??? ?iDevice,? // 低7位指定I2C設(shè)備地址
?? ?UCHAR?? ??? ??? ?iAddr,? // 指定數(shù)據(jù)單元的地址
?? ?UCHAR?? ??? ??? ?iByte );? // 待寫入的字節(jié)數(shù)據(jù)
不知如何使用,求解!
在下想自己寫一個(gè)利用 CH341調(diào)試單片機(jī)I2C從機(jī)的 上位機(jī)程序!需要使用I2C中的具體功能指令如 起始命令,停止命令,應(yīng)答等等。等待高手指點(diǎn),