Revision 263
starting uart tests
proj/include/uart.h | ||
---|---|---|
34 | 34 |
uint8_t modem_stat_int :1; |
35 | 35 |
} uart_config; |
36 | 36 |
|
37 |
int (subscribe_uart_interrupt)(uint8_t interrupt_bit, int *interrupt_id); |
|
38 |
|
|
37 | 39 |
int uart_get_config(int base_addr, uart_config *config); |
38 | 40 |
void uart_print_config(uart_config config); |
39 | 41 |
|
proj/src/interrupts_func.c | ||
---|---|---|
5 | 5 |
#include "i8254.h" |
6 | 6 |
#include "keyboard.h" |
7 | 7 |
#include "mouse.h" |
8 |
#include "uart.h" |
|
8 | 9 |
#include "utils.h" |
9 | 10 |
#include "errors.h" |
10 | 11 |
|
... | ... | |
14 | 15 |
|
15 | 16 |
static int mouse_subscribed = 0, mouse_id; |
16 | 17 |
|
18 |
static int uart_subscribed = 0, uart_id; |
|
19 |
|
|
17 | 20 |
static void (*const ih[])(void) = { timer_int_handler, |
18 | 21 |
kbc_ih, |
19 | 22 |
NULL, |
... | ... | |
96 | 99 |
return SBCR_ERROR; |
97 | 100 |
} |
98 | 101 |
|
102 |
/// UART interrupt handling |
|
103 |
uart_id = 0; |
|
104 |
uart_enable_int_rx (COM1_ADDR); |
|
105 |
uart_disable_int_tx(COM1_ADDR); |
|
106 |
if(subscribe_uart_interrupt(COM1_IRQ, &uart_id)) { |
|
107 |
printf("%s: failed to subscribe UART interrupts.\n", __func__); |
|
108 |
return SBCR_ERROR; |
|
109 |
} |
|
110 |
uart_subscribed = 1; |
|
111 |
|
|
99 | 112 |
return SUCCESS; |
100 | 113 |
} |
101 | 114 |
|
... | ... | |
141 | 154 |
mouse_subscribed = 0; |
142 | 155 |
} |
143 | 156 |
|
157 |
// Unsubscribe UART interrupts |
|
158 |
if (uart_subscribed) { |
|
159 |
if (unsubscribe_interrupt(&uart_id)) { |
|
160 |
printf("%s: failed to unsubcribe UART interrupts.\n"); |
|
161 |
r = UNSBCR_ERROR; |
|
162 |
} |
|
163 |
uart_enable_int_rx(COM1_ADDR); |
|
164 |
uart_enable_int_tx(COM1_ADDR); |
|
165 |
uart_subscribed = 0; |
|
166 |
} |
|
167 |
|
|
144 | 168 |
return r; |
145 | 169 |
} |
146 | 170 |
|
proj/src/proj.c | ||
---|---|---|
188 | 188 |
break; |
189 | 189 |
} |
190 | 190 |
break; |
191 |
#endif |
|
191 | 192 |
case KBC_IRQ: |
192 | 193 |
switch (game_state) { |
193 | 194 |
case MENU: |
... | ... | |
213 | 214 |
break; |
214 | 215 |
} |
215 | 216 |
break; |
217 |
#ifndef DIOGO |
|
216 | 218 |
case MOUSE_IRQ: |
217 | 219 |
if (counter_mouse_ih >= 3) { |
218 | 220 |
mouse_parse_packet(packet_mouse_ih, &pp); |
proj/src/uart.c | ||
---|---|---|
78 | 78 |
#define UART_GET_FRAMING_ERROR (((n)&UART_FRAMING_ERROR )>>UART_FRAMING_ERROR_POS ) |
79 | 79 |
#define UART_GET_TRANSMITTER_EMPTY(n) (((n)&UART_TRANSMITTER_EMPTY )>>UART_TRANSMITTER_EMPTY_POS ) |
80 | 80 |
|
81 |
int (subscribe_uart_interrupt)(uint8_t interrupt_bit, int *interrupt_id) { |
|
82 |
if (interrupt_id == NULL) return 1; |
|
83 |
*interrupt_id = interrupt_bit; |
|
84 |
return (sys_irqsetpolicy(COM1_IRQ, IRQ_REENABLE | IRQ_EXCLUSIVE, interrupt_id)); |
|
85 |
} |
|
86 |
|
|
81 | 87 |
static void uart_parse_config(uart_config *config){ |
82 | 88 |
/// LCR |
83 | 89 |
config->bits_per_char = UART_GET_BITS_PER_CHAR (config->lcr); |
Also available in: Unified diff