Shows how to use SPI interface to transfer a number of bytes to and from an SPI device
#include <bcm2835.h>
#include <stdio.h>
int main(int argc, char **argv)
{
{
printf("bcm2835_init failed. Are you running as root??\n");
return 1;
}
{
printf("bcm2835_spi_begin failed. Are you running as root??\n");
return 1;
}
char buf[] = { 0x01, 0x02, 0x11, 0x33 };
printf("Read from SPI: %02X %02X %02X %02X \n", buf[0], buf[1], buf[2], buf[3]);
return 0;
}