Quantcast

SPI reading and writing to register

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

SPI reading and writing to register

Joulethief
This post has NOT been accepted by the mailing list yet.
Hello, I was thrown on a project with the Gumstix and an accelerometer to connect to. However, I haven't dealt with SPI or writing drivers before. So my question is, how do I manually read/write to an SPI register (slave)? I already have the 4-wire SPI connection setup, I just can't figure out how to access to MOSI/MISO pins.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SPI reading and writing to register

bhamadicharef
What accelerometer are you using ? Search if a driver is available,
and modify one for your specific accelerometer, they all have more
or less the same registers ...
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SPI reading and writing to register

Scott Ellis
In reply to this post by Joulethief
I'd probably start with spidev first. It's a generic spi driver built
into the stock Gumstix kernels. You can google it.

Gumstix brings out two CS pins for SPI Bus 1, but both are taken by
display drivers in the default kernels. Only one driver can claim a
SPI Bus CS line at a time. CS0 is taken by the 4.3" display driver and
CS1 is taken by the 3.5" display driver.

You'll need to disable one or both of those display drivers if you
want to use those CS pins.

This entails modifying the kernel config file (defconfig) and
rebuilding it.

Make the following change to give spidev access to CS0

CONFIG_TOUCHSCREEN_ADS7846=m
to
# CONFIG_TOUCHSCREEN_ADS7846 is not set

Make the following change to give spidev access to CS1

CONFIG_PANEL_LGPHILIPS_LB035Q02=y
to
# CONFIG_PANEL_LGPHILIPS_LB035Q02 is not set

In the end spidev might not be fast enough for you depending
on how often you want to sample the accelerometer. But it's
an easy way to checkout your hardware and basic communication.

I'm working on some Overo SPI stuff today as well if you want
to ask some more specific question.

You can contact me off list.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SPI reading and writing to register

carveone
On Thu, Apr 17, 2014 at 2:14 PM, Scott Ellis <[hidden email]> wrote:
> I'd probably start with spidev first. It's a generic spi driver built
> into the stock Gumstix kernels. You can google it.

I'd second that. I built my own framebuffer driver for an SPI display
but step 1 was with spidev. It's easy to use but requires that the
Gumstix pins be set correctly. Which board and gumstix platform are
you using? I've good experience with the Duovero and Parlor board;
Scott has much more on the Overo and a website to boot!

You can contact me off list if you need patches or code. You may need
to change u-boot or the kernel board file and, while the changes are
easy enough, knowing what to do can be a bit daunting at first. The
wiki (http://wiki.gumstix.org/index.php?title=Category:SPI) might be a
bit high level to begin with; maybe I'll change that...

Conor.

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
gumstix-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gumstix-users
Loading...