Spidev guidance

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Hi All,

I'm trying to write a SPI driver for the AD7793 analog to digital
converter.  Actually, I've written a driver using EMAC's SPI class but
since I've encountered some strange problems I've decided to use

I was able to successfully create spidev1.1 in my /dev dir.  Now I've
written code to try and talk to my AD7793.  The question I have is

In order to reset the A/D I have to write 32 consecutive one's to the
device while mosi is high.  In other words, 32 SCLK pulses need to be
initiated in order to reset the device.

I'm confused on how to do this in the code.  I'm using the
spidev_fdx.c code as a template.  Is it valid to simply do this:

uint8_t tx = 0xFFFFFFFF;

and then:

struct spi_ioc_transfer tr = {
        .tx_buf = (unsigned long)tx,
        .rx_buf = (unsigned long)rx,
        .len = ARRAY_SIZE(tx),
        .delay_usecs = delay,
        .speed_hz = speed,
        .bits_per_word = bits,

ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);

A code snippet of how this would be done would be a tremendous help.


Re: Spidev guidance
You'd probably want to send
uint8_t tx[4] 3D% {0xFF, 0xFF, 0xFF, 0xFF}
struct spi_ioc_transfer tr 3D% {
                .tx_buf 3D% tx,
                .rx_buf 3D% rx,
                .len 3D% ARRAY_SIZE(tx),
                .delay_usecs 3D% delay,
                .speed_hz 3D% speed,
                .bits_per_word 3D% bits,

Quoted text here. Click to load it

Re: Spidev guidance
Quoted text here. Click to load it

also put delay3D%500us


Re: Spidev guidance
Quoted text here. Click to load it

Thanks, guys!  I'll give that a try and see how it goes.
Any thoughts on what SPI mode should be used?

Upon looking at the AD7793 documentation I believe SPI_MODE_3 is what
I need to pass in.

Site Timeline