Debian Codegraph @

test/iar/iar_v5/Resource/SAM7_SIM.mac

raw
1 //=========================================================
2 // Simulation setup file for esc07_demo project
3 //=========================================================
4
5 __var _timer0_interrupt_ID;
6
7 irqBreak()
8 {
9 __var __AIC_SMR;
10 __var __AIC_IECR;
11 __var __AIC_IVR;
12
13 // read AIC_IECR instead, since not fully supported by simulator
14 __AIC_IECR = __readMemory32(0xFFFFF120, "Memory");
15 if(__AIC_IECR & 0x1000)
16 {
17 __AIC_SMR = __readMemory32(0xFFFFF060, "Memory");
18 __AIC_IVR = __readMemory32(0xFFFFF0B0, "Memory"); //AIC_IVR = AIC_SVR[x]
19 __writeMemory32(__AIC_IVR, 0xFFFFF100, "Memory"); //AIC_IVR
20 __writeMemory32(0x1000, 0xFFFFF10C, "Memory"); //AIC_IPR
21 __writeMemory32(0x2, 0xFFFFF114, "Memory"); //AIC_CISR
22 }
23
24 return 0;
25 }
26
27 setupProcessorRegisters()
28 {
29 // Write TC0_SR.CPCS with correct status for ISR (Clock enabled; RC Compare Flag = TRUE)
30 __writeMemory32(0x00010010, 0xfffa0020, "Memory");
31
32 // Set TX ready flag in USART0 status register
33 // USART0_BASE->US_CSR = AT91C_US_TXRDY
34 __writeMemory32(0x00000002, 0xfffc0014, "Memory");
35 }
36
37 configureTimer0Interrupt()
38 {
39 __var _master_clock_frequency;
40 __var _timer0_period_cycles;
41
42 // Calculate timer0 frequency in master clock cycles
43 _master_clock_frequency = 48054857;
44 _timer0_period_cycles = _master_clock_frequency / 100;
45 if((_master_clock_frequency % 100) >= 50)
46 {
47 _timer0_period_cycles++;
48 }
49
50 __cancelAllInterrupts();
51 __enableInterrupts();
52
53 _timer0_interrupt_ID = __orderInterrupt("IRQ", _timer0_period_cycles, _timer0_period_cycles, 0, 0, 0, 100);
54
55 if(-1 == _timer0_interrupt_ID)
56 {
57 __message "ERROR: failed to order timer 0 interrupt";
58 }
59
60 __setCodeBreak("0x18", 0, "irqBreak()", "TRUE", "");
61 }
62
63 execUserReset()
64 {
65 setupProcessorRegisters();
66 configureTimer0Interrupt();
67 }