Skip to content

Commit b08fb3c

Browse files
committed
DM: fix SPI bugs, gyro bitmask
1 parent 019e15c commit b08fb3c

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

Adafruit_LSM9DS1.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ void Adafruit_LSM9DS1::setupMag ( lsm9ds1MagGain_t gain )
301301
void Adafruit_LSM9DS1::setupGyro ( lsm9ds1GyroScale_t scale )
302302
{
303303
uint8_t reg = read8(XGTYPE, LSM9DS1_REGISTER_CTRL_REG1_G);
304-
reg &= ~(0b00110000);
304+
reg &= ~(0b00011000);
305305
reg |= scale;
306306
write8(XGTYPE, LSM9DS1_REGISTER_CTRL_REG1_G, reg );
307307

@@ -389,7 +389,7 @@ void Adafruit_LSM9DS1::write8(boolean type, byte reg, byte value)
389389
} else {
390390
digitalWrite(_cs, LOW);
391391
if (_clk == -1) // hardware SPI
392-
SPI.beginTransaction(SPISettings(200000, MSBFIRST, SPI_MODE0));
392+
SPI.beginTransaction(SPISettings(2000000, MSBFIRST, SPI_MODE3));
393393
// set address
394394
spixfer(reg & 0x7F); // write data
395395
spixfer(value);
@@ -442,13 +442,16 @@ byte Adafruit_LSM9DS1::readBuffer(boolean type, byte reg, byte len, uint8_t *buf
442442

443443
} else {
444444
if (_clk == -1) // hardware SPI
445-
SPI.beginTransaction(SPISettings(200000, MSBFIRST, SPI_MODE0));
445+
SPI.beginTransaction(SPISettings(2000000, MSBFIRST, SPI_MODE3));
446446
else
447447
digitalWrite(_clk, HIGH);
448448
// set address
449449

450450
digitalWrite(_cs, LOW);
451451

452+
if(type == MAGTYPE)
453+
reg |= 0x40;
454+
452455
spixfer(reg | 0x80 ); // readdata
453456
for (uint8_t i=0; i<len; i++) {
454457
buffer[i] = spixfer(0);

Adafruit_LSM9DS1.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ class Adafruit_LSM9DS1
168168

169169
typedef enum
170170
{
171-
LSM9DS1_GYROSCALE_245DPS = (0b00 << 4), // +/- 245 degrees per second rotation
172-
LSM9DS1_GYROSCALE_500DPS = (0b01 << 4), // +/- 500 degrees per second rotation
173-
LSM9DS1_GYROSCALE_2000DPS = (0b11 << 4) // +/- 2000 degrees per second rotation
171+
LSM9DS1_GYROSCALE_245DPS = (0b00 << 3), // +/- 245 degrees per second rotation
172+
LSM9DS1_GYROSCALE_500DPS = (0b01 << 3), // +/- 500 degrees per second rotation
173+
LSM9DS1_GYROSCALE_2000DPS = (0b11 << 3) // +/- 2000 degrees per second rotation
174174
} lsm9ds1GyroScale_t;
175175

176176
typedef struct vector_s

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Adafruit LSM9DS1 Library
2-
version=1.0.0
2+
version=1.0.1
33
author=Adafruit
44
maintainer=Adafruit <[email protected]>
55
sentence=Arduino library for LSM9DS1 9-DOF sensor board.

0 commit comments

Comments
 (0)