Skip to content
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

Don't set SPI bus cshigh on v1 hub #202

Merged
merged 1 commit into from
Jul 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions pitopd/pthub/pthub_spi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
import threading
import traceback
from enum import Enum
from platform import uname
from re import match
from time import sleep

from pitop.common.common_ids import DeviceID
Expand Down Expand Up @@ -221,7 +219,6 @@ def _setup_spi(self):
self.spi.max_speed_hz = 9600
self.spi.mode = 0b00
self.spi.bits_per_word = 8
self.spi.cshigh = True
self.spi.lsbfirst = False

def _determine_byte(self, resp):
Expand Down Expand Up @@ -300,12 +297,6 @@ def _process_spi_resp(self, resp, init=False):
if init or not screen_is_blanked:
self._state.set_brightness(spi_brightness_int, False)

def __using_old_kernel(self):
# check if kernel version is lower than "5.0.0"
# to avoid errors when setting cshigh
# https://github.com/raspberrypi/linux/issues/3745
return match(r"^[0-4]\.", uname().release) is not None

def _transceive_spi(self, bits_to_send):
hex_str_to_send = "0x" + str(hex(bits_to_send))[2:].zfill(2)
bin_str_to_send = "{0:b}".format(int(hex_str_to_send[2:], 16)).zfill(8)
Expand All @@ -331,12 +322,8 @@ def _transceive_spi(self, bits_to_send):
+ "]"
)

if self.__using_old_kernel():
# Initiate receiving communication from hub
self.spi.cshigh = False
# Transfer data with hub
resp = self.spi.xfer2([bits_to_send], self.spi.max_speed_hz)
self.spi.cshigh = True

resp_hex = hex(resp[0])
resp_hex_str = "0x" + str(resp_hex)[2:].zfill(2)
Expand Down
Loading