Shows how to use SPI interface to transfer a byte 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;
}
uint8_t send_data = 0x23;
printf("Sent to SPI: 0x%02X. Read back from SPI: 0x%02X.\n", send_data, read_data);
if (send_data != read_data)
printf("Do you have the loopback from MOSI to MISO connected?\n");
return 0;
}