@@ -406,8 +406,8 @@ class LSM9DS1_SPI(LSM9DS1):
406406 """Driver for the LSM9DS1 connect over SPI."""
407407 # pylint: disable=no-member
408408 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 )
411411 super ().__init__ ()
412412
413413 def _read_u8 (self , sensor_type , address ):
@@ -416,7 +416,6 @@ def _read_u8(self, sensor_type, address):
416416 else :
417417 device = self ._xg_device
418418 with device as spi :
419- spi .configure (baudrate = 200000 , phase = 0 , polarity = 0 )
420419 self ._BUFFER [0 ] = (address | 0x80 ) & 0xFF
421420 spi .write (self ._BUFFER , end = 1 )
422421 spi .readinto (self ._BUFFER , end = 1 )
@@ -428,7 +427,6 @@ def _read_bytes(self, sensor_type, address, count, buf):
428427 else :
429428 device = self ._xg_device
430429 with device as spi :
431- spi .configure (baudrate = 200000 , phase = 0 , polarity = 0 )
432430 buf [0 ] = (address | 0x80 ) & 0xFF
433431 spi .write (buf , end = 1 )
434432 spi .readinto (buf , end = count )
@@ -439,7 +437,6 @@ def _write_u8(self, sensor_type, address, val):
439437 else :
440438 device = self ._xg_device
441439 with device as spi :
442- spi .configure (baudrate = 200000 , phase = 0 , polarity = 0 )
443440 self ._BUFFER [0 ] = (address & 0x7F ) & 0xFF
444441 self ._BUFFER [1 ] = val & 0xFF
445442 spi .write (self ._BUFFER , end = 2 )
0 commit comments