34 lines
799 B
C
34 lines
799 B
C
|
#pragma once
|
||
|
|
||
|
#include <fcntl.h> //Needed for SPI port
|
||
|
#include <sys/ioctl.h> //Needed for SPI port
|
||
|
#include <linux/spi/spidev.h> //Needed for SPI port
|
||
|
#include <unistd.h> //Needed for SPI port
|
||
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
#include <string>
|
||
|
#include <iostream>
|
||
|
#include <unistd.h>
|
||
|
#include <cstring>
|
||
|
|
||
|
|
||
|
class SPI
|
||
|
{
|
||
|
public:
|
||
|
SPI(int port);
|
||
|
~SPI();
|
||
|
|
||
|
int SpiOpenPort();
|
||
|
int SpiClosePort();
|
||
|
int SpiWriteAndRead(unsigned char *data, int length);
|
||
|
|
||
|
private:
|
||
|
int spi_device;
|
||
|
int spi_cs_fd;
|
||
|
//int spi_cs0_fd; //file descriptor for the SPI device
|
||
|
//int spi_cs1_fd; //file descriptor for the SPI device
|
||
|
unsigned char spi_mode;
|
||
|
unsigned char spi_bitsPerWord;
|
||
|
unsigned int spi_speed;
|
||
|
};
|