SPI for sensor

mouha 2010-03-06 00:27:21 Link
Hi all,

Did not found out SPI code that can drive accelerometer from Linux, who
knows where to get one ?

thx

mouha 2010-03-06 00:29:22 Link
My question was not correct enough :
 I meant driving "something" with some SPI code.

gene.sally 2010-03-06 06:30:35 Link
Check out the Documentation/spi directory, there's good documentation in
there and some sample code.

Regards,
gene

mouha 2010-03-06 09:07:18 Link
thanks for your reply.
The spi code I was talking about is not the off. doc, but
about driving spi from Linux

mouha 2010-03-07 19:32:39 Link
Does anybody have SPI code >from< Linux ?

bartman 2010-03-08 12:14:18 Link
in the "firmware_bsp" dir, did you read the SPI.C file that 
begin with :


/*============================================================

  File Name: SPI.c
  Description: S3C2440A SPI controller Function Test
     Version: 0.1 

     History:
      0.1: 2003. 07. 06, Programming Start.
      0.2: 2004. 05. 14, added keyboard test codes 
                       
=============================================================*/

#include <string.h>
#include "2440addr.h"
#include "2440lib.h"
#include "spi.h"
#include "def.h"

#define spi_count 0x80
#define SPI_BUFFER _NONCACHE_STARTADDRESS

void __irq Spi_Int(void);
void __irq Dma1Tx_Int(void);
void __irq Dma1Rx_Int(void);

void Test_Spi1_MS_poll(void); // added by junon

volatile char *spiTxStr,*spiRxStr;
volatile int endSpiTx;
volatile int tx_dma1Done;
volatile int rx_dma1Done;
unsigned int spi_rGPECON,spi_rGPEDAT,spi_rGPEUP;
unsigned int spi_rGPGCON,spi_rGPGDAT,spi_rGPGUP;
unsigned int spi_rGPDCON,spi_rGPDDAT,spi_rGPDUP;

...etc

it should be the good one for you

mouga 2010-03-08 14:38:51 Link
Yes, you are right.
These are SPI tests I want to drive an external sensor (the accelerometer I
was talking, like those you have in Wii remote or Iphone) i.e. : receive
data from it, but not sure that Linux let me run a program that use
directly the I/Os .

Do you know if Linux let drive directly the SPi I/O directly from commande
line program ?

mouha 2010-03-16 16:07:05 Link
no anwsers, no one knows how to drive SPI ?

open-nandra 2010-09-08 10:14:18 Link
Working on getting some accelerometer working with SPI in linux. I'll post
a patch when will be finished. Stay tuned.

open-nandra 2010-09-08 11:46:07 Link
Attachment: patch (2.88 KB)
mouha: well this patch you can apply for mini2440 kernel from repo.or.cz.
It add to spi.0 driver for sca3000 accelerometer. If you need different
device just update board info structure. If you have any question just
lemme know at marek.belisko at gmail.com.

srikanth 2010-09-10 08:25:30 Link
hi open-nandra,
               does the patch also cover for gpio, if not can you also post
the code for gpios as well and can you give us the procedure to make the
patch.

thanks in advance,
sri.

Sergey Manucharian 2010-10-25 18:59:02 Link
Hi folks!

I gonna use SPI to communicate with several sensors/ADC/DAC. The SPI host
driver works in 2.6.32.2, and  I also have added support for the second
one, so I have spidev0.0 and spidev1.0 in /dev.

The questions arisen:

1) The driver support only 8 bit per word. Is it a hardware limitation?

2) When trying to send data (a few chars) using file writes or system calls
I get the following diagram on data/clock pins:
   __      __   __     __     __     __
__/  \____/  \_/  \___/  \___/  \___/  \___
  \__/    \__/ \__/   \__/   \__/   \__/

The "gap" between the 1st and 2nd bytes is longer and the "gap" between the
2nd and 3rd bytes is shorter than all others, which are equidistant. Also
the chip select signal is much longer than needed in case of 1-3 bytes
sent.

All the above might interfere time critical applications.

Any thoughts?
TIA

davef 2010-10-25 20:47:30 Link
My understanding is that Linux is not a real-time operating system, so use
in time critical applications MAY not be appropriate.  Search <hard real
time> and <real time Linux>.

Now, whether this is the problem is another question.

If you have other stuff going on at the same time, does SPI get priority
over those "other things"?  Is the SPI being interrupted by a higher level
task?

Can you turn off interrupts while you send all your data out?

HTH

Dave

Sergey Manucharian 2010-10-25 21:54:15 Link
I haven't researched much in that direction, but tried to set the priority
of my data sending program (by nice) to very high level, the pattern is
exactly the same all the time.

Of course, you're right about the Linux not being RTOS, but in my
particular case I wouldn't worry if I was able to send 32 bits per word. I
can't find any info regarding such a (hardware) capability.

Reply

Name
eMail (not visible)
Subject (no text only in upper case; no HELP, URGENT...)
Text
HTML tags are not supported and links are generated automatically if they start with http or ftp.
Please submit long source code or log files as attachment (only registered users).
Please enter the number 5274