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 mag_init(
int i2c_dev, uint8_t rate, uint8_t range, uint8_t samples_avg, uint8_t meas_mode, uint8_t op_mode)
80 perror(
"Wrong rate value");
97 perror(
"Wrong samples_avg value");
104 perror(
"Write in Configuration register A unsuccesful");
109 perror(
"Write in configuration register B unsuccesful");
114 perror(
"Write in mode register unsuccesful");
127 unsigned short int usgnd[3];
141 result.usgnd[j]=result.usgnd[j]|((
unsigned short int)data8[i*2+1])|(((
unsigned int)data8[i*2])<<8);
142 data[j]=result.sgnd[j];
172 result.usgnd=result.usgnd|(((
unsigned short int)data[1]))|(((
unsigned short int)data[0])<<8);
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.
short int mag_read_data(int i2c_dev, int axis)
READ DATA (X, Y or Z)
int mag_write_reg(int i2c_dev, uint8_t reg, uint8_t data)
Rev 0 - 11/11/2012 RLEG project - 2012.
Rev 0 - 06/11/2012 RLEG project - 2012.
uint8_t * mag_read_reg(int i2c_dev, uint8_t reg, uint8_t count)
READ COUNT 8-BIT REGISTER IN SEQUENCE.
int mag_read_all_data(int i2c_dev, short int *data)
READ ALL DATA AT ONCE (X, Y and Z)