Linux SPI API example

Started by Ilh, July 09, 2014, 09:32:59 AM

Previous topic - Next topic

Ilh

Hello,

I am still newbie in linux, so it is a little bit hard for me to figure out what is needed to initialize and use in userspace SPI driver. Could you provide a simple example for A13 SPI initialization/read/write?
Thanks in advance.  :)


Ilh

Hello again,

This topic sure is very useful. However - I encountered a problem - I do everything except:
I use
http://leachy.homeip.net/olinuxino/spi/tst_spi.c
Instead of
https://www.kernel.org/doc/Documentation/spi/spidev_test.c

Because of missing declarations for the modes. Also I don't receive any messages for "cpu tx data time out!"

Everything else is exactly the same as in your post with the difference that there are no real SPI messages outputted on the pins.

Can you help with some ideas what I am doing wrong?

Ilh

Hello,

This may sound as a newbie request, but can somebody tell me how to update the existing SPI driver module -> I want for example to put some debug messages to see what happens down there. Driver is installed with Kernel compilation by selecting SPI enable and SPI for user mode enable in the menuconfig. Will rmmod and insmod work?  :)

oldpenguin

Concerning your previous post, do you mean the definitions for DUAL and QUAD modes ?
Add them by hand. I've found that some linux-headers don't have them defined.
#define SPI_TX_DUAL             0x100
#define SPI_TX_QUAD             0x200
#define SPI_RX_DUAL             0x400
#define SPI_RX_QUAD             0x800


Did you make sure the script.bin is modified to allow SPI pin use ?
How are you testing data on you pins ?

Regards


Ilh

Hello oldpenguin,

Yes - I modified script bin for use of SPI2, removing the cam interface.

I test the pins with oscilloscope.


I will now try to add the definitions.

Best Regards

vinifr

Quote from: Ilh on July 14, 2014, 08:42:45 AM
Hello,

This may sound as a newbie request, but can somebody tell me how to update the existing SPI driver module -> I want for example to put some debug messages to see what happens down there. Driver is installed with Kernel compilation by selecting SPI enable and SPI for user mode enable in the menuconfig. Will rmmod and insmod work?  :)
You can add:
printk(KERN_WARNING ": some message\n");

Ilh

Hello vinifr,

Yes - my aim is to use printk, but my problem is in uninstalling the driver and then building and installing the new version, because it is not loaded as a module, but compiled with the kernel.  :)

vinifr

Quote from: Ilh on July 16, 2014, 08:07:22 AM
Hello vinifr,

Yes - my aim is to use printk, but my problem is in uninstalling the driver and then building and installing the new version, because it is not loaded as a module, but compiled with the kernel.  :)

You have to change the code and recompile the kernel.
http://linux-sunxi.org/Linux_Kernel
https://www.youtube.com/watch?v=ilDhOzmkORY