Skip to content

Commit d970210

Browse files
Compatibility with 32 bit chips
1 parent a5ca826 commit d970210

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/SparkFun_ADXL345.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ void ADXL345::readAccel(int *x, int *y, int *z) {
7474
readFrom(ADXL345_DATAX0, ADXL345_TO_READ, _buff); // Read Accel Data from ADXL345
7575

7676
// Each Axis @ All g Ranges: 10 Bit Resolution (2 Bytes)
77-
*x = (((int)_buff[1]) << 8) | _buff[0];
78-
*y = (((int)_buff[3]) << 8) | _buff[2];
79-
*z = (((int)_buff[5]) << 8) | _buff[4];
77+
*x = (int16_t)((((int)_buff[1]) << 8) | _buff[0]);
78+
*y = (int16_t)((((int)_buff[3]) << 8) | _buff[2]);
79+
*z = (int16_t)((((int)_buff[5]) << 8) | _buff[4]);
8080
}
8181

8282
void ADXL345::get_Gxyz(double *xyz){
@@ -818,4 +818,4 @@ void print_byte(byte val){
818818
for(i=7; i>=0; i--){
819819
Serial.print(val >> i & 1, BIN);
820820
}
821-
}
821+
}

0 commit comments

Comments
 (0)