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

Subversion Repositories test_project

[/] [test_project/] [trunk/] [sw/] [uart/] [uart.c] - Blame information for rev 54

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

Line No. Rev Author Line
1 25 julius
#include "../support/support.h"
2
#include "../support/board.h"
3 52 julius
#include "../support/uart.h"
4 25 julius
 
5 52 julius
void uart_print_str(char *);
6
void uart_print_long(unsigned long);
7 25 julius
 
8 52 julius
// Dummy or32 except vectors
9
void buserr_except(){}
10
void dpf_except(){}
11
void ipf_except(){}
12
void lpint_except(){}
13
void align_except(){}
14
void illegal_except(){}
15
void hpint_except(){}
16
void dtlbmiss_except(){}
17
void itlbmiss_except(){}
18
void range_except(){}
19
void syscall_except(){}
20
void res1_except(){}
21
void trap_except(){}
22
void res2_except(){}
23 25 julius
 
24
 
25
void uart_print_str(char *p)
26
{
27
        while(*p != 0) {
28
                uart_putc(*p);
29
                p++;
30
        }
31
}
32
 
33
void uart_print_long(unsigned long ul)
34
{
35
  int i;
36
  char c;
37
 
38
 
39
  uart_print_str("0x");
40
  for(i=0; i<8; i++) {
41
 
42
  c = (char) (ul>>((7-i)*4)) & 0xf;
43
  if(c >= 0x0 && c<=0x9)
44
    c += '0';
45
  else
46
    c += 'a' - 10;
47
  uart_putc(c);
48
  }
49
 
50
}
51
 
52
void uart_print_short(unsigned long ul)
53
{
54
  int i;
55
  char c;
56
  char flag=0;
57
 
58
 
59
  uart_print_str("0x");
60
  for(i=0; i<8; i++) {
61
 
62
  c = (char) (ul>>((7-i)*4)) & 0xf;
63
  if(c >= 0x0 && c<=0x9)
64
    c += '0';
65
  else
66
    c += 'a' - 10;
67
  if ((c != '0') || (i==7))
68
    flag=1;
69
  if(flag)
70
    uart_putc(c);
71
  }
72
 
73
}
74
 
75
 
76
 
77
int main()
78
{
79
        uart_init();
80
 
81
        /* We can't use printf because in this simple example
82
           we don't link C library. */
83
        uart_print_str("Hello World.\n\r");
84
 
85
        report(0xdeaddead);
86 52 julius
        or32_exit(0);
87 25 julius
}

powered by: WebSVN 2.1.0

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