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

Subversion Repositories minsoc

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

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

Line No. Rev Author Line
1 36 rfajardo
#include "../support/board.h"
2
#include "../support/support.h"
3
#include "../support/uart.h"
4
#include "uart.h"
5
 
6
void uart_interrupt()
7
{
8
    char lala;
9
    unsigned char interrupt_id;
10
    interrupt_id = REG8(UART_BASE + UART_IIR);
11
    if ( interrupt_id & UART_IIR_RDI )
12
    {
13
        lala = uart_getc();
14
        uart_putc(lala+1);
15
    }
16
 
17
}
18
 
19
void uart_print_str(char *p)
20
{
21
        while(*p != 0) {
22
                uart_putc(*p);
23
                p++;
24
        }
25
}
26
 
27
void uart_print_long(unsigned long ul)
28
{
29
  int i;
30
  char c;
31
 
32
 
33
  uart_print_str("0x");
34
  for(i=0; i<8; i++) {
35
 
36
  c = (char) (ul>>((7-i)*4)) & 0xf;
37
  if(c >= 0x0 && c<=0x9)
38
    c += '0';
39
  else
40
    c += 'a' - 10;
41
  uart_putc(c);
42
  }
43
 
44
}
45
 
46
void uart_print_short(unsigned long ul)
47
{
48
  int i;
49
  char c;
50
  char flag=0;
51
 
52
 
53
  uart_print_str("0x");
54
  for(i=0; i<8; i++) {
55
 
56
  c = (char) (ul>>((7-i)*4)) & 0xf;
57
  if(c >= 0x0 && c<=0x9)
58
    c += '0';
59
  else
60
    c += 'a' - 10;
61
  if ((c != '0') || (i==7))
62
    flag=1;
63
  if(flag)
64
    uart_putc(c);
65
  }
66
 
67
}
68
 

powered by: WebSVN 2.1.0

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