23 if (write(i2c_dev, ®_data, 2) != 2) {
40 if (write(i2c_dev, &data, 1) != 1) {
45 if (read(i2c_dev, &data, count) != count) {
53 int gyr_init(
int i2c_dev,
float rate,
short int lpf_bw,
char clk_source,
char *act)
82 perror(
"Wrong low pass filter bandwidth value");
87 perror(
"Write in Configuration register A unsuccesful");
91 if( (rate>Fint)||(rate<0) )
93 perror(
"Wrong choice for rate");
96 data=(uint8_t)(Fint/rate - 1);
99 perror(
"Write in configuration register B unsuccesful");
117 perror(
"Wrong clk_source value");
121 if( strcmp(act,
"XYZ")==0 );
122 else if( strcmp(act,
"YZ")==0 )
124 else if( strcmp(act,
"")==0 )
126 else if( strcmp(act,
"Y")==0 )
128 else if( strcmp(act,
"Z")==0 )
130 else if( strcmp(act,
"X")==0 )
132 else if( strcmp(act,
"XY")==0 )
134 else if( strcmp(act,
"XZ")==0 )
137 perror(
"Wrong act value in gyrometer initialization");
142 perror(
"Write in mode register unsuccesful");
155 unsigned short int usgnd[4];
167 result.usgnd[i-1]=result.usgnd[i-1]|((
unsigned short int)data8[i*2+1])|(((
unsigned int)data8[i*2])<<8);
168 data[i-1]=result.sgnd[i-1];
172 result.usgnd[3]=result.usgnd[3]|((
unsigned short int)data8[1])|(((
unsigned int)data8[0])<<8);
173 data[3]=result.sgnd[3];
203 result.usgnd=result.usgnd|(((
unsigned short int)data[1]))|(((
unsigned short int)data[0])<<8);
short int gyr_read_data(int i2c_dev, int type)
READ DATA (X, Y, Z or T)
int gyr_write_reg(int i2c_dev, uint8_t reg, uint8_t data)
WRITE TO REGISTER.
Rev 0 - 06/11/2012 RLEG project - 2012.
uint8_t * gyr_read_reg(int i2c_dev, uint8_t reg, uint8_t count)
READ COUNT 8-BIT REGISTER IN SEQUENCE.
int gyr_init(int i2c_dev, float rate, short int lpf_bw, char clk_source, char *act)
INITIALIZE GYROMETER.
int gyr_read_all_data(int i2c_dev, short int *data)
READ ALL DATA AT ONCE (X, Y, Z and T)