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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
/* M68HC11/M68HC12 serial line operations
* Copyright (C) 1999, 2001, 2003, 2004 Stephane Carrez (stcarrez@nerim.fr)
*
* The authors hereby grant permission to use, copy, modify, distribute,
* and license this software and its documentation for any purpose, provided
* that existing copyright notices are retained in all copies and that this
* notice is included verbatim in any distributions. No written agreement,
* license, or royalty fee is required for any of the authorized uses.
* Modifications to this software may be copyrighted by their authors
* and need not follow the licensing terms described here, provided that
* the new terms are clearly indicated on the first page of each file where
* they apply.
*/
#ifdef __HAVE_SHORT_INT__
.mode mshort
#else
.mode mlong
#endif
#if defined(__USE_RTC__)
.macro ret
#if defined(mc68hc12)
rtc
#else
jmp __return_32
#endif
.endm
#else
.macro ret
rts
.endm
#endif
#ifdef mc68hc12
SC0CR1 = 0xC2
SC0CR2 = 0xC3
SC0SR1 = 0xC4
SC0DRL = 0xC7
SC0BD = 0xC0
.sect .data
.globl _m68hc12_ports
_m68hc12_ports: .word 0
.sect .text
.globl outbyte
;;;
;;; int outbyte(char c);
;;;
;;; B : Character to send
;;;
outbyte:
bsr _sci_init
L1:
ldaa SC0SR1,x
bge L1
stab SC0DRL,x
ldab SC0CR2,x
orab #0x8
stab SC0CR2,x
ret
.sect .text
.globl inbyte
;;;
;;; char inbyte(void);
;;;
inbyte:
bsr _sci_init
ldaa SC0SR1,x
bita #0x20
beq inbyte
ldab SC0CR2,x
ret
.globl _sci_init
.sect .text
_sci_init:
ldx _m68hc12_ports
beq do_init
dex
rts
do_init:
ldx #0x1
stx _m68hc12_ports
dex
ldd #26
std SC0BD,x
ldaa #0
staa SC0CR1,x
ldaa #0xC
staa SC0CR2,x
rts
#else
BAUD = 0x2b
SCCR1= 0x2c
SCCR2= 0x2d
SCSR = 0x2e
SCDR = 0x2f
.sect .data
.globl _m68hc11_ports
_m68hc11_ports: .word 0
.sect .text
.globl outbyte
;;;
;;; int outbyte(char c);
;;;
;;; B : Character to send
;;;
outbyte:
bsr _sci_init
L1:
ldaa SCSR,x
bge L1
stab SCDR,x
ldab SCCR2,x
orab #0x8
stab SCCR2,x
ret
.sect .text
.globl inbyte
;;;
;;; char inbyte(void);
;;;
inbyte:
bsr _sci_init
ldaa SCSR,x
bita #0x20
beq inbyte
ldab SCDR,x
ret
.globl _sci_init
.sect .text
_sci_init:
ldx _m68hc11_ports
beq do_init
rts
do_init:
ldx #0x1000
stx _m68hc11_ports
ldaa #0x30
staa BAUD,x
clra
staa SCCR1,x
ldaa #0xC
staa SCCR2,x
rts
#endif
|