OpenCores
URL https://opencores.org/ocsvn/openfire2/openfire2/trunk

Subversion Repositories openfire2

[/] [openfire2/] [trunk/] [sw/] [test-int/] [sample.c] - Blame information for rev 6

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 toni32
#include "openfire.h"
2
 
3
// --- prototypes ---
4
void interrupt_handler(void) __attribute__((interrupt_handler));
5
 
6
// -------------------------------------
7
void interrupt_handler(void)
8
{
9
   uart1_printchar('.');
10
}
11
 
12
// -------------------------------------
13
void main(void)
14
{
15
  int n;
16
  uart1_printline("inicio del test\r\n");
17
 
18
  uart1_printline("setting interrupt handler\r\n");
19
  asm volatile ("la  r6, r0, interrupt_handler  \n\t" \
20
                "sw  r6, r1, r0                 \n\t" \
21
                "lhu r7, r1, r0                 \n\t" \
22
                "shi r7, r0, 0x12               \n\t" \
23
                "shi r6, r0, 0x16               \n\t" \
24
                "la  r6, r0, 0x2                \n\t" \
25
                "mts rmsr, r6                   \n\t" );
26
 
27
  uart1_printline("configure timer1\r\n");
28
  *(unsigned long *) TIMER1_PORT = TIMER1_CONTROL | 50000000L;  // pulse each 2 seconds
29
 
30
  uart1_printline("enable interrupts for timer1\r\n");
31
  *(unsigned long *) INTERRUPT_ENABLE = INTERRUPT_TIMER1;
32
 
33
  uart1_printline("working...");
34
 
35
  while(1)
36
  {
37
    for(n = 0; n < 1000000; n++);
38
    uart1_printchar('+');
39
  }
40
 
41
 
42
}
43
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.