Rleg  2
 All Data Structures Files Functions Variables Typedefs Macros Groups Pages
communication.h
Go to the documentation of this file.
1 
7 #ifndef COMMUNICATION_H
8 #define COMMUNICATION_H
9 
10 #include "imu_functions.h"
11 #include "spi_functions.h"
12 #include "gpio_functions.h"
13 #include "encoder_functions.h"
14 #include "imu_regs.h"
15 
16 #define GPIO_CS_S0 168 // GPIOs that select CS in Demux
17 #define GPIO_CS_S1 64
18 #define GPIO_CS_S2 176
19 #define GPIO_CS_S3 65
20 
21 #define GPIO_DAC_SHDN 66 // GPIO that deals with DAC power
22 #define GPIO_DAC_LDAC 67
23 
24 #define USE_ENCODER 1
25 #define USE_IMU 1
26 #define USE_SPI 1
27 
31 typedef struct imu_param{
35  struct param_acc{
36  uint8_t full_res;
37  uint16_t rate;
38  uint8_t range;
39  }acc;
43  struct param_gyr {
44  float rate;
45  short int lpf_bw;
46  char clk_source;
47  char *act;
48  }gyr;
52  struct param_mag {
53  uint8_t rate;
54  uint8_t range;
55  uint8_t samples_avg;
56  uint8_t meas_mode;
57  uint8_t op_mode;
58  }mag;
59  int i2c_dev;
61 
65 typedef struct spi_param{
66  uint8_t mode;
67  uint32_t speed;
68  uint8_t cs;
69  int spi_dev;
71 
75 typedef struct dataxyz{
76  short int x;
77  short int y;
78  short int z;
79 }DATA_XYZ;
80 
84 typedef struct dataxyzdouble{
85  double x;
86  double y;
87  double z;
89 
93 typedef struct imu_data{
97  struct calibrated{
101  }calib;
102  short int temp;
103  double calib_temp;
104  uint8_t new_data;
106 /*
107 typedef struct ang_data{
108  short int knee;
109  //...
110 }ANG_DATA_STRUCT;
111 */
112 typedef struct eff_data{
115  uint8_t new_data;
117 /*
118 typedef struct dac_data{
119  short int Out_0;
120  short int Out_1;
121  short int Read_0;
122  short int Read_1;
123  int success;
124 }DAC_DATA_STRUCT;
125 */
129 typedef struct mra_data{
130  short int v_ctl;
131  short int v_ctl_read;
132  int new_data;
133  int new_ctl;
135 
144 
155 
166 
173  void actuate(int spi_dev, MRA_DATA_STRUCT *mra_data);
174 
179  void mra_shut_down(void);
180 #endif
MRA_DATA_STRUCT mra_data
Definition: main.c:32
Gyrometer Parameters.
Definition: communication.h:43
Configs for SPI.
Definition: communication.h:65
int read_all_data(int i2c_dev, int spi_dev, IMU_DATA_STRUCT *imu_data, EFF_DATA_STRUCT *eff_data, MRA_DATA_STRUCT *mra_data, ENC_DATA_STRUCT *enc_data)
READ ALL DATA FROM SENSORS AND ADC.
Definition: communication.c:94
Magnetometer Parameters.
Definition: communication.h:52
ENC_DATA_STRUCT enc_data
Definition: main.c:31
Struct to control MRA.
Data of IMU structure.
Definition: communication.h:93
short int y
Definition: communication.h:77
SPI_PARAM_STRUCT spi_param
Definition: main.c:26
IMU_PARAM_STRUCT imu_param
Definition: main.c:25
IMU_DATA_STRUCT imu_data
Definition: main.c:30
DATA_XYZ mag
Magnetormeter Vector.
Definition: communication.h:96
Rev 0 - 06/11/2012 RLEG project - 2012.
int devices_close(IMU_PARAM_STRUCT *imu_param, SPI_PARAM_STRUCT *spi_param, MRA_DATA_STRUCT *mra_data)
Fuction to close all communication with the sensors and devices.
Definition: communication.c:82
void mra_shut_down(void)
Turn off MRA.
void actuate(int spi_dev, MRA_DATA_STRUCT *mra_data)
Applies the control signal to the actuator.
A structure to represent a 3d Vector.
Definition: communication.h:75
short int v_ctl_read
Voltage level read from the actuator.
DATA_XYZ acc
Accel Vector.
Definition: communication.h:94
Rev 0 - 18/06/2013 RLEG project - 2013.
short int z
Definition: communication.h:78
Vector definition on double.
Definition: communication.h:84
Configs of IMU.
Definition: communication.h:31
DATA_XYZ gyr
Gyrometer Vector.
Definition: communication.h:95
Registers that are present in each device from the IMU (ADXL345, ITG3200 and HMC5883) ...
int devices_init(IMU_PARAM_STRUCT *imu_param, SPI_PARAM_STRUCT *spi_param, MRA_DATA_STRUCT *mra_data)
INITIALIZATION OF SENSORS AND DEVICES.
Definition: communication.c:12
EFF_DATA_STRUCT eff_data
Definition: main.c:29
short int x
Definition: communication.h:76
short int v_ctl
Voltage level for control output.
Accelerometer Parameters.
Definition: communication.h:35