|
@@ -0,0 +1,54 @@
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+import typing
|
|
|
+
|
|
|
+import pytest
|
|
|
+
|
|
|
+import cc1101
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+@pytest.mark.parametrize(
|
|
|
+ ("freq210", "frequency_hertz"),
|
|
|
+ [((0x10, 0xB0, 0x71), 433920000), ((0x21, 0x62, 0x76), 868000000)],
|
|
|
+)
|
|
|
+def test_get_base_frequency_hertz(
|
|
|
+ transceiver: cc1101.CC1101,
|
|
|
+ freq210: typing.Tuple[int, int, int],
|
|
|
+ frequency_hertz: int,
|
|
|
+) -> None:
|
|
|
+ transceiver._spi.xfer.return_value = [0] + list(freq210)
|
|
|
+ assert transceiver.get_base_frequency_hertz() == pytest.approx(
|
|
|
+ frequency_hertz, abs=170
|
|
|
+ )
|
|
|
+ transceiver._spi.xfer.assert_called_once_with([0x0D | 0xC0, 0, 0, 0])
|
|
|
+
|
|
|
+
|
|
|
+@pytest.mark.parametrize(
|
|
|
+ ("freq210", "frequency_hertz"),
|
|
|
+ [((0x10, 0xB0, 0x71), 433920000), ((0x21, 0x62, 0x76), 868000000)],
|
|
|
+)
|
|
|
+def test_set_base_frequency_hertz(
|
|
|
+ transceiver: cc1101.CC1101,
|
|
|
+ freq210: typing.Tuple[int, int, int],
|
|
|
+ frequency_hertz: int,
|
|
|
+) -> None:
|
|
|
+ transceiver._spi.xfer.return_value = [15] * (1 + 3)
|
|
|
+ transceiver.set_base_frequency_hertz(frequency_hertz)
|
|
|
+ transceiver._spi.xfer.assert_called_once_with([0x0D | 0x40] + list(freq210))
|