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

Subversion Repositories mips32r1

[/] [mips32r1/] [trunk/] [Software/] [demos/] [XD4_UART/] [src/] [os/] [exception_handler.c] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 ayersg
#include "drivers/lcd.h"
2
#include "drivers/piezo.h"
3
#include "drivers/monitor.h"
4
#include "drivers/uart.h"
5
 
6
void dead_loop(void)
7
{
8
        for (;;) {}
9
}
10
 
11
void mips32_handler_AdEL(void)
12
{
13
        LCD_clear();
14
        LCD_printString("AdEL");
15
        dead_loop();
16
}
17
 
18
void mips32_handler_AdES(void)
19
{
20
        LCD_clear();
21
        LCD_printString("AdES");
22
        dead_loop();
23
}
24
 
25
void mips32_handler_Bp(void)
26
{
27
        LCD_clear();
28
        LCD_printString("Bp");
29
        dead_loop();
30
}
31
 
32
void mips32_handler_CpU(void)
33
{
34
        LCD_clear();
35
        LCD_printString("CpU");
36
        dead_loop();
37
}
38
 
39
void mips32_handler_Ov(void)
40
{
41
        LCD_clear();
42
        LCD_printString("Ov");
43
        dead_loop();
44
}
45
 
46
void mips32_handler_RI(void)
47
{
48
        LCD_clear();
49
        LCD_printString("RI");
50
        dead_loop();
51
}
52
 
53
void mips32_handler_Sys(void)
54
{
55
        LCD_clear();
56
        LCD_printString("Sys");
57
        dead_loop();
58
}
59
 
60
void mips32_handler_Tr(void)
61
{
62
        LCD_clear();
63
        LCD_printString("Trap");
64
        dead_loop();
65
}
66
 
67
/* Timer */
68
void mips32_handler_HwInt5(void)
69
{
70
        static volatile char wait = 0;
71
        static volatile uint8_t cursor = 0x20;
72
 
73
        if (wait == 1) {
74
                wait++;
75
                Piezo_set(0, 0);
76
        }
77
        else if (wait < 1) {
78
                wait++;
79
        }
80
 
81
        LCD_setAutoIncr(0);
82
        LCD_printByte(cursor);
83
        LCD_setAutoIncr(1);
84
 
85
        if (cursor == 0x20) {
86
                cursor = 0xff;
87
        }
88
        else {
89
                cursor = 0x20;
90
        }
91
 
92
}
93
 
94
void mips32_handler_HwInt4(void)
95
{
96
        static volatile char count = 0;
97
 
98
        LCD_printByte(count);
99
        count++;
100
}
101
 
102
void mips32_handler_HwInt3(void)
103
{
104
        static volatile char count = 0;
105
 
106
        LCD_printByte(count);
107
        count++;
108
}
109
 
110
void mips32_handler_HwInt2(void)
111
{
112
        static volatile char count = 0;
113
 
114
        LCD_printByte(count);
115
        count++;
116
}
117
 
118
void mips32_handler_HwInt1(void)
119
{
120
        static volatile char count = 0;
121
 
122
        LCD_printByte(count);
123
        count++;
124
}
125
 
126
 
127
/* UART */
128
void mips32_handler_HwInt0(void)
129
{
130
        uint32_t recv_msg;
131
        uint32_t bytes_avail;
132
        uint8_t  read_byte;
133
 
134
        recv_msg = UART_readMessage();
135
        read_byte = (uint8_t)recv_msg;
136
        bytes_avail = (recv_msg >> 8);
137
 
138
        while (bytes_avail > 0) {
139
                if (read_byte == 0x7f) {  // delete
140
                        LCD_setAutoIncr(0);
141
                        LCD_printByte(0x20);
142
                        LCD_setPos(LCD_getPos()-1);
143
                        LCD_setAutoIncr(1);
144
                }
145
                else {
146
                        LCD_printByte(read_byte);
147
                }
148
                bytes_avail--;
149
                read_byte = UART_readByte();
150
        }
151
}
152
 
153
void mips32_handler_SwInt1(void)
154
{
155
        static volatile char count = 0;
156
 
157
        LCD_printByte(count);
158
        count++;
159
}
160
 
161
void mips32_handler_SwInt0(void)
162
{
163
        static volatile char count = 0;
164
 
165
        LCD_printByte(count);
166
        count++;
167
}
168
 

powered by: WebSVN 2.1.0

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