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 spidev.
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 this:
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.
Thanks!