Rleg  2
 All Data Structures Files Functions Variables Typedefs Macros Groups Pages
encoder_functions.h
Go to the documentation of this file.
1 
11 #ifndef ENCODER_FUNCTIONS_H
12 #define ENCODER_FUNCTIONS_H
13 
14 #include <stdio.h>
15 #include <stdint.h>
16 #include <stdlib.h>
17 #include <string.h>
18 #include <errno.h>
19 #include <unistd.h>
20 #include <sys/types.h>
21 #include <sys/stat.h>
22 #include <sys/ioctl.h>
23 #include <fcntl.h>
24 //#include <linux/i2c-dev.h>
25 
26 #define SUCCESS 1
27 #define FAILURE -1
28 
29 /* Commands */
30 #define ENCODER_NO_OP 0x00
31 #define ENCODER_RD_POS 0x10
32 #define ENCODER_SET_ZERO_PT 0x70
33 #define ENCODER_EEPROM_WR 0x80
34 #define ENCODER_EEPROM_RD 0x90
35 
36 /* Responses */
37 #define ENCODER_WAIT_RESP 0xA5
38 
39 #define INT_MAX 5
40 
45 typedef struct enconder_data{
46  int spi_dev;
47  unsigned short int position;
48  struct calibrate{
49  unsigned short int position;
50  }calib;
51  int new_data;
53 
54 /*
55  * @brief INITIALIZE ENCODER
56  * @ingroup enc
57  * @param spi Communication Port
58  * @param[in] status Register
59  * @param[in] data Data to write
60 
61  * @return flag with SUCCESS or FAILURE
62  */
63 
64 //int encoder_init(int spi,);
65 
66 
74 int enc_read_pos(int spi_dev,unsigned short int *data);
75 
76 
85 int enc_zero_set(int spi_dev);
86 
87 
95 int enc_wait_for_ack(int spi_dev, uint8_t ack, int max_errors);
96 
97 
98 #endif
99 
int enc_wait_for_ack(int spi_dev, uint8_t ack, int max_errors)
send command and delay between reads
int enc_zero_set(int spi_dev)
SET ZERO POINT.
unsigned short int position
unsigned short int position
int enc_read_pos(int spi_dev, unsigned short int *data)
READ POSITION.