-
Notifications
You must be signed in to change notification settings - Fork 8
Fixes for SPI class #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
b3a7966
55cbf04
d024a3c
ed4492c
8d3c393
aebd0dd
5374e18
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -397,8 +397,8 @@ class LSM9DS0_SPI(LSM9DS0): | |
"""Driver for the LSM9DS0 connected over SPI.""" | ||
# pylint: disable=no-member | ||
def __init__(self, spi, xmcs, gcs): | ||
self._gyro_device = spi_device.I2CDevice(spi, gcs) | ||
self._xm_device = spi_device.I2CDevice(spi, xmcs) | ||
self._mag_device = spi_device.SPIDevice(spi, xmcs, baudrate=200000, phase=1, polarity=1) | ||
self._xg_device = spi_device.SPIDevice(spi, gcs, baudrate=200000, phase=1, polarity=1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The rest of the code refers to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see comment below |
||
super().__init__() | ||
|
||
def _read_u8(self, sensor_type, address): | ||
|
@@ -407,7 +407,6 @@ def _read_u8(self, sensor_type, address): | |
else: | ||
device = self._xm_device | ||
with device as spi: | ||
spi.configure(baudrate=200000, phase=0, polarity=0) | ||
self._BUFFER[0] = (address | 0x80) & 0xFF | ||
spi.write(self._BUFFER, end=1) | ||
spi.readinto(self._BUFFER, end=1) | ||
|
@@ -419,7 +418,6 @@ def _read_bytes(self, sensor_type, address, count, buf): | |
else: | ||
device = self._xm_device | ||
with device as spi: | ||
spi.configure(baudrate=200000, phase=0, polarity=0) | ||
buf[0] = (address | 0x80) & 0xFF | ||
spi.write(buf, end=1) | ||
spi.readinto(buf, end=count) | ||
|
@@ -430,7 +428,6 @@ def _write_u8(self, sensor_type, address, val): | |
else: | ||
device = self._xm_device | ||
with device as spi: | ||
spi.configure(baudrate=200000, phase=0, polarity=0) | ||
self._BUFFER[0] = (address & 0x7F) & 0xFF | ||
self._BUFFER[1] = val & 0xFF | ||
spi.write(self._BUFFER, end=2) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,17 @@ | |
i2c = busio.I2C(board.SCL, board.SDA) | ||
sensor = adafruit_lsm9ds0.LSM9DS0_I2C(i2c) | ||
|
||
#SPI connection: | ||
# from digitalio import DigitalInOut, Direction | ||
# spi = busio.SPI(board.SCK, board.MOSI, board.MISO) | ||
# csag = DigitalInOut(board.D5) | ||
# csag.direction = Direction.OUTPUT | ||
# csag.value = True | ||
# csm = DigitalInOut(board.D6) | ||
# csm.direction = Direction.OUTPUT | ||
# csm.value = True | ||
# sensor = adafruit_lsm9ds0.LSM9DS0_SPI(spi, csag, csm) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This example copy-pasted from LSM9DS1 is probably all wrong also. For one thing, the CS pins are taken in a different order for the LSM9DS0: def __init__(self, spi, xmcs, gcs): |
||
# Main loop will read the acceleration, magnetometer, gyroscope, Temperature | ||
# values every second and print them out. | ||
while True: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rest of the code refers to
self._gyro_device
, is this incorrect or is the rest of the code incorrect?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see comment below