I've been searching google and stackexchange for quite a while: I would like to access an ADC (MCP3201) via SPI, to do so, I have to use Python and would like to use WiringPi. Sadly it seems impossible to find any documentation on the wiringPi python bindings.
In C, the functions look as follows:
int wiringPiSPISetup (int channel, int speed); //returning filedescriptor
int wiringPiSPIDataRW (int channel, unsigned char *data, int len);
They seem to exist (checked with ipython -> 'import wiringpi' -> 'wiringpi.' -> tab pressed twice) as python bindings.
Has anyone ever used the wiringPi SPI functions with python?
If so, please explain to me how to do it or point me into the right direction.
System is: Raspberry Pi 2 running raspbian jessie
Any help is appreciated,
P.S.: So far I tried the following code, executing it returns an error that it only accepts exactly 2 parameters.
import wiringpi wiringpi.wiringPiSetupGpio() SPIchan = 1 SPIspeed = 800000 wiringpi.wiringPiSPISetup (SPIchan, SPIspeed) data = 0xAA numberOfBytes = 2 wiringpi.wiringPiSPIDataRW(SPIchan, data, numberOfBytes) print "Returned data: " + data
P.P.S: Found the wrapper for the C function: In Python, the wiringPiSPIDataRW() receives the channel and data to send as arguments, and returns the received data. However, using this function with 2 arguments just aborts the python script. Does anyone have any ideas how to get this function to work?