GPIO

The GPIO module allows you to directly interact with your DUT. For example, maybe your board has a manual hard reset button, that you'd like the ability to press. With GPIO this is possible programmatically, you just need to make sure to assign a GPIO net during setup.

Output

gpio_net_output.py
 import time
 from lager import Net, NetType, GPIO

 button = Net.get('BTN',
         type=NetType.GPIO,
         setup_function=setup_nets,
         teardown_function=teardown_nets)

 button.set(GPIO.MODE.OUT)
 button.output(GPIO.LEVEL.HIGH)
 time.sleep(1)
 button.output(GPIO.LEVEL.LOW)
Control GPIO Net's Output
 ~  lager gpio BTN output 1 --dut 1
 ~  lager gpio BTN output 0 --dut 1

Input

gpio_net_input.py
 import time
 from lager import Net, NetType, GPIO

 button = Net.get('BTN',
         type=NetType.GPIO,
         setup_function=setup_nets,
         teardown_function=teardown_nets)

 button.set(GPIO.MODE.INT)
 print(f"Button Value: {button.input()}")
Read GPIO Net's Input
 ~  lager gpio BTN intput --dut 1
 0
 ~