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

Subversion Repositories mips_enhanced

[/] [mips_enhanced/] [trunk/] [grlib-gpl-1.0.19-b3188/] [software/] [leon3/] [hpi_functions.c] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dimamali
#include "hpi_defs.h"
2
#include "hpi_functions.h"
3
 
4
 
5
//#define outw(a,b)     WRITE_REGISTER_USHORT( (unsigned short *)b, ((unsigned short)a) )
6
//#define inw(b)                READ_REGISTER_USHORT( (unsigned short *)b)
7
 
8
inline void kill_time(int num) {
9
  int i;
10
 
11
  for(i=0; i<num; i++) {
12
    asm("nop");
13
  }
14
}
15
 
16
 
17
USHORT
18
inw( PUSHORT b )
19
{
20
    return (*(volatile PUSHORT const)b);
21
}
22
 
23
VOID
24
outw(USHORT  a, PUSHORT b)
25
{
26
    *(volatile PUSHORT const)b = a;
27
}
28
 
29
 
30
 
31
/*
32
 *  FUNCTION: lcd_hpi_write_word
33
 *
34
 *  PARAMETERS:
35
 *    chip_addr       - Offset Address of the ASIC
36
 *    value           - Value to write
37
 *    cy_private_data - Private data structure pointer
38
 *
39
 *  DESCRIPTION:
40
 *    This function writes to hpi
41
 *
42
 *  RETURNS:
43
 *    LCD_SUCCESS         - Success
44
 *    LCD_ERROR           - Failure
45
 */
46
void lcd_hpi_write_word(unsigned short chip_addr,
47
                        unsigned short value)
48
{
49
  outw (chip_addr, (USHORT*)(HPI_ADDR_ADDR + HPI_BASE));
50
 
51
  //  kill_time(5000);
52
 
53
  //  printf("\nwrite_word: writing %x to %x\n", chip_addr, (USHORT*)(HPI_ADDR_ADDR + HPI_BASE));
54
  outw (value, (USHORT*)(HPI_DATA_ADDR + HPI_BASE));
55
  //  printf("write_word: writing %x to %x\n", value, (USHORT*)(HPI_DATA_ADDR + HPI_BASE));
56
}
57
 
58
unsigned short lcd_hpi_read_status() {
59
  USHORT value;
60
 
61
  value = inw((USHORT*)(HPI_STAT_ADDR + HPI_BASE));
62
  return(value);
63
}
64
 
65
 
66
void lcd_hpi_write_mailbox(unsigned short value) {
67
  outw (value, (USHORT*)(HPI_MBX_ADDR + HPI_BASE));
68
}
69
 
70
 
71
unsigned short lcd_hpi_read_mailbox() {
72
    unsigned short value;
73
 
74
    value = inw((USHORT*)(HPI_MBX_ADDR + HPI_BASE));
75
    return(value);
76
}
77
 
78
 
79
 
80
/*
81
 *  FUNCTION: lcd_hpi_read_word
82
 *
83
 *  PARAMETERS:
84
 *    chip_addr       - Offset Address of the ASIC
85
 *    cy_private_data - Private data structure pointer
86
 *
87
 *  DESCRIPTION:
88
 *    This function reads from hpi
89
 *
90
 *  RETURNS:
91
 *    LCD_SUCCESS         - Success
92
 *    LCD_ERROR           - Failure
93
 */
94
unsigned short lcd_hpi_read_word(unsigned short chip_addr)
95
{
96
    unsigned short value;
97
 
98
 
99
    outw (chip_addr, (USHORT*)(HPI_ADDR_ADDR + HPI_BASE));
100
 
101
    //    kill_time(5000);
102
    //    printf("\nread_word: writing %x to %x\n", chip_addr, (USHORT*)(HPI_ADDR_ADDR + HPI_BASE));
103
    value = inw((USHORT*)(HPI_DATA_ADDR + HPI_BASE));
104
    //    printf("read_word: reading %x from %x\n", value, (USHORT*)(HPI_DATA_ADDR + HPI_BASE));
105
 
106
    return(value);
107
}
108
 
109
void lcd_hpi_write_words(unsigned short chip_addr,
110
                         unsigned short *data,
111
                         int num_words)
112
{
113
    int i;
114
 
115
    outw (chip_addr, (PUSHORT)(HPI_ADDR_ADDR + HPI_BASE));
116
 
117
    for (i=0; i<num_words; i++) {
118
        outw (*data++, (PUSHORT)(HPI_DATA_ADDR + HPI_BASE));
119
    }
120
}
121
 
122
/*
123
 *  FUNCTION: lcd_hpi_read_words
124
 *
125
 *  PARAMETERS:
126
 *    chip_addr       - Offset Address of the ASIC
127
 *    data            - data pointer
128
 *    num_words       - Length
129
 *    cy_private_data - Private data structure pointer
130
 *
131
 *  DESCRIPTION:
132
 *    This function reads words from hpi
133
 *
134
 *  RETURNS:
135
 *    LCD_SUCCESS         - Success
136
 *    LCD_ERROR           - Failure
137
 */
138
void lcd_hpi_read_words(unsigned short chip_addr,
139
                        unsigned short *data,
140
                        int num_words)
141
{
142
    int i;
143
 
144
    outw (chip_addr, (PUSHORT)(HPI_ADDR_ADDR + HPI_BASE));
145
    for (i=0; i<num_words; i++) {
146
        *data++ = inw ((PUSHORT)(HPI_DATA_ADDR + HPI_BASE));
147
    }
148
}
149
 

powered by: WebSVN 2.1.0

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