7 #ifndef LINUX_LIBV2_SOURCE_SPI_LIB_SPI_H_ 8 #define LINUX_LIBV2_SOURCE_SPI_LIB_SPI_H_ 16 #include <linux/spi/spidev.h> 17 #include <sys/ioctl.h> 19 static unsigned int mode = 0x0;
20 static unsigned char bits = 8;
21 static unsigned int speed = 500000;
24 #define SPI_API extern "C" SPI_API int set_spi_mode(int fd, unsigned short mode)
设置SPI模式
SPI_API int set_spi_bits_per_word(int fd, unsigned short bits)
设置SPI通讯时每个字是多少位
SPI_API int set_spi_max_transfer_speed(int fd, unsigned int speed)
设置SPI通讯时最大波特率
SPI_API int spi_message_transfer(int fd, unsigned char *sendBuf, int send_len, unsigned char *recvBuf, int recv_len)
全双工SPI通讯函数,能同时收发
SPI_API int spi_message_send(int fd, unsigned char *sendBuf, int len)
SPI通讯发送函数