-
Notifications
You must be signed in to change notification settings - Fork 0
/
rs232_setcontrol.c
49 lines (42 loc) · 1.65 KB
/
rs232_setcontrol.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// RS232 code for the TI-99/4A by Tursi
// You can copy this file and use it at will ;)
#include "rs232.h"
// sets the specified line format, use the RS232_CTRL_xxx bits
void rs232_setcontrol(int card, int uart, int control) {
#ifdef TI99
int rawCRU = rs232raw_getuart(card, uart);
// Note: the reset is supposed to set the bits for loading:
// control register(14), interval register (13), rx rate (12)
// and tx rate (11). The highest one set is the one that is
// loaded. But in order to allow more flexibility with this
// library, as well as to deal with incomplete emulation and
// potential new devices that also emulate a 9902, we'll just
// be very selective and not make assumptions!
__asm__ volatile (
" mov %0,r12\n" // get the rawcru address
" sbo 31\n" // reset
" sbz 21\n" // rts/cts interrupts off
" sbz 20\n" // timer ints off
" sbz 19\n" // tx int off
" sbz 18\n" // rx int off
" sbz 17\n" // clear abort/BREAK
" sbz 15\n" // clear loopback test mode
" sbo 14\n" // request to write control word
" sbz 13\n" // not request to write interval register
" sbz 12\n" // not request to write rx data rate
" sbz 11\n" // not request to write tx data rate
" swpb %1\n" // get the byte into the msb
" ldcr %1,8\n" // write it
" sbz 14\n" // and turn it off for later use
" swpb %1\n" // fix the reg in case gcc wants it
: : "r"(rawCRU), "r"(control) : "r12"
);
#endif
#ifdef COLECO
(void)control;
#endif
#ifdef GBA
(void)control;
#endif
rs232raw_deactivateCard(card);
}