1*** Variables ***
2${UART}                       sysbus.usart1
3${LED}                        sysbus.gpioPortC.led
4${BUTTON}                     sysbus.gpioPortA.button
5${URI}                        @https://dl.antmicro.com/projects/renode
6${LED_DELAY}                  1
7
8*** Keywords ***
9Create Machine
10    [Arguments]  ${elf}
11
12    Execute Command          mach create
13    Execute Command          machine LoadPlatformDescription @platforms/boards/stm32f072b_discovery.repl
14
15    Execute Command          sysbus LoadELF ${URI}/${elf}
16
17*** Test Cases ***
18Should Run Zephyr Hello Sample
19    Create Machine           stm32f072b_disco--zephyr-hello_world.elf-s_451704-a4d8c888e36c324dcc1dfde33bac33fc6ed3ed1b
20    Create Terminal Tester   ${UART}
21    Start Emulation
22
23    Wait For Line On Uart    Hello World! stm32f072b_disco
24
25Should Run Zephyr Console Echo Sample
26    Create Machine           stm32f072b_disco--zephyr-echo.elf-s_544096-541b7b153ff0a9b30489bd1cc34e693c0ac8b9ea
27    Create Terminal Tester   ${UART}
28
29    Start Emulation
30
31    Wait For Line On Uart    Start typing characters to see them echoed back
32    Write Line To Uart       Echo working?      waitForEcho=true
33
34Should Run Zephyr Blinky Sample
35    Create Machine           stm32f072b_disco--zephyr-blinky.elf-s_460516-9452135ae6af4492bb284a6f88b196b1314909c8
36
37    Create LED Tester        ${LED}  defaultTimeout=${LED_DELAY}
38
39    Start Emulation
40    Assert LED State         true
41    Assert LED State         false
42    Assert LED State         true
43    Assert LED State         false
44    Assert LED State         true
45    Assert LED State         false
46
47Should Run Zephyr Button Sample
48    Create Machine           stm32f072b_disco--zephyr-button.elf-s_466084-bd8983bad3182e3a36ca6120a629093bd24426c8
49    Create Terminal Tester   ${UART}
50
51    Start Emulation
52
53    Execute Command          ${BUTTON} Press
54    Sleep                    0.3
55    Execute Command          ${BUTTON} Release
56    Wait For Line On Uart    Button pressed at
57
58    # LED matches button state and should not change until after the button is pressed/released
59    Create LED Tester        ${LED}
60    Execute Command          ${BUTTON} Press
61    Assert And Hold LED State  false  ${LED_DELAY}  ${LED_DELAY}
62    Execute Command          ${BUTTON} Release
63    Assert And Hold LED State  true  ${LED_DELAY}  ${LED_DELAY}
64    Execute Command          ${BUTTON} Press
65    Assert And Hold LED State  false  ${LED_DELAY}  ${LED_DELAY}
66    Execute Command          ${BUTTON} Release
67
68Should Read ADC
69    Create Machine           stm32f072b--zephyr-adc.elf-s_567632-591075b4dc78decfb7ccab1d7a2477a78edc710e
70
71    Create Terminal Tester   ${UART}
72
73    Start Emulation
74
75    Wait For Line On Uart    Booting Zephyr
76
77    Execute Command          sysbus.adc SetDefaultValue 600
78    Wait For Line On Uart    ADC reading: 745
79
80    Execute Command          sysbus.adc SetDefaultValue 1200
81    Wait For Line On Uart    ADC reading: 1489
82
83Should Run stm32f0-crc-test Application
84    Execute Command          mach create
85    Execute Command          machine LoadPlatformDescription @platforms/boards/stm32f072b_discovery.repl
86    Execute Command          sysbus LoadELF @https://dl.antmicro.com/projects/renode/stm32f0-crc-test.elf-s_915148-a4b6b448dca6f24df573f23cd05224d11f9d83ff
87    Create Terminal Tester   ${UART}
88
89    Start Emulation
90
91    Wait For Line On Uart    test result: ok. 840 passed; 0 failed
92