|
| 1 | +import pytest |
| 2 | + |
| 3 | +digital_inputs = [('d0', 'input'), ('d1', 'input'), ('d2', 'input'), ('d3', 'input'), ('ee_d0', 'input'), ('ee_d1', 'input')] |
| 4 | +digital_outputs = [('d0', 'output'), ('d1', 'output'), ('d2', 'output'), ('d3', 'output'), ('ee_d0', 'output'), ('ee_d1', 'output')] |
| 5 | +analog_inputs = [('ee_a0', 'input'), ('ee_a1', 'input')] |
| 6 | +IOs = digital_inputs + analog_inputs + digital_outputs |
| 7 | +# Not supported yet ('a0', 'input'), ('a1', 'input'), ('a0', 'output'), ('a1', 'output'), ('ee_a0', 'output'), ('ee_a1', 'output') |
| 8 | + |
| 9 | + |
| 10 | +@pytest.mark.robot_required |
| 11 | +class TestEva_GPIO: |
| 12 | + def test_get(self, eva): |
| 13 | + # For all io variations, if the key is not present an exception |
| 14 | + # will be thrown so no assertions are required |
| 15 | + for pin in IOs: |
| 16 | + (pin_name, pin_type) = pin |
| 17 | + eva.gpio_get(pin_name, pin_type) |
| 18 | + |
| 19 | + |
| 20 | + def test_set(self, locked_eva): |
| 21 | + # All outputs should be set-able and idempotent |
| 22 | + for pin in digital_outputs: |
| 23 | + (pin_name, _) = pin |
| 24 | + locked_eva.gpio_set(pin_name, True) |
| 25 | + locked_eva.gpio_set(pin_name, True) |
| 26 | + locked_eva.gpio_set(pin_name, False) |
| 27 | + locked_eva.gpio_set(pin_name, False) |
| 28 | + |
| 29 | + |
| 30 | + @pytest.mark.io_loopback_required |
| 31 | + def test_set_get(self, locked_eva): |
| 32 | + digital_states = [True, False] |
| 33 | + for state in digital_states: |
| 34 | + for (pin_name, _) in digital_outputs: |
| 35 | + locked_eva.gpio_set(pin_name, state) |
| 36 | + |
| 37 | + for (pin_name, pin_type) in digital_inputs: |
| 38 | + pin_state = locked_eva.gpio_get(pin_name, pin_type) |
| 39 | + assert(pin_state == state) |
0 commit comments