summaryrefslogtreecommitdiff
path: root/ports/risc-v32/iar/example_build/config/debugger/timer.mac
blob: 7dabac71bd84ee0bde3acc5f7914036c1692bb78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
* Copyright (C) 1996-2019 IAR Systems AB.
*
* Excerpt from IAR Embedded Workbench tutorial
*
* Macro package for the C-SPY debugger to simulate Fibonacci data input,
* including setting an immediate breakpoint and defining a simulated
* interrupt.
*
* See the file riscv/doc/licenses/IARSourceLicense.txt for detailed
* license information.
*
*/

__var _counter;
__var _interruptID;
__var _breakID;

execUserSetup()
{
    __message "execUserSetup() called\n";

    /* Call the simulation setup. */
    SimulationSetup ();
}

execUserExit()
{
    __message "execUserExit() called\n";

    /* Call the Simulation shutdown. */
    SimulationShutdown();
}


SimulationSetup()
{
    /* Automatically setup the TIMER interrupt for the simulation */
    _interruptID = __orderInterrupt("TIMER", 1000, 1000, 0, 1, 0, 100);
    if( -1 == _interruptID )
    {
        __message "ERROR: failed to set up the interrupt";
    }

    /* Insert a breakpoint in the _tx_timer_interrupt entry point */
    _breakID = __setCodeBreak( "_tx_timer_interrupt", 0, "1", "TRUE", "InterruptCSPYlogger()");
    if( !_breakID )
    {
        __message "ERROR: could not set immediate breakpoint.\n" ;
    }
}

InterruptCSPYlogger()
{
    _counter++;
    __message "Entered TIMER interrupt: ", _counter, "\n";
}


SimulationShutdown()
{
    __cancelInterrupt(_interruptID);
    __clearBreak(_breakID);
}