Skip to content
This repository was archived by the owner on Sep 30, 2019. It is now read-only.

Commit d70b111

Browse files
committed
SPI: Make sure CS line is active-low
If another user configures the SPI bus as CS active-high, the setting will stick. It is thus possible to end up in a situation where CS is forced high during SPI transactions. The solution is to explicitly disable 'cshigh' before using the SpiDev object.
1 parent 38cd1bb commit d70b111

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Adafruit_GPIO/SPI.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ def __init__(self, port, device, max_speed_hz=500000):
4141
self._device = spidev.SpiDev()
4242
self._device.open(port, device)
4343
self._device.max_speed_hz=max_speed_hz
44-
# Default to mode 0.
44+
# Default to mode 0, and make sure CS is active low.
4545
self._device.mode = 0
46+
self.cshigh = False
4647

4748
def set_clock_hz(self, hz):
4849
"""Set the speed of the SPI clock in hertz. Note that not all speeds

0 commit comments

Comments
 (0)