Power & Source of Big Ideas

SPI read and write

Moderators: chensy, FATechsupport

We used spi on a banana pi to interface with a sensor module. I used spidev there, and needed to load spi-sun7i.ko module. Everything worked there. See spidev examples for banana pi.

I want to switch to nanopi neo air and port the application that interfaces with spi. I had difficulties. First, I did not find spi-sun7i.ko in the kernel, although I can see /dev/spidev0.0 . I installed WiringNP on my nanopi neo air board, and looked at some examples there. One example requires you run "gpio load spi", and that returns "can't find spi-sun7i.." . I compiled some simple spi test code following the examples and run without spi-sun7i, and failed to get correct result.

Please help and let me know how I can communicate with nanopi spi. Greatly appreciated.
Some additional information.

I am using Ubuntu core 3.4.xx coming with the nanapi neo air unit. It has /dev/spidev0.0. That means spi driver is in the kernel.

I wonder if the driver works properly? Has anyone verified it?

Here is my finding:

I have a simple spi test program I used to communicate with a spi slave. The slave is using mode 0, so I set the master mode to 0 and and speed to 1mbps. The test program works when running it on a banana pi unit communicating with the slave. But on the nanapi neo air, the data master reads from the slave has one bit off, meaning, 0x3 become 0x6, 0x1 becomes 0x2, etc. Digital scope shows the 4 lines are in expected format. It appeared the phase handling, that is sampling of data on which edge could be wrong. Can someone shed light to the issue? Thanks a lot.
Hey
Yep i can confirm it works. I have tested it on
    Nano Pi Neo Air
    Nano Pi Duo
    Nano Pi Neo Plus 2
Have a look at my Neopixel library https://github.com/leonyuhanov/SK6812viaSPI Look inside the "Nano Pi Neo Air" directory for a C++ example of how to use SPIDEV
I have tested it to 20mhz, it probably goes faster But i have never needed it.
Leon
Thx. Yes. Spi on nanopi works. Somehow the spi slave I was using had a little problem.
Does anybody tried to change SPI mode (exactly SPI_CPOL (Clock polarity) and SPI_CPHA (Clock phase) ) ? All my attemps were unsuccessfull :(
I tried both WiringNP (mode 0, 3) and native spidev_test.c (written by Anton Vorontsov) (with flags -HO and without them) - I've got same results on my logic analizator.

Device - NanoPi NEO2, Ubuntu 16.04.3 LTS xenial

Who is online

In total there are 9 users online :: 0 registered, 0 hidden and 9 guests (based on users active over the past 5 minutes)
Most users ever online was 2865 on Sun Nov 10, 2019 5:27 am

Users browsing this forum: No registered users and 9 guests