1/*
2* Copyright (C) 1996-2019 IAR Systems AB.
3*
4* Excerpt from IAR Embedded Workbench tutorial
5*
6* Macro package for the C-SPY debugger to simulate Fibonacci data input,
7* including setting an immediate breakpoint and defining a simulated
8* interrupt.
9*
10* See the file riscv/doc/licenses/IARSourceLicense.txt for detailed
11* license information.
12*
13*/
14
15__var _counter;
16__var _interruptID;
17__var _breakID;
18
19execUserSetup()
20{
21    __message "execUserSetup() called\n";
22
23    /* Call the simulation setup. */
24    SimulationSetup ();
25}
26
27execUserExit()
28{
29    __message "execUserExit() called\n";
30
31    /* Call the Simulation shutdown. */
32    SimulationShutdown();
33}
34
35
36SimulationSetup()
37{
38    /* Automatically setup the TIMER interrupt for the simulation */
39    _interruptID = __orderInterrupt("TIMER", 1000, 1000, 0, 1, 0, 100);
40    if( -1 == _interruptID )
41    {
42        __message "ERROR: failed to set up the interrupt";
43    }
44
45    /* Insert a breakpoint in the _tx_timer_interrupt entry point */
46    _breakID = __setCodeBreak( "_tx_timer_interrupt", 0, "1", "TRUE", "InterruptCSPYlogger()");
47    if( !_breakID )
48    {
49        __message "ERROR: could not set immediate breakpoint.\n" ;
50    }
51}
52
53InterruptCSPYlogger()
54{
55    _counter++;
56    __message "Entered TIMER interrupt: ", _counter, "\n";
57}
58
59
60SimulationShutdown()
61{
62    __cancelInterrupt(_interruptID);
63    __clearBreak(_breakID);
64}