16 if( (imu_param->
i2c_dev = open(
"/dev/i2c-3", O_RDWR))<0 )
18 perror(
"Failed to open i2c_dev");
23 perror(
"ioctl(I2C_SLAVE) mag");
29 perror(
"Error in magnetometer initialization");
34 perror(
"ioctl(I2C_SLAVE) gyr");
40 perror(
"Error in gyrometer initialization");
45 perror(
"ioctl(I2C_SLAVE) acc");
51 perror(
"Error in accelerometer initialization");
59 perror(
"Error in SPI device initialization");
70 perror(
"Error in MRA initialization");
110 imu_data->
acc.
x=data[0];
111 imu_data->
acc.
y=data[1];
112 imu_data->
acc.
z=data[2];
120 imu_data->
gyr.
x=data[0];
121 imu_data->
gyr.
y=data[1];
122 imu_data->
gyr.
z=data[2];
123 imu_data->
temp=data[3];
131 imu_data->
mag.
x=data[0];
132 imu_data->
mag.
y=data[1];
133 imu_data->
mag.
z=data[2];
144 else eff_data->
F.
x=data[0];
int dac_write(int spi_dev, uint8_t ch, uint8_t _shdn, unsigned short int data)
WRITE DATA TO D/A CONVERTER MCP3922.
struct IMU_PARAM_STRUCT::param_mag mag
void actuate(int spi_dev, MRA_DATA_STRUCT *mra_data)
Applies the control signal to the actuator.
SPI_PARAM_STRUCT spi_param
int spi_init(uint8_t mode, uint32_t speed, uint8_t cs)
spi Functions to deal communication by SPI protocol
IMU_PARAM_STRUCT imu_param
int adc_read(int spi_dev, uint8_t ch, uint8_t sgl, short int *data)
READ DATA FROM A/D CONVERTER MCP3208.
DATA_XYZ mag
Magnetormeter Vector.
struct IMU_PARAM_STRUCT::param_gyr gyr
struct IMU_PARAM_STRUCT::param_acc acc
int gpio_write(uint8_t gpio, uint8_t value)
int acc_read_all_data(int i2c_dev, short int *data)
READ ALL DATA AT ONCE (X, Y and Z)
int gpio_read(uint8_t gpio)
short int v_ctl_read
Voltage level read from the actuator.
DATA_XYZ acc
Accel Vector.
struct ENC_DATA_STRUCT::calibrate calib
int devices_init(IMU_PARAM_STRUCT *imu_param, SPI_PARAM_STRUCT *spi_param, MRA_DATA_STRUCT *mra_data)
INITIALIZATION OF SENSORS AND DEVICES.
unsigned short int position
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.
unsigned short int position
int enc_read_pos(int spi_dev, unsigned short int *data)
READ POSITION.
int mag_init(int i2c_dev, uint8_t rate, uint8_t range, uint8_t samples_avg, uint8_t meas_mode, uint8_t op_mode)
INITIALIZE MAGNETOMETER.
int gyr_init(int i2c_dev, float rate, short int lpf_bw, char clk_source, char *act)
INITIALIZE GYROMETER.
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.
DATA_XYZ gyr
Gyrometer Vector.
int gyr_read_all_data(int i2c_dev, short int *data)
READ ALL DATA AT ONCE (X, Y, Z and T)
int mag_read_all_data(int i2c_dev, short int *data)
READ ALL DATA AT ONCE (X, Y and Z)
short int v_ctl
Voltage level for control output.
int acc_init(int i2c_dev, uint8_t full_res, uint16_t rate, uint8_t range)
Rev 0 - 11/11/2012 RLEG project - 2012.