PINE64
SPI python ? - Printable Version

+- PINE64 (https://forum.pine64.org)
+-- Forum: PINE A64(+) (https://forum.pine64.org/forumdisplay.php?fid=4)
+--- Forum: Linux on Pine A64(+) (https://forum.pine64.org/forumdisplay.php?fid=6)
+---- Forum: Debian (https://forum.pine64.org/forumdisplay.php?fid=24)
+---- Thread: SPI python ? (/showthread.php?tid=3042)



SPI python ? - herialtifa - 01-06-2017

Hello,

How i can access SPI pin (pi2bus or euler) with python spidev?

i look in the raspberry, the SPI port must be enable before using through raspi-config. How about pine64?
Thank's Smile


RE: SPI python ? - martinayotte - 01-06-2017

Use this Python library : https://github.com/swkim01/RPi.GPIO-PineA64

Here some loopback testing code :


Code:
#!/usr/bin/python
import RPi.SPI as spi
data = [0xDE,0xAD,0xBE,0xEF,0xBA,0xAD,0xF0,0x0D]
spi.open("/dev/spidev0.0")
spi.write(data)
data = spi.xfer(data, len(data))
spi.close()
print data



RE: SPI python ? - herialtifa - 01-06-2017

(01-06-2017, 09:15 AM)martinayotte Wrote: Use this Python library : https://github.com/swkim01/RPi.GPIO-PineA64

Here some loopback testing code :


Code:
#!/usr/bin/python
import RPi.SPI as spi
data = [0xDE,0xAD,0xBE,0xEF,0xBA,0xAD,0xF0,0x0D]
spi.open("/dev/spidev0.0")
spi.write(data)
data = spi.xfer(data, len(data))
spi.close()
print data
Thanks Martinayotte,

What the spi.xfer?

I look 2 pins SPI (pi2bus and euler),
which the pin i can call /dev/spidev0.0 and /dev/spidev0.1?

On raspi tutorial, we can look spidev0.0 in /dev but in pine not found.

Sent from my Mi-4c using Tapatalk


RE: SPI python ? - martinayotte - 01-08-2017

spi.xfer() is transmitting and receiving at the same time, full-duplex transfer.

If you don't see /dev/spi0.0 on your board, it is probably that you don't use an image using longsleep's kernel, because SPIs have been added in the DT of longsleep several months ago.


RE: SPI python ? - martinayotte - 01-09-2017

I feel that this image is pretty old. Which version is show when doing "uname -a"
If you don't mind switch to Ubuntu, here is on image built in December :
http://files.pine64.org/os/ubuntu/xubuntu-xenial-mate-20161215-longsleep-pine64-8GB.img.gz
or even better, one from Armbian :
https://img.armbian.com/pine64/Ubuntu_xenial_default_desktop.7z


RE: SPI python ? - herialtifa - 01-13-2017

Thanks Martinayotte,, i will try it

Sent from my Mi-4c using Tapatalk


RE: SPI python ? - herialtifa - 01-16-2017

Martinayotte, i was tried armbian..
But SPI port not appear in /dev/

what the configuration for appear spidev0.0/spidev0.1?


RE: SPI python ? - xalius - 01-17-2017

Mmmh I was looking at...

https://github.com/longsleep/build-pine64-image/blob/master/blobs/pine64.dts#L1849
https://github.com/longsleep/build-pine64-image/blob/master/blobs/pine64.dts#L1865

Maybe the SPI blocks are disabled by default to have the pins as GPIO?


RE: SPI python ? - herialtifa - 01-17-2017

(01-17-2017, 03:40 PM)xalius Wrote: Mmmh I was looking at...

https://github.com/longsleep/build-pine64-image/blob/master/blobs/pine64.dts#L1849
https://github.com/longsleep/build-pine64-image/blob/master/blobs/pine64.dts#L1865

Maybe the SPI blocks are disabled by default to have the pins as GPIO?
Can i enabling, how?

Sent from my Mi-4c using Tapatalk