CH347 提供了4個(gè)讀寫(xiě)函數(shù)CH347SPI_Write(),CH347SPI_Read(),CH347SPI_WriteRead,CH347StreamSPI4但開(kāi)發(fā)手冊(cè)里對(duì)函數(shù)的描寫(xiě)太簡(jiǎn)單了,我的疑問(wèn)
1)spi_read函數(shù) iLength為PULONG型的變量,看起來(lái)像是個(gè)指針。參數(shù)說(shuō)明里的描述是“準(zhǔn)備讀取的數(shù)據(jù)字長(zhǎng)度”那么iLength里面存放的到底是告訴read函數(shù)需要讀取字節(jié)的數(shù)量還是read函數(shù)讀結(jié)束后將讀到的實(shí)際字節(jié)數(shù)量寫(xiě)入到iLength,如果是后一種情況很容易內(nèi)存溢出如何防止?
2)WriteRead()函數(shù)ioBuffer參數(shù)說(shuō)明“ 指向一個(gè)緩沖區(qū),放置準(zhǔn)備從MOSI 寫(xiě)出的數(shù)據(jù),返回后是從MISO 讀入的數(shù)據(jù)”這個(gè)函數(shù)是先寫(xiě)后讀,CH347SPI_Read函數(shù)也是先寫(xiě)后讀且寫(xiě)的長(zhǎng)度都可以指定那么這兩個(gè)函數(shù)的區(qū)別是什么?是read函數(shù)讀取長(zhǎng)度可以自己指定,WriteRead函數(shù)讀取長(zhǎng)度不能指定么?
3)CH347StreamSPI4 也是ioBuffer: 指向一個(gè)緩沖區(qū),放置準(zhǔn)備從MOSI 寫(xiě)出的數(shù)據(jù),返回后是從MISO 讀入的數(shù)據(jù) 那么這個(gè)函數(shù)同WriteRead()有什么區(qū)別呢?
能否解釋下這幾個(gè)函數(shù)的具體區(qū)別?
附:
CH347SPI_Read(
ULONG iIndex,
ULONG iChipSelect,
ULONG oLength,
PULONG iLength,
PVOID ioBuffer);
參數(shù)說(shuō)明
oLength: 準(zhǔn)備發(fā)出的數(shù)據(jù)字節(jié)數(shù)
iLength: 準(zhǔn)備讀取的數(shù)據(jù)字長(zhǎng)度
ioBuffer: 指向一個(gè)緩沖區(qū),放置準(zhǔn)備從MOSI 寫(xiě)出的數(shù)據(jù),返回后是從MISO 讀入的數(shù)據(jù)
CH347SPI_WriteRead( ULONG iIndex,
ULONG iChipSelect,
ULONG iLength,
PVOID ioBuffer );
參數(shù)說(shuō)明
iLength: 準(zhǔn)備傳輸?shù)臄?shù)據(jù)字節(jié)數(shù)
ioBuffer: 指向一個(gè)緩沖區(qū),放置準(zhǔn)備從MOSI 寫(xiě)出的數(shù)據(jù),返回后是從MISO 讀入的數(shù)據(jù)
CH347StreamSPI4(ULONG iIndex,
ULONG iChipSelect,
ULONG iLength,
PVOID ioBuffer );
iLength: 準(zhǔn)備傳輸?shù)淖止?jié)數(shù)
ioBuffer: 指向一個(gè)緩沖區(qū),放置準(zhǔn)備從MOSI 寫(xiě)出的數(shù)據(jù),返回后是從MISO 讀入的數(shù)據(jù)