#include <stdint.h>#include <unistd.h>#include <stdio.h>#include <stdlib.h>#include <getopt.h>#include <fcntl.h>#include <sys/ioctl.h>#include <linux/types.h>#include <linux/spi/spidev.h>

Go to the source code of this file.
Macros | |
| #define | ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) |
| #define | ENCODER_NO_OP 0x00 |
| #define | ENCODER_RD_POS 0x10 |
| #define | ENCODER_SET_ZERO_PT 0x70 |
| #define | ENCODER_EEPROM_WR 0x80 |
| #define | ENCODER_EEPROM_RD 0x90 |
Functions | |
| int | spi_init (uint8_t mode, uint32_t speed, uint8_t cs) |
| spi Functions to deal communication by SPI protocol More... | |
| void | spi_end (int spi_dev) |
| TERMINATES SPI DEVICE. More... | |
| int | adc_read (int spi_dev, uint8_t ch, uint8_t sgl, short int *data) |
| READ DATA FROM A/D CONVERTER MCP3208. More... | |
| int | dac_write (int spi_dev, uint8_t ch, uint8_t _shdn, unsigned short int data) |
| WRITE DATA TO D/A CONVERTER MCP3922. More... | |
| int | spi_trans_bytes (int spi_dev, uint8_t *send, uint8_t *receive, int n) |
| TRANSFER N BYTES. More... | |
| #define ARRAY_SIZE | ( | a | ) | (sizeof(a) / sizeof((a)[0])) |
Definition at line 29 of file spi_functions.h.
Referenced by adc_read(), dac_write(), enc_read_pos(), and spi_trans_bytes().
| #define ENCODER_EEPROM_RD 0x90 |
Definition at line 36 of file spi_functions.h.
| #define ENCODER_EEPROM_WR 0x80 |
Definition at line 35 of file spi_functions.h.
| #define ENCODER_NO_OP 0x00 |
Definition at line 32 of file spi_functions.h.
| #define ENCODER_RD_POS 0x10 |
Definition at line 33 of file spi_functions.h.
| #define ENCODER_SET_ZERO_PT 0x70 |
Definition at line 34 of file spi_functions.h.
| int adc_read | ( | int | spi_dev, |
| uint8_t | ch, | ||
| uint8_t | sgl, | ||
| short int * | data | ||
| ) |
READ DATA FROM A/D CONVERTER MCP3208.
| ch | Set Channel (0 .. 7) |
| sgl | (0: to single or 1: to pseudo-differencial) |
Definition at line 172 of file spi_functions.c.
References ARRAY_SIZE, delay, FAILURE, and SUCCESS.
Referenced by read_all_data().

| int dac_write | ( | int | spi_dev, |
| uint8_t | ch, | ||
| uint8_t | _shdn, | ||
| unsigned short int | data | ||
| ) |
WRITE DATA TO D/A CONVERTER MCP3922.
Definition at line 200 of file spi_functions.c.
References ARRAY_SIZE, delay, FAILURE, and SUCCESS.
Referenced by actuate().

| void spi_end | ( | int | spi_dev | ) |
TERMINATES SPI DEVICE.
Definition at line 166 of file spi_functions.c.
| int spi_init | ( | uint8_t | mode, |
| uint32_t | speed, | ||
| uint8_t | cs | ||
| ) |
spi Functions to deal communication by SPI protocol
INITIALIZE SPI DEVICE
Definition at line 100 of file spi_functions.c.
References bits, and pabort().
Referenced by devices_init().


| int spi_trans_bytes | ( | int | spi_dev, |
| uint8_t * | send, | ||
| uint8_t * | receive, | ||
| int | n | ||
| ) |
TRANSFER N BYTES.
Fix this to show all data
Definition at line 228 of file spi_functions.c.
References ARRAY_SIZE, delay, FAILURE, and SUCCESS.
Referenced by enc_read_pos(), enc_wait_for_ack(), and enc_zero_set().

1.8.6