2017-08-16 46 views
0

嗨,大家好,我是编码新手,我试图通过在raspberryPi3上使用spi通信来监测potantiometer的电压和电阻值。我发现的代码,但是当我尝试运行它,程序给我:“传输SPI数据..ioc”无效的参数

问题发送SPI data..ioc”无效参数

我仔细看了一遍代码,但我不能发现任何错误也许我失去了一些东西。如果你帮我,它会这么好谢谢:)顺便说一句代码是在这里:。

http://www.hertaville.com/interfacing-an-spi-adc-mcp3008-chip-to-the-raspberry-pi-using-c.html

回答

0

你应该尽量充分初始化SPI结构。

......... 
spi[i].speed_hz  = this->speed ; 
spi[i].bits_per_word = this->bitsPerWord ; 
spi[i].cs_change = 0; 

//Ypu should add this lines 
spi[i].pad = 0; 
spi[i].tx_nbits = 0; 
spi[i].rx_nbits = 0; 

它应该帮助:)