mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 09:10:30 +08:00
removed cshigh option
This commit is contained in:
parent
0140cba0dc
commit
c144f41c1d
@ -104,7 +104,6 @@ class _SpiPhy(BasePhy): # pylint: disable=too-many-instance-attributes
|
|||||||
chip: int,
|
chip: int,
|
||||||
hw_cs: bool,
|
hw_cs: bool,
|
||||||
sw_cs_pin: int,
|
sw_cs_pin: int,
|
||||||
cs_high: bool,
|
|
||||||
max_freq: int,
|
max_freq: int,
|
||||||
block_usec: int,
|
block_usec: int,
|
||||||
read_timeout: float,
|
read_timeout: float,
|
||||||
@ -114,7 +113,6 @@ class _SpiPhy(BasePhy): # pylint: disable=too-many-instance-attributes
|
|||||||
self.__chip = chip
|
self.__chip = chip
|
||||||
self.__hw_cs = hw_cs
|
self.__hw_cs = hw_cs
|
||||||
self.__sw_cs_pin = sw_cs_pin
|
self.__sw_cs_pin = sw_cs_pin
|
||||||
self.__cs_high = cs_high
|
|
||||||
self.__max_freq = max_freq
|
self.__max_freq = max_freq
|
||||||
self.__block_usec = block_usec
|
self.__block_usec = block_usec
|
||||||
self.__read_timeout = read_timeout
|
self.__read_timeout = read_timeout
|
||||||
@ -128,18 +126,16 @@ class _SpiPhy(BasePhy): # pylint: disable=too-many-instance-attributes
|
|||||||
with contextlib.closing(spidev.SpiDev(self.__bus, self.__chip)) as spi:
|
with contextlib.closing(spidev.SpiDev(self.__bus, self.__chip)) as spi:
|
||||||
spi.mode = 0
|
spi.mode = 0
|
||||||
spi.no_cs = (not self.__hw_cs)
|
spi.no_cs = (not self.__hw_cs)
|
||||||
if self.__hw_cs:
|
|
||||||
spi.cshigh = self.__cs_high
|
|
||||||
spi.max_speed_hz = self.__max_freq
|
spi.max_speed_hz = self.__max_freq
|
||||||
|
|
||||||
def xfer(data: bytes) -> bytes:
|
def xfer(data: bytes) -> bytes:
|
||||||
try:
|
try:
|
||||||
if sw_cs_line is not None:
|
if sw_cs_line is not None:
|
||||||
sw_cs_line.set_value(int(self.__cs_high))
|
sw_cs_line.set_value(0)
|
||||||
return spi.xfer(data, self.__max_freq, self.__block_usec)
|
return spi.xfer(data, self.__max_freq, self.__block_usec)
|
||||||
finally:
|
finally:
|
||||||
if sw_cs_line is not None:
|
if sw_cs_line is not None:
|
||||||
sw_cs_line.set_value(int(not self.__cs_high))
|
sw_cs_line.set_value(1)
|
||||||
|
|
||||||
yield _SpiPhyConnection(
|
yield _SpiPhyConnection(
|
||||||
xfer=xfer,
|
xfer=xfer,
|
||||||
@ -151,7 +147,7 @@ class _SpiPhy(BasePhy): # pylint: disable=too-many-instance-attributes
|
|||||||
if self.__sw_cs_pin > 0:
|
if self.__sw_cs_pin > 0:
|
||||||
with contextlib.closing(gpiod.Chip(env.GPIO_DEVICE_PATH)) as chip:
|
with contextlib.closing(gpiod.Chip(env.GPIO_DEVICE_PATH)) as chip:
|
||||||
line = chip.get_line(self.__sw_cs_pin)
|
line = chip.get_line(self.__sw_cs_pin)
|
||||||
line.request("kvmd::hid-mcu::sw_cs", gpiod.LINE_REQ_DIR_OUT, default_vals=[int(not self.__cs_high)])
|
line.request("kvmd::hid-mcu::sw_cs", gpiod.LINE_REQ_DIR_OUT, default_vals=[1])
|
||||||
yield line
|
yield line
|
||||||
else:
|
else:
|
||||||
yield None
|
yield None
|
||||||
@ -177,7 +173,6 @@ class Plugin(BaseMcuHid):
|
|||||||
"chip": Option(-1, type=valid_int_f0),
|
"chip": Option(-1, type=valid_int_f0),
|
||||||
"hw_cs": Option(False, type=valid_bool),
|
"hw_cs": Option(False, type=valid_bool),
|
||||||
"sw_cs_pin": Option(-1, type=valid_gpio_pin_optional),
|
"sw_cs_pin": Option(-1, type=valid_gpio_pin_optional),
|
||||||
"cs_high": Option(False, type=valid_bool),
|
|
||||||
"max_freq": Option(200000, type=valid_int_f1),
|
"max_freq": Option(200000, type=valid_int_f1),
|
||||||
"block_usec": Option(1, type=valid_int_f0),
|
"block_usec": Option(1, type=valid_int_f0),
|
||||||
"read_timeout": Option(0.5, type=valid_float_f01),
|
"read_timeout": Option(0.5, type=valid_float_f01),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user