1- # Filename: test-button.robot
21*** Settings ***
32Suite Setup Setup
43Suite Teardown Teardown
5- Test Setup Reset Emulation
4+ Test Setup Reset And Load System
65Resource ${RENODEKEYWORDS }
76
7+ *** Variables ***
8+ ${REPL } ${CURDIR } /../nucleo_f446re_custom.repl
9+ ${ELF } ${CURDIR } /../nucleo-f446re/ButtonLed/build/ButtonLed.elf
10+ ${LED } sysbus.gpioa.greenled2
11+ ${BUTTON } sysbus.gpioc.bluebutton
12+
813*** Test Cases ***
914Button Press should Toggle LED
10- Execute Command mach create
11- Execute Command machine LoadPlatformDescription @${CURDIR } /../nucleo_f446re_custom.repl
12- Execute Command sysbus LoadELF @${CURDIR } /../nucleo-f446re/ButtonLed/build/ButtonLed.elf
15+ [Documentation] Verifies that the LED toggles its state on every
16+ ... button click.
1317
14- Start Emulation
15-
16- ${LedState } = Execute Command sysbus.gpioa.greenled2 State
17- Should Be Equal ${LedState.strip() } False
18-
19- Execute Command sysbus.gpioc.bluebutton Press
20- sleep 100milliseconds
21- Execute Command sysbus.gpioc.bluebutton Release
18+ LED State Should Be False
2219
23- ${LedState } = Execute Command sysbus.gpioa.greenled2 State
24- Should Be Equal ${LedState.strip() } True
20+ Toggle Button
21+ LED State Should Be True
22+
23+ Toggle Button
24+ LED State Should Be False
25+
26+ *** Keywords ***
27+ Reset And Load System
28+ Reset Emulation
29+ Execute Command mach create
30+ Execute Command machine LoadPlatformDescription @${REPL }
31+ Execute Command sysbus LoadELF @${ELF }
32+ Start Emulation
2533
26- Execute Command sysbus.gpioc.bluebutton Press
27- sleep 100milliseconds
28- Execute Command sysbus.gpioc.bluebutton Release
34+ Toggle Button
35+ Execute Command ${BUTTON } Press
36+ Sleep 100ms # Small delay for debouncing logic in firmware
37+ Execute Command ${BUTTON } Release
2938
30- ${LedState } = Execute Command sysbus.gpioa.greenled2 State
31- Should Be Equal ${LedState.strip() } False
32-
39+ LED State Should Be
40+ [Arguments] ${expected_state }
41+ ${current_state } = Execute Command ${LED } State
42+ Should Be Equal ${current_state.strip() } ${expected_state }
0 commit comments