Accessing BBB SPI with C/C++

Hello everyone,

i have enabled SPI1, but now the question is: How can I send/receive data throught it, using a C/C++ program?
I have found many examples for python, but none for C/C++, althought I read, that the Python module is written in C itself.

This lib, for example: is
the top level file for an example app using the SPI class.


Thanks Jacek,
this looks, as if it is exactly what I wanted.

Hi Rafael and jacek,

Will you both please explain me the procedure how you both have used SPI API. i am newbie to BBB so i won’t able to understand how can i implement SPI on BBB.

Please reply me as soon as possible.

Thanks and regards

What kernel version are using? Have you load the overlay ‘BB-SPIDEV0’ to the cape manager? You should see something like /dev/spidev*.* after the SPI is enable.
If you are using kernel version larger than 4.4, then you just configure the pin to spi mode using ‘sudo config-pin PIN_NUMBER spi’, for do, di, cs and sclk.

For a lower kernel version, just load the related overlay under /lib/firmware/

在 2017年5月5日星期五 UTC+2下午2:54:16,rohit…@gmail.com写道:

I use 4.9 kernel. The spidev loopback test failed even after setting the config-pin