Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.53 KB | None | 0 0
  1. void read_full_xyz(int16_t * acc_X, int16_t * acc_Y, int16_t * acc_Z){
  2.     int i;
  3.     int16_t temp[3];
  4.     if(g_I2C_Msg.Status != READING)
  5.     {
  6.         g_I2C_Msg.Data_count = 6;
  7.         g_I2C_Msg.Dev_adx = MMA_ADDR;
  8.         g_I2C_Msg.Reg_adx = REG_XHI;
  9.         g_I2C_Msg.Command = READ;
  10.     }
  11.     //i2c_read_bytes(MMA_ADDR, REG_XHI, data, 6);
  12.     if(g_I2C_Msg.Status == READ_COMPLETE)
  13.     {
  14.  
  15.         for ( i=0; i<3; i++ ) {
  16.             temp[i] = (int16_t) ((data[2*i]<<8) | data[2*i+1]);
  17.         }
  18.  
  19.         // Align for 14 bits
  20.         *acc_X = temp[0]/4;
  21.         *acc_Y = temp[1]/4;
  22.         *acc_Z = temp[2]/4;
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement