1*** Keywords ***
2Prepare Machine
3    Execute Command             include @scripts/single-node/ek-ra2e1.resc
4
5*** Test Cases ***
6Should Run Periodicaly Blink LED
7    Prepare Machine
8    Create Led Tester           sysbus.port9.led_blue
9    Create Terminal Tester      sysbus.segger_rtt
10
11    Execute Command             agt0 IRQ AddStateChangedHook "Antmicro.Renode.Logging.Logger.Log(LogLevel.Error, 'AGT0 ' + str(state))"
12    # Timeout is only used for checking whether the IRQ has been handled
13    Create Log Tester           0.001
14
15    # Configuration is roughly in ms
16    Wait For Prompt On Uart     One-shot mode:
17    Write Line To Uart          10                                                      waitForEcho=false
18    Wait For Line On Uart       Time period for one-shot mode timer: 10
19
20    Wait For Prompt On Uart     Periodic mode:
21    Write Line To Uart          5                                                       waitForEcho=false
22    Wait For Line On Uart       Time period for periodic mode timer: 5
23
24    Wait For Prompt On Uart     Enter any key to start or stop the timers
25    Write Line To Uart                                                                  waitForEcho=false
26
27    # Timeout is extended by an additional 1ms to account for rounding errors
28    Wait For Log Entry          AGT0 True   level=Error    pauseEmulation=true  timeout=0.011
29    Wait For Log Entry          AGT0 False  level=Error    pauseEmulation=true
30    # move to the begining of a True state
31    Assert Led State            True        timeout=0.01   pauseEmulation=true
32    # Run test for 5 cycles
33    Assert Led Is Blinking      testDuration=0.05  onDuration=0.005  offDuration=0.005  tolerance=0.2  pauseEmulation=true
34    Assert Led State            True        timeout=0.005  pauseEmulation=true
35
36    # Stop timers, clear log tester history and check whether the periodic timer stops
37    Write Line To Uart                                                                  waitForEcho=false
38    Wait For Line On Uart       Periodic timer stopped. Enter any key to start timers.  pauseEmulation=true
39    Assert And Hold Led State   True  0.0  0.05
40