@@ -363,12 +363,32 @@ def _write_u8(self, sensor_type, address, val):
363363
364364
365365class LSM9DS1_I2C (LSM9DS1 ):
366- """Driver for the LSM9DS1 connect over I2C."""
366+ """Driver for the LSM9DS1 connect over I2C.
367367
368- def __init__ (self , i2c ):
369- self ._mag_device = i2c_device .I2CDevice (i2c , _LSM9DS1_ADDRESS_MAG )
370- self ._xg_device = i2c_device .I2CDevice (i2c , _LSM9DS1_ADDRESS_ACCELGYRO )
371- super ().__init__ ()
368+ :param ~busio.I2C i2c: The I2C bus object used to connect to the LSM9DS1.
369+
370+ .. note:: This object should be shared among other driver classes that use the
371+ same I2C bus (SDA & SCL pins) to connect to different I2C devices.
372+
373+ :param int mag_address: A 8-bit integer that represents the i2c address of the
374+ LSM9DS1's magnetometer. Options are limited to ``0x1C`` or ``0x1E``.
375+ Defaults to ``0x1E``.
376+
377+ :param int xg_address: A 8-bit integer that represents the i2c address of the
378+ LSM9DS1's accelerometer and gyroscope. Options are limited to ``0x6A`` or ``0x6B``.
379+ Defaults to ``0x6B``.
380+
381+ """
382+ def __init__ (self , i2c , mag_address = _LSM9DS1_ADDRESS_MAG ,
383+ xg_address = _LSM9DS1_ADDRESS_ACCELGYRO ):
384+ if mag_address in (0x1c , 0x1e ) and xg_address in (0x6a , 0x6b ):
385+ self ._mag_device = i2c_device .I2CDevice (i2c , mag_address )
386+ self ._xg_device = i2c_device .I2CDevice (i2c , xg_address )
387+ super ().__init__ ()
388+ else :
389+ raise ValueError ('address parmeters are incorrect. Read the docs at '
390+ 'circuitpython.rtfd.io/projects/lsm9ds1/en/latest'
391+ '/api.html#adafruit_lsm9ds1.LSM9DS1_I2C' )
372392
373393 def _read_u8 (self , sensor_type , address ):
374394 if sensor_type == _MAGTYPE :
@@ -401,7 +421,20 @@ def _write_u8(self, sensor_type, address, val):
401421
402422
403423class LSM9DS1_SPI (LSM9DS1 ):
404- """Driver for the LSM9DS1 connect over SPI."""
424+ """Driver for the LSM9DS1 connect over SPI.
425+
426+ :param ~busio.SPI spi: The SPI bus object used to connect to the LSM9DS1.
427+
428+ .. note:: This object should be shared among other driver classes that use the
429+ same SPI bus (SCK, MISO, MOSI pins) to connect to different SPI devices.
430+
431+ :param ~digitalio.DigitalInOut mcs: The digital output pin connected to the
432+ LSM9DS1's CSM (Chip Select Magnetometer) pin.
433+
434+ :param ~digitalio.DigitalInOut xgcs: The digital output pin connected to the
435+ LSM9DS1's CSAG (Chip Select Accelerometer/Gyroscope) pin.
436+
437+ """
405438 # pylint: disable=no-member
406439 def __init__ (self , spi , xgcs , mcs ):
407440 self ._mag_device = spi_device .SPIDevice (spi , mcs , baudrate = 200000 , phase = 1 , polarity = 1 )
0 commit comments