File: trs_uart.h

package info (click to toggle)
xtrs 4.9c-4
  • links: PTS
  • area: contrib
  • in suites: stretch
  • size: 2,240 kB
  • ctags: 1,430
  • sloc: ansic: 19,941; makefile: 243; csh: 132; sh: 129
file content (89 lines) | stat: -rw-r--r-- 2,979 bytes parent folder | download | duplicates (7)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/* Copyright (c) 2000, Timothy Mann */

/* This software may be copied, modified, and used for any purpose
 * without fee, provided that (1) the above copyright notice is
 * retained, and (2) modified versions are clearly marked as having
 * been modified, with the modifier's name and the date included.  */

/* Last modified on Thu May 18 00:42:46 PDT 2000 by mann */

/*
 * Emulation of the Radio Shack TRS-80 Model I/III/4/4P serial port.
 */

#include <errno.h>
#include "trs.h"
#include "trs_hard.h"

extern void trs_uart_init(int reset_button);
extern int trs_uart_check_avail();
extern int trs_uart_modem_in();
extern void trs_uart_reset_out(int value);
extern int trs_uart_switches_in();
extern void trs_uart_baud_out(int value);
extern int trs_uart_status_in();
extern void trs_uart_control_out(int value);
extern int trs_uart_data_in();
extern void trs_uart_data_out(int value);
extern char *trs_uart_name;
extern int trs_uart_switches;

#define TRS_UART_MODEM    0xE8 /* in */
#define TRS_UART_RESET    0xE8 /* out */
#define TRS_UART_SWITCHES 0xE9 /* in, model I only */
#define TRS_UART_BAUD     0xE9 /* out */
#define TRS_UART_STATUS   0xEA /* in */
#define TRS_UART_CONTROL  0xEA /* out */
#define TRS_UART_DATA     0xEB /* in/out */

/* Bits in TRS_UART_MODEM port */
#define TRS_UART_CTS      0x80
#define TRS_UART_DSR      0x40
#define TRS_UART_CD       0x20
#define TRS_UART_RI       0x10
#define TRS_UART_RCVIN    0x02

/* Bits in TRS_UART_BAUD port */
#define TRS_UART_SNDBAUD(v) (((v)&0xf0)>>4)
#define TRS_UART_RCVBAUD(v) (((v)&0x0f)>>0)
#define TRS_UART_50       0x00
#define TRS_UART_75       0x01
#define TRS_UART_110      0x02
#define TRS_UART_134      0x03
#define TRS_UART_150      0x04
#define TRS_UART_300      0x05
#define TRS_UART_600      0x06
#define TRS_UART_1200     0x07
#define TRS_UART_1800     0x08
#define TRS_UART_2000     0x09
#define TRS_UART_2400     0x0a
#define TRS_UART_3600     0x0b
#define TRS_UART_4800     0x0c
#define TRS_UART_7200     0x0d
#define TRS_UART_9600     0x0e
#define TRS_UART_19200    0x0f
#define TRS_UART_BAUD_TABLE \
  { 50.0, 75.0, 110.0, 134.5, 150.0, 300.0, 600.0, 1200.0, 1800.0, \
    2000.0, 2400.0, 3600.0, 4800.0, 7200.0, 9600.0, 19200.0 }

/* Bits in TRS_UART_STATUS port */
#define TRS_UART_RCVD     0x80
#define TRS_UART_SENT     0x40
#define TRS_UART_OVRERR   0x20
#define TRS_UART_FRMERR   0x10
#define TRS_UART_PARERR   0x08

/* Bits in TRS_UART_CONTROL port */
#define TRS_UART_EVENPAR  0x80
#define TRS_UART_WORDMASK 0x60
#define TRS_UART_WORD5    0x00
#define TRS_UART_WORD6    0x40
#define TRS_UART_WORD7    0x20
#define TRS_UART_WORD8    0x60
#define TRS_UART_WORDBITS(v) (((v)&TRS_UART_WORDMASK)>>5)
#define TRS_UART_WORDBITS_TABLE { 5, 7, 6, 8 }
#define TRS_UART_STOP2    0x10
#define TRS_UART_NOPAR    0x08
#define TRS_UART_NOTBREAK 0x04
#define TRS_UART_DTR      0x02 /* mislabelled as RTS in Model I manual */
#define TRS_UART_RTS      0x01 /* mislabelled as DTR in Model I manual */