1*** Variables ***
2${UART}                             sysbus.usart1
3${GREEN_LED}                        sysbus.gpioPortB.GreenLED
4${BLUE_LED}                         sysbus.gpioPortB.BlueLED
5${USER_BUTTON}                      sysbus.gpioPortC.UserButton1
6
7${PROJECT_URL}                      @https://dl.antmicro.com/projects/renode
8${UART_PRINTF}                      ${PROJECT_URL}/stm32wba--cube_mx_UART_Printf.elf-s_414528-276b355f13e0fc82007222130810179e374d275e
9${EXTI_ToggleLED}                   ${PROJECT_URL}/stm32wba--cubemx-EXTI_ToggleLedOnIT_Init.elf-s_196736-e4aae2df7e5f275593f31d5d94db7c852c1575f6
10${SPI_POLLING}                      ${PROJECT_URL}/stm32wba52--cube_mx--SPI_FullDuplex_ComPolling_Master.elf-s_351444-751cf3ade71c0e0ff33c010a97ab61f9a97e7487
11${SPI_INTERRUPT}                    ${PROJECT_URL}/stm32wba52--cube_mx--SPI_FullDuplex_ComIT_Master.elf-s_370676-fdb46bf729f660edb79ff64bf10f6da8e0dc517b
12
13${PLATFORM}                         @platforms/boards/nucleo_wba52cg.repl
14${SPI_LOOPBACK}                     loopback: SPI.SPILoopback @ spi3
15
16*** Keywords ***
17Create Machine
18    [Arguments]                     ${elf}
19
20    Execute Command                 mach create
21    Execute Command                 machine LoadPlatformDescription ${PLATFORM}
22
23    Execute Command                 sysbus LoadELF ${elf}
24
25Run SPI Test Case
26    [Arguments]                     ${elf}
27
28    Create Machine                  ${elf}
29    Execute Command                 machine LoadPlatformDescriptionFromString "${SPI_LOOPBACK}"
30    Create LED Tester               ${GREEN_LED}  defaultTimeout=0.5
31
32    # The green LED should be off to start with
33    Assert LED State                false
34
35    # Trigger the SPI transfer
36    Execute Command                 ${USER_BUTTON} Press
37
38    # The green LED should turn on indicating that the transfer was successful and
39    # the received data was correct (identical to the sent data)
40    Assert LED State                true
41
42*** Test Cases ***
43Should Have Working UART
44    Create Machine                  ${UART_PRINTF}
45    Create Terminal Tester          ${UART}
46
47    Start Emulation
48
49    Wait For Line On Uart           UART Printf Example
50    Wait For Line On Uart           ** Test finished successfully. **
51
52Should have Working EXTI
53    Create Machine                 ${EXTI_TogglelED}
54    Create LED Tester              ${BLUE_LED}  defaultTimeout=0.1
55
56    Start Emulation
57
58    Assert LED State               false
59
60    Execute Command                ${USER_BUTTON} PressAndRelease
61    Assert LED State               true
62
63    Execute Command                ${USER_BUTTON} PressAndRelease
64    Assert LED State               false
65
66SPI Should Work In Polling Mode
67    Run SPI Test Case               ${SPI_POLLING}
68
69SPI Should Work In Interrupt Mode
70    Run SPI Test Case               ${SPI_INTERRUPT}
71