programming SPI with C on BBB

Hi,

I need to interface a DAC with SPI interface http://ww1.microchip.com/downloads/en/DeviceDoc/21697F.pdf to BBB.
First question is which one (SPI) to select from device tree overlays (as there is a few and I don’t know the differences between them)
root@beaglebone:~# cd /lib/firmware
root@beaglebone:/lib/firmware# ls SPI
ADAFRUIT-SPI0-00A0.dtbo BB-SPIDEV0-00A0.dtbo BB-SPIDEV1A1-00A0.dtbo
ADAFRUIT-SPI1-00A0.dtbo BB-SPIDEV1-00A0.dtbo

I started with spidev0 and have
root@beaglebone:~# ls /dev/spi
/dev/spidev1.0 /dev/spidev1.1
Is this one conflicting with HDMI?

When I try in my C program:

// for serial
//const char *portname = “/dev/ttyO1”;
const char *portname = “/dev/ttyUSB0”;
const char *spiname = “/dev/spidev1.0”;
char sbuf[40];
int fd, SPIhandle;

// for spidev1.0
SPIhandle = open (spiname, O_RDWR | O_NOCTTY | O_SYNC);
if (SPIhandle < 0)
{
printf(“Error while opening SPI port …\n”); // Just if you want user interface error control
} else
printf(“using %s\n”, spiname);
// end of for spidev1.0

After compiling I have:
“error: ‘spidev’ does not name a type”

This should be included in a C project, so I can not use Python.
Can someone point me into the right directions, please

Jan

Found an example here http://stackoverflow.com/questions/23691084/reading-sensor-with-spi and it started to work with default settings.
Where is the docs for ioctl(spiDev, SPI_IOC_MESSAGE(1), &xfer); and xfer.speed_hz = ???
I need to use a slower clock SCLK.

Good example code: https://www.kernel.org/doc/Documentation/spi/spidev_fdx.c
It works on BBB without any changes.
Manual for linux spidev: https://www.kernel.org/doc/Documentation/spi/spidev

Thanks Artem,

Will try it later, as I’m away now.
Is the spidev1.1 the same port with a different CS (as I need 2 SPI interfaces). If yes, what pin is the second CS on?

Thanks again,
Jan