CH341A如何實現(xiàn)SPI功能

再VB中CH341A如何實現(xiàn)SPI功能,片選CS如何置高,最好有演示代碼。多謝?。?!

相關(guān)的例子程序在/ch341/evt/ch341vb CH341A實現(xiàn)SPI功能步驟: 一:打開設(shè)備 Declare Function CH341OpenDevice Lib "CH341DLL.DLL" (ByVal iIndex As Long) As Long ' 打開CH341設(shè)備,返回句柄,出錯則無效 ' iIndex 指定CH341設(shè)備序號,0對應(yīng)第一個設(shè)備 二:設(shè)置流模式 Declare Function CH341SetStream Lib "CH341DLL.DLL" (ByVal iIndex As Long, ByVal iMode As Long) As Boolean ' CH341SetStream 設(shè)置串口流模式 ' iIndex, 指定CH341設(shè)備序號 ' iMode 指定模式,見下行 ' 位1-位0: I2C接口速度/SCL頻率, 00=低速/20KHz,01=標準/100KHz,10=快速/400KHz,11=高速/750KHz ' 位2: SPI的I/O數(shù)/IO引腳, 0=單入單出(D5出/D7入),1=雙入雙出(D5出D4出/D7入D6入) ' 其它保留,必須為0

三:處理SPI數(shù)據(jù)流 Declare Function CH341StreamSPI3 Lib "CH341DLL.DLL" (ByVal iIndex As Long, ByVal iChipSelect As Long, ByVal iLength As Long, ByRef ioBuffer As Any) As Boolean ' CH341StreamSPI3 處理SPI數(shù)據(jù)流,3線接口,時鐘線為DCK2/SCL引腳,數(shù)據(jù)線為DIO/SDA引腳(準雙向I/O),片選線為D0/D1/D2,速度約51K字節(jié) ' SPI時序: DCK2/SCL引腳為時鐘輸出, 默認為低電平, DIO/SDA引腳在時鐘上升沿之前輸出, DIO/SDA引腳在時鐘下降沿之后輸入 ' iIndex, 指定CH341設(shè)備序號 ' iChipSelect,片選控制, 位7為0則忽略片選控制, 位7為1則參數(shù)有效: 位1位0為00/01/10分別選擇D0/D1/D2引腳作為低電平有效片選 ' iLength, 準備傳輸?shù)臄?shù)據(jù)字節(jié)數(shù) ' ioBuffer 指向一個緩沖區(qū),放置準備從DIO寫出的數(shù)據(jù),返回后是從DIO讀入的數(shù)據(jù)

Declare Function CH341StreamSPI4 Lib "CH341DLL.DLL" (ByVal iIndex As Long, ByVal iChipSelect As Long, ByVal iLength As Long, ByRef ioBuffer As Any) As Boolean ' CH341StreamSPI4 處理SPI數(shù)據(jù)流,4線接口,時鐘線為DCK/D3引腳,輸出數(shù)據(jù)線為DOUT/D5引腳,輸入數(shù)據(jù)線為DIN/D7引腳,片選線為D0/D1/D2,速度約68K字節(jié) ' SPI時序: DCK/D3引腳為時鐘輸出, 默認為低電平, DOUT/D5引腳在時鐘上升沿之前輸出, DIN/D7引腳在時鐘下降沿之后輸入 ' iIndex, 指定CH341設(shè)備序號 ' iChipSelect,片選控制, 位7為0則忽略片選控制, 位7為1則參數(shù)有效: 位1位0為00/01/10分別選擇D0/D1/D2引腳作為低電平有效片選 ' iLength, 準備傳輸?shù)臄?shù)據(jù)字節(jié)數(shù) ' ioBuffer 指向一個緩沖區(qū),放置準備從DOUT寫出的數(shù)據(jù),返回后是從DIN讀入的數(shù)據(jù)

Declare Function CH341StreamSPI5 Lib "CH341DLL.DLL" (ByVal iIndex As Long, ByVal iChipSelect As Long, ByVal iLength As Long, ByRef ioBuffer As Any, ByRef ioBuffer2 As Any) As Boolean ' CH341StreamSPI5 處理SPI數(shù)據(jù)流,5線接口,時鐘線為DCK/D3引腳,輸出數(shù)據(jù)線為DOUT/D5和DOUT2/D4引腳,輸入數(shù)據(jù)線為DIN/D7和DIN2/D6引腳,片選線為D0/D1/D2,速度約30K字節(jié)*2 ' SPI時序: DCK/D3引腳為時鐘輸出, 默認為低電平, DOUT/D5和DOUT2/D4引腳在時鐘上升沿之前輸出, DIN/D7和DIN2/D6引腳在時鐘下降沿之后輸入 ' iIndex, 指定CH341設(shè)備序號 ' iChipSelect,片選控制, 位7為0則忽略片選控制, 位7為1則參數(shù)有效: 位1位0為00/01/10分別選擇D0/D1/D2引腳作為低電平有效片選 ' iLength, 準備傳輸?shù)臄?shù)據(jù)字節(jié)數(shù) ' ioBuffer, 指向一個緩沖區(qū),放置準備從DOUT寫出的數(shù)據(jù),返回后是從DIN讀入的數(shù)據(jù) ' ioBuffer2 指向第二個緩沖區(qū),放置準備從DOUT2寫出的數(shù)據(jù),返回后是從DIN2讀入的數(shù)據(jù)

Declare Function CH341BitStreamSPI Lib "CH341DLL.DLL" (ByVal iIndex As Long, ByVal iLength As Long, ByRef ioBuffer As Any) As Boolean ' CH341BitStreamSPI 處理SPI位數(shù)據(jù)流,4線/5線接口,時鐘線為DCK/D3引腳,輸出數(shù)據(jù)線為DOUT/DOUT2引腳,輸入數(shù)據(jù)線為DIN/DIN2引腳,片選線為D0/D1/D2,速度約8K位*2 ' iIndex, 指定CH341設(shè)備序號 ' iLength, 準備傳輸?shù)臄?shù)據(jù)位數(shù),一次最多896,建議不超過256 ' ioBuffer 指向一個緩沖區(qū),放置準備從DOUT/DOUT2/D2-D0寫出的數(shù)據(jù),返回后是從DIN/DIN2讀入的數(shù)據(jù) '/* SPI時序: DCK/D3引腳為時鐘輸出, 默認為低電平, DOUT/D5和DOUT2/D4引腳在時鐘上升沿之前輸出, DIN/D7和DIN2/D6引腳在時鐘下降沿之后輸入 */ '/* ioBuffer中的一個字節(jié)共8位分別對應(yīng)D7-D0引腳, 位5輸出到DOUT, 位4輸出到DOUT2, 位2-位0輸出到D2-D0, 位7從DIN輸入, 位6從DIN2輸入, 位3數(shù)據(jù)忽略 */ '/* 在調(diào)用該API之前,應(yīng)該先調(diào)用CH341Set_D5_D0設(shè)置CH341的D5-D0引腳的I/O方向,并設(shè)置引腳的默認電平 */


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

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