Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 3 additions & 3 deletions tests/test_spi.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
CS = "LA3"
SPIMaster._primary_prescaler = PPRE = 0
SPIMaster._secondary_prescaler = SPRE = 0
PWM_FERQUENCY = SPIMaster._frequency * 2 / 3
PWM_FREQUENCY = 1000
MICROSECONDS = 1e-6
RELTOL = 0.05
Comment on lines 31 to 36
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoding PWM_FREQUENCY = 1000 makes the SPI read-path tests much less meaningful. With the SPI clock in these tests on the order of ~100s of kHz, a 1 kHz SDI square wave will be effectively constant over an 8/16-bit transfer, so verify_value() can pass trivially (all bits identical) and may no longer exercise sampling behavior (especially in test_set_parameter_smp). It would be better to derive PWM_FREQUENCY from the actual SPI clock (e.g., a fraction of the configured SPIMaster frequency) while still avoiding the earlier TypeError by ensuring you’re using a numeric frequency value (not a descriptor/method object).

Copilot uses AI. Check for mistakes.
# Number of expected logic level changes.
Expand Down Expand Up @@ -61,7 +61,7 @@ def slave(handler: SerialHandler) -> SPISlave:
@pytest.fixture
def la(handler: SerialHandler) -> LogicAnalyzer:
pwm = PWMGenerator(handler)
pwm.generate(SDI[1], PWM_FERQUENCY, 0.5)
pwm.generate(SDI[1], PWM_FREQUENCY, 0.5)
return LogicAnalyzer(handler)


Expand All @@ -73,7 +73,7 @@ def verify_value(
smp: int = 0,
):
sck_ts = sck_timestamps[smp::2]
pwm_half_period = ((1 / PWM_FERQUENCY) * 1e6) / 2 # microsecond
pwm_half_period = ((1 / PWM_FREQUENCY) * 1e6) / 2 # microsecond

pattern = ""
for t in sck_ts:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_uart.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
WRITE_DATA = 0x55
TXD2 = "LA1"
RXD2 = "SQ1"
PWM_FERQUENCY = UART._baudrate // 2
PWM_FREQUENCY = 1000
MICROSECONDS = 1e-6
Comment on lines 18 to 21
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PWM_FREQUENCY = 1000 is not aligned with how test_read_byte / test_read_int are structured. Those tests expect the UART RX line (driven by PWMGenerator on SQ1) to be a square wave that flips every UART bit-time, which requires a PWM frequency of roughly uart's configured baudrate / 2 (producing 0x55 / 0xAA depending on alignment). With a 1 kHz PWM and the default UART baudrate (~460800), the line will be essentially constant during a frame, so the expected values are unlikely and the tests become unreliable. Consider deriving the PWM frequency from the actual baudrate used in the test (e.g., configure a known baudrate in the uart fixture and compute PWM from that), and add a short comment explaining the relationship.

Copilot uses AI. Check for mistakes.
RELTOL = 0.05
# Number of expected logic level changes.
Expand All @@ -38,7 +38,7 @@ def la(handler: SerialHandler) -> LogicAnalyzer:
@pytest.fixture
def pwm(handler: SerialHandler) -> None:
pwm = PWMGenerator(handler)
pwm.generate(RXD2, PWM_FERQUENCY, 0.5)
pwm.generate(RXD2, PWM_FREQUENCY, 0.5)


def test_configure(la: LogicAnalyzer, uart: UART):
Expand Down
Loading