#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;
}
#define LOW
Definition: bcm2835.h:687
@ BCM2835_SPI_BIT_ORDER_MSBFIRST
Definition: bcm2835.h:1138
@ BCM2835_SPI_CS0
Definition: bcm2835.h:1157
@ BCM2835_SPI_MODE0
Definition: bcm2835.h:1146
@ BCM2835_SPI_CLOCK_DIVIDER_65536
Definition: bcm2835.h:1179
int bcm2835_close(void)
Definition: bcm2835.c:2163
int bcm2835_init(void)
Definition: bcm2835.c:2008
void bcm2835_spi_setBitOrder(uint8_t order)
Definition: bcm2835.c:737
void bcm2835_spi_chipSelect(uint8_t cs)
Definition: bcm2835.c:898
uint8_t bcm2835_spi_transfer(uint8_t value)
Definition: bcm2835.c:768
int bcm2835_spi_begin(void)
Definition: bcm2835.c:703
void bcm2835_spi_setDataMode(uint8_t mode)
Definition: bcm2835.c:760
void bcm2835_spi_end(void)
Definition: bcm2835.c:727
void bcm2835_spi_setClockDivider(uint16_t divider)
Definition: bcm2835.c:747
void bcm2835_spi_setChipSelectPolarity(uint8_t cs, uint8_t active)
Definition: bcm2835.c:905