Skip to content

Commit 2ae3612

Browse files
committed
Change _get_status to _status property
1 parent e0b2a19 commit 2ae3612

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

PSL/i2c.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,9 @@ def scan(self) -> List[int]:
9595

9696
return addrs
9797

98-
def _get_status(self):
99-
"""Get the contents of the I2C2STAT register.
98+
@property
99+
def _status(self):
100+
"""int: Contents of the I2C2STAT register.
100101
101102
bit 15 ACKSTAT: Acknowledge Status
102103
1 = NACK received from slave.

tests/recordings/i2c/test_status.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[[[4], [14], [4], [9], [244, 1], [4], [9], [244, 1], [4], [10]], [[], [1], [], [], [1], [], [], [1], [], [0, 0, 1]]]

tests/test_i2c.py

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
"""Tests for PSL.i2c.
2+
3+
When integration testing, the PSLab's logic analyzer is used to verify the
4+
function of the I2C bus. Before running the integration tests, connect:
5+
SCL->LA1
6+
SDA->LA2
7+
"""
8+
19
import pytest
210

311
from PSL.i2c import I2CMaster, I2CSlave
@@ -65,6 +73,12 @@ def test_scan(master: I2CMaster):
6573
assert mcp4728_address in master.scan()
6674

6775

76+
def test_status(master: I2CMaster):
77+
master.configure(1.25e5)
78+
# No status bits should be set on a newly configured bus.
79+
assert not master._status
80+
81+
6882
def test_start_slave(la: LogicAnalyzer, slave: I2CSlave):
6983
la.capture(2, block=False)
7084
slave._start(1)

0 commit comments

Comments
 (0)