11 int acc_init(
int i2c_dev, uint8_t full_res, uint16_t rate, uint8_t range)
34 perror(
"Data Format unsuccesful");
40 perror(
"Power Control unsuccesful");
76 perror(
"Wrong rate value");
80 perror(
"Write in BW_RATE unsuccesful");
97 perror(
"Write unsucessful: Read-Only Register");
101 if ((write(i2c_dev, ®_data, 2)) != 2) {
102 perror(
"Write unsuccessful");
118 if ((write(i2c_dev, &data, 1)) != 1) {
123 if ((read(i2c_dev, &data, count)) != count) {
136 unsigned short int usgnd;
155 result.usgnd=result.usgnd|(((
unsigned short int)data[0]))|(((
unsigned short int)data[1])<<8);
165 unsigned short int usgnd[3];
178 result.usgnd[i]=result.usgnd[i]|((
unsigned short int)data8[i*2])|(((
unsigned short int)data8[i*2+1])<<8);
179 data[i]=result.sgnd[i];
190 bits[i]=((*hvalue)<<i)>>7+
ASCII_0;
198 uint8_t *hvalue0, *hvalue1, *hvalue;
209 hvalue=(uint8_t*)malloc(30*
sizeof(uint8_t));
210 hvalue[0]=hvalue0[0];
212 hvalue[i+1]=hvalue1[i];
215 printf(
"\nACC_THRESH_TAP = 0x%02X = %s", hvalue1[0],
conv_byte_hex_bin(hvalue+1));
223 printf(
"\nACC_THRESH_INACT = 0x%02X = %s", hvalue[9],
conv_byte_hex_bin(hvalue+9));
224 printf(
"\nACC_TIME_INACT = 0x%02X = %s", hvalue[10],
conv_byte_hex_bin(hvalue+10));
225 printf(
"\nACC_ACT_INACT_CTL = 0x%02X = %s", hvalue[11],
conv_byte_hex_bin(hvalue+11));
226 printf(
"\nACC_THRESH_FF = 0x%02X = %s", hvalue[12],
conv_byte_hex_bin(hvalue+12));
229 printf(
"\nACC_ACT_TAP_STATUS = 0x%02X = %s", hvalue[15],
conv_byte_hex_bin(hvalue+15));
231 printf(
"\nACC_POWER_CTL = 0x%02X = %s", hvalue[17],
conv_byte_hex_bin(hvalue+17));
232 printf(
"\nACC_INT_ENABLE = 0x%02X = %s", hvalue[18],
conv_byte_hex_bin(hvalue+18));
234 printf(
"\nACC_INT_SOURCE = 0x%02X = %s", hvalue[20],
conv_byte_hex_bin(hvalue+20));
235 printf(
"\nACC_DATA_FORMAT = 0x%02X = %s", hvalue1[20],
conv_byte_hex_bin(hvalue1+21));
243 printf(
"\nACC_FIFO_STATUS = 0x%02X = %s", hvalue[29],
conv_byte_hex_bin(hvalue+29));
#define ACC_POWER_CTL_MEAS_MODE
char * conv_byte_hex_bin(uint8_t *hvalue)
int acc_write_reg(int i2c_dev, uint8_t reg, uint8_t data)
WRITE TO REGISTER.
#define ACC_ACT_TAP_STATUS
Rev 0 - 06/11/2012 RLEG project - 2012.
int acc_read_all_data(int i2c_dev, short int *data)
READ ALL DATA AT ONCE (X, Y and Z)
uint8_t * acc_read_reg(int i2c_dev, uint8_t reg, uint8_t count)
READ COUNT 8-BIT REGISTER IN SEQUENCE
short int acc_read_data(int i2c_dev, int axis)
READ DATA (X, Y or Z)
int acc_read_all_reg(int i2c_dev)
Read all accelerometer data and print in stdio.
int acc_init(int i2c_dev, uint8_t full_res, uint16_t rate, uint8_t range)
Rev 0 - 11/11/2012 RLEG project - 2012.