Skip to content

Commit

Permalink
ENH: added verbosity trigger edge + switch mock in test config
Browse files Browse the repository at this point in the history
  • Loading branch information
rpartzsch committed Jan 3, 2025
1 parent e71fa61 commit c4e45e3
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 11 deletions.
15 changes: 12 additions & 3 deletions aidatlu/main/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,18 @@ def conf_dut(self) -> None:
def conf_trigger_logic(self) -> None:
"""Configures the trigger logic. So the trigger polarity and the trigger pulse length and stretch."""

self.tlu.trigger_logic.set_trigger_polarity(
self.conf["trigger_inputs"]["trigger_polarity"]["polarity"]
)
if self.conf["trigger_inputs"]["trigger_polarity"]["polarity"] in [
0,
"0",
"rising",
]:
self.tlu.trigger_logic.set_trigger_polarity(0)
elif self.conf["trigger_inputs"]["trigger_polarity"]["polarity"] in [
1,
"1",
"falling",
]:
self.tlu.trigger_logic.set_trigger_polarity(1)

self.tlu.trigger_logic.set_pulse_stretch_pack(
self.conf["trigger_inputs"]["trigger_signal_shape"]["stretch"]
Expand Down
4 changes: 3 additions & 1 deletion aidatlu/test/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@

FILEPATH = Path(__file__).parent

MOCK = True
with open(FILEPATH / "tlu_test_configuration.yaml") as yaml_file:
test_config = yaml.safe_load(yaml_file)
MOCK = test_config["MOCK"]

if MOCK:
I2CMETHOD = MockI2C
Expand Down
5 changes: 4 additions & 1 deletion aidatlu/test/test_tlu.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
from pathlib import Path
import time
import yaml
import pytest
from aidatlu.main.tlu import AidaTLU
from aidatlu.hardware.i2c import I2CCore
from aidatlu.test.utils import MockI2C

FILEPATH = Path(__file__).parent

MOCK = True
with open(FILEPATH / "tlu_test_configuration.yaml") as yaml_file:
test_config = yaml.safe_load(yaml_file)
MOCK = test_config["MOCK"]

if MOCK:
I2CMETHOD = MockI2C
Expand Down
12 changes: 7 additions & 5 deletions aidatlu/test/tlu_test_configuration.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
################################################
#
# This configuration is only used during tests
#
###############################################
# #
# This configuration is only used during tests #
# #
################################################

# Use mock I2C
MOCK: True # This setting is ignored outside of tests

internal_trigger: #Generate TLU internal trigger with given rate in Hz
internal_trigger_rate: 100000
Expand Down Expand Up @@ -33,7 +35,7 @@ trigger_inputs: #threshold voltages for the trigger inputs in V.
trigger_inputs_logic: CH1

trigger_polarity: #TLU triggers on rising (0) or falling (1) edge
polarity: 1
polarity: falling

trigger_signal_shape: #Stretches and delays each trigger input signal for an number of clock cycles,
stretch: [2, 2, 2, 2, 2, 2]
Expand Down
2 changes: 1 addition & 1 deletion aidatlu/tlu_configuration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ trigger_inputs: #threshold voltages for the trigger inputs in V.
trigger_inputs_logic: CH2 & CH4

trigger_polarity: #TLU triggers on rising (0) or falling (1) edge
polarity: 1
polarity: falling

trigger_signal_shape: #Stretches and delays each trigger input signal for an number of clock cycles,
stretch: [2, 2, 2, 2, 2, 2]
Expand Down

0 comments on commit c4e45e3

Please sign in to comment.