summaryrefslogtreecommitdiff
path: root/kvmd/plugins/hid/_mcu
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2020-11-03 10:15:54 +0300
committerDevaev Maxim <[email protected]>2020-11-11 22:24:25 +0300
commite07cdd60f393eb17184afe4ea1730f3c5745ea6f (patch)
tree5751136b75af6dc2433c19e17b9e3739cb7a9d33 /kvmd/plugins/hid/_mcu
parenta3707d047fddd5f0c923422468be29ddb345f989 (diff)
spi firmware
Diffstat (limited to 'kvmd/plugins/hid/_mcu')
-rw-r--r--kvmd/plugins/hid/_mcu/__init__.py8
-rw-r--r--kvmd/plugins/hid/_mcu/gpio.py13
2 files changed, 15 insertions, 6 deletions
diff --git a/kvmd/plugins/hid/_mcu/__init__.py b/kvmd/plugins/hid/_mcu/__init__.py
index f762567b..3f925cd8 100644
--- a/kvmd/plugins/hid/_mcu/__init__.py
+++ b/kvmd/plugins/hid/_mcu/__init__.py
@@ -172,6 +172,7 @@ class BaseMcuHid(BaseHid, multiprocessing.Process): # pylint: disable=too-many-
phy: BasePhy,
reset_pin: int,
+ reset_inverted: bool,
reset_delay: float,
read_retries: int,
@@ -190,7 +191,7 @@ class BaseMcuHid(BaseHid, multiprocessing.Process): # pylint: disable=too-many-
self.__noop = noop
self.__phy = phy
- self.__gpio = Gpio(reset_pin, reset_delay)
+ self.__gpio = Gpio(reset_pin, reset_inverted, reset_delay)
self.__events_queue: "multiprocessing.Queue[_BaseEvent]" = multiprocessing.Queue()
@@ -207,8 +208,9 @@ class BaseMcuHid(BaseHid, multiprocessing.Process): # pylint: disable=too-many-
@classmethod
def get_plugin_options(cls) -> Dict:
return {
- "reset_pin": Option(-1, type=valid_gpio_pin_optional),
- "reset_delay": Option(0.1, type=valid_float_f01),
+ "reset_pin": Option(-1, type=valid_gpio_pin_optional),
+ "reset_inverted": Option(False, type=valid_bool),
+ "reset_delay": Option(0.1, type=valid_float_f01),
"read_retries": Option(10, type=valid_int_f1),
"common_retries": Option(100, type=valid_int_f1),
diff --git a/kvmd/plugins/hid/_mcu/gpio.py b/kvmd/plugins/hid/_mcu/gpio.py
index 830819f0..87f4b547 100644
--- a/kvmd/plugins/hid/_mcu/gpio.py
+++ b/kvmd/plugins/hid/_mcu/gpio.py
@@ -33,8 +33,15 @@ from .... import aiogp
# =====
class Gpio:
- def __init__(self, reset_pin: int, reset_delay: float) -> None:
+ def __init__(
+ self,
+ reset_pin: int,
+ reset_inverted: bool,
+ reset_delay: float,
+ ) -> None:
+
self.__reset_pin = reset_pin
+ self.__reset_inverted = reset_inverted
self.__reset_delay = reset_delay
self.__chip: Optional[gpiod.Chip] = None
@@ -47,7 +54,7 @@ class Gpio:
assert self.__reset_line is None
self.__chip = gpiod.Chip(env.GPIO_DEVICE_PATH)
self.__reset_line = self.__chip.get_line(self.__reset_pin)
- self.__reset_line.request("kvmd::hid-mcu::reset", gpiod.LINE_REQ_DIR_OUT, default_vals=[0])
+ self.__reset_line.request("kvmd::hid-mcu::reset", gpiod.LINE_REQ_DIR_OUT, default_vals=[int(self.__reset_inverted)])
def close(self) -> None:
if self.__chip:
@@ -63,7 +70,7 @@ class Gpio:
if not self.__reset_wip:
self.__reset_wip = True
try:
- await aiogp.pulse(self.__reset_line, self.__reset_delay, 1)
+ await aiogp.pulse(self.__reset_line, self.__reset_delay, 1, self.__reset_inverted)
finally:
self.__reset_wip = False
get_logger(0).info("Reset HID performed")