pihwm  r1
A lightweight C library for Raspberry Pi hardware modules.
 All Data Structures Files Functions Modules Pages
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_config (int fd, uint8_t mode, uint8_t bits, uint32_t speed, uint16_t delay);
41 int spi_config_default (int fd);
42 int spi_transfer (int fd, uint8_t txbuf[], uint8_t rxbuf[], uint8_t len);
43 
44 #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:116
int spi_transfer(int fd, uint8_t txbuf[], uint8_t rxbuf[], uint8_t len)
Initiates SPI transfers.
Definition: pi_spi.c:175
int spi_config_default(int fd)
Configures the spidev interface with default values.
Definition: pi_spi.c:155
int spi_init(uint8_t channel)
Initialises the spidev interface.
Definition: pi_spi.c:53