@@ -406,8 +406,8 @@ class LSM9DS1_SPI(LSM9DS1):
406
406
"""Driver for the LSM9DS1 connect over SPI."""
407
407
# pylint: disable=no-member
408
408
def __init__ (self , spi , xgcs , mcs ):
409
- self ._mag_device = spi_device .I2CDevice (spi , mcs )
410
- self ._xg_device = spi_device .I2CDevice (spi , xgcs )
409
+ self ._mag_device = spi_device .SPIDevice (spi , mcs , baudrate = 200000 , phase = 1 , polarity = 1 )
410
+ self ._xg_device = spi_device .SPIDevice (spi , xgcs , baudrate = 200000 , phase = 1 , polarity = 1 )
411
411
super ().__init__ ()
412
412
413
413
def _read_u8 (self , sensor_type , address ):
@@ -416,7 +416,6 @@ def _read_u8(self, sensor_type, address):
416
416
else :
417
417
device = self ._xg_device
418
418
with device as spi :
419
- spi .configure (baudrate = 200000 , phase = 0 , polarity = 0 )
420
419
self ._BUFFER [0 ] = (address | 0x80 ) & 0xFF
421
420
spi .write (self ._BUFFER , end = 1 )
422
421
spi .readinto (self ._BUFFER , end = 1 )
@@ -428,7 +427,6 @@ def _read_bytes(self, sensor_type, address, count, buf):
428
427
else :
429
428
device = self ._xg_device
430
429
with device as spi :
431
- spi .configure (baudrate = 200000 , phase = 0 , polarity = 0 )
432
430
buf [0 ] = (address | 0x80 ) & 0xFF
433
431
spi .write (buf , end = 1 )
434
432
spi .readinto (buf , end = count )
@@ -439,7 +437,6 @@ def _write_u8(self, sensor_type, address, val):
439
437
else :
440
438
device = self ._xg_device
441
439
with device as spi :
442
- spi .configure (baudrate = 200000 , phase = 0 , polarity = 0 )
443
440
self ._BUFFER [0 ] = (address & 0x7F ) & 0xFF
444
441
self ._BUFFER [1 ] = val & 0xFF
445
442
spi .write (self ._BUFFER , end = 2 )
0 commit comments