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

Subversion Repositories minsoc

[/] [minsoc/] [trunk/] [sw/] [uart/] [uart.c] - Blame information for rev 2

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

Line No. Rev Author Line
1 2 rfajardo
#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);
38
    }
39
}
40
 
41
 
42
void uart_print_str(char *p)
43
{
44
        while(*p != 0) {
45
                uart_putc(*p);
46
                p++;
47
        }
48
}
49
 
50
void uart_print_long(unsigned long ul)
51
{
52
  int i;
53
  char c;
54
 
55
 
56
  uart_print_str("0x");
57
  for(i=0; i<8; i++) {
58
 
59
  c = (char) (ul>>((7-i)*4)) & 0xf;
60
  if(c >= 0x0 && c<=0x9)
61
    c += '0';
62
  else
63
    c += 'a' - 10;
64
  uart_putc(c);
65
  }
66
 
67
}
68
 
69
void uart_print_short(unsigned long ul)
70
{
71
  int i;
72
  char c;
73
  char flag=0;
74
 
75
 
76
  uart_print_str("0x");
77
  for(i=0; i<8; i++) {
78
 
79
  c = (char) (ul>>((7-i)*4)) & 0xf;
80
  if(c >= 0x0 && c<=0x9)
81
    c += '0';
82
  else
83
    c += 'a' - 10;
84
  if ((c != '0') || (i==7))
85
    flag=1;
86
  if(flag)
87
    uart_putc(c);
88
  }
89
 
90
}
91
 
92
 
93
 
94
int main()
95
{
96
        uart_init();
97
 
98
        int_init();
99
        int_add(2,&uart_interrupt);
100
 
101
        /* We can't use printf because in this simple example
102
           we don't link C library. */
103
        uart_print_str("Hello World.\n\r");
104
 
105
        report(0xdeaddead);
106
        or32_exit(0);
107
}

powered by: WebSVN 2.1.0

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