pihwm  r1
A lightweight C library for Raspberry Pi hardware modules.
pi_spi.h
Go to the documentation of this file.
1 
26 #ifndef PI_SPI_H
27 #define PI_SPI_H
28 
29 #include <linux/spi/spidev.h>
30 #include <inttypes.h>
31 
32 // Default config for the SPI module
33 #define SPI_DEFAULT_MODE 0
34 #define SPI_DEFAULT_BPW 8
35 #define SPI_DEFAULT_SPEED 1000000
36 #define SPI_DEFAULT_DELAY 10
37 
38 // Function Prototypes
39 int spi_init (uint8_t channel);
40 int spi_init_name (char *devname);
41 int spi_config (int fd, uint8_t mode, uint8_t bits, uint32_t speed, uint16_t delay);
42 int spi_config_default (int fd);
43 int spi_transfer (int fd, uint8_t txbuf[], uint8_t rxbuf[], uint8_t len);
44 
45 #endif
int spi_config(int fd, uint8_t mode, uint8_t bits, uint32_t speed, uint16_t delay)
Configures the spidev interface.
Definition: pi_spi.c:139
int spi_transfer(int fd, uint8_t txbuf[], uint8_t rxbuf[], uint8_t len)
Initiates SPI transfers.
Definition: pi_spi.c:198
int spi_config_default(int fd)
Configures the spidev interface with default values.
Definition: pi_spi.c:178
int spi_init_name(char *devname)
Initialises the spidev interface for the sysfs entry specified by the devname parameter.
Definition: pi_spi.c:112
int spi_init(uint8_t channel)
Initialises the spidev interface.
Definition: pi_spi.c:52