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

Subversion Repositories wdsp

[/] [wdsp/] [trunk/] [sw/] [uart/] [uart.c] - Blame information for rev 11

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 parrado
#include "../support/support.h"
2
#include "../support/board.h"
3
#include "../support/uart.h"
4
 
5
#include "../support/spr_defs.h"
6
 
7
void uart_print_str(char *);
8
void uart_print_long(unsigned long);
9
 
10
// Dummy or32 except vectors
11
void buserr_except(){}
12
void dpf_except(){}
13
void ipf_except(){}
14
void lpint_except(){}
15
void align_except(){}
16
void illegal_except(){}
17
/*void hpint_except(){
18
 
19
}*/
20
void dtlbmiss_except(){}
21
void itlbmiss_except(){}
22
void range_except(){}
23
void syscall_except(){}
24
void res1_except(){}
25
void trap_except(){}
26
void res2_except(){}
27
 
28
 
29
void uart_interrupt()
30
{
31
    char lala;
32
    unsigned char interrupt_id;
33
    interrupt_id = REG8(UART_BASE + UART_IIR);
34
    if ( interrupt_id & UART_IIR_RDI )
35
    {
36
        lala = uart_getc();
37
        uart_putc((lala>>1)&0xff);
38
 
39
 
40
//        uart_putc('A');
41
 
42
 
43
//uart_print_short(lala);
44
 //       uart_putc('\n');
45
    }
46
}
47
 
48
 
49
void uart_print_str(char *p)
50
{
51
        while(*p != 0) {
52
                uart_putc(*p);
53
                p++;
54
        }
55
}
56
 
57
void uart_print_long(unsigned long ul)
58
{
59
  int i;
60
  char c;
61
 
62
 
63
  uart_print_str("0x");
64
  for(i=0; i<8; i++) {
65
 
66
  c = (char) (ul>>((7-i)*4)) & 0xf;
67
  if(c >= 0x0 && c<=0x9)
68
    c += '0';
69
  else
70
    c += 'a' - 10;
71
  uart_putc(c);
72
  }
73
 
74
}
75
 
76
void uart_print_short(unsigned long ul)
77
{
78
  int i;
79
  char c;
80
  char flag=0;
81
 
82
 
83
  uart_print_str("0x");
84
  for(i=0; i<8; i++) {
85
 
86
  c = (char) (ul>>((7-i)*4)) & 0xf;
87
  if(c >= 0x0 && c<=0x9)
88
    c += '0';
89
  else
90
    c += 'a' - 10;
91
  if ((c != '0') || (i==7))
92
    flag=1;
93
  if(flag)
94
    uart_putc(c);
95
  }
96
 
97
}
98
 
99
 
100
 
101
int main()
102
{
103
int c,k,j,r_in,r_out;
104
        uart_init();
105
 
106
        int_init();
107
        int_add(UART_IRQ,&uart_interrupt);
108
 
109
uart_print_str("Hola\n");
110
 
111
        //report(0xdeaddead);
112
        //or32_exit(0);
113
 
114
 
115
        k=0;r_in=15;
116
        while(1){
117
//      uart_print_str("OpenRISC Printing: ");
118
//              uart_print_short(k++);
119
//              uart_putc('\n');
120
                REG32(0x94000000)=r_in;
121
                r_out=REG32(0x94000000);
122
                uart_print_short(r_out);
123
                uart_putc('\n');
124
        }
125
 
126
 
127
        report(0xdeaddead);
128
        or32_exit(0);
129
}

powered by: WebSVN 2.1.0

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