16 #ifndef SPI_FUNCTIONS_H
17 #define SPI_FUNCTIONS_H
25 #include <sys/ioctl.h>
26 #include <linux/types.h>
27 #include <linux/spi/spidev.h>
29 #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
32 #define ENCODER_NO_OP 0x00
33 #define ENCODER_RD_POS 0x10
34 #define ENCODER_SET_ZERO_PT 0x70
35 #define ENCODER_EEPROM_WR 0x80
36 #define ENCODER_EEPROM_RD 0x90
46 int spi_init(uint8_t mode, uint32_t speed, uint8_t cs);
66 int adc_read(
int spi_dev, uint8_t ch, uint8_t sgl,
short int *data);
72 int dac_write(
int spi_dev, uint8_t ch, uint8_t _shdn,
unsigned short int data);
int spi_trans_bytes(int spi_dev, uint8_t *send, uint8_t *receive, int n)
TRANSFER N BYTES.
int spi_init(uint8_t mode, uint32_t speed, uint8_t cs)
spi Functions to deal communication by SPI protocol
int adc_read(int spi_dev, uint8_t ch, uint8_t sgl, short int *data)
READ DATA FROM A/D CONVERTER MCP3208.
void spi_end(int spi_dev)
TERMINATES SPI DEVICE.
int dac_write(int spi_dev, uint8_t ch, uint8_t _shdn, unsigned short int data)
WRITE DATA TO D/A CONVERTER MCP3922.