Subversion Repositories MB01 Project

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 - 1
	NOLIST
2
 
3
	CONFIG	OSC = EC
4
	CONFIG	FCMEN = OFF
5
	CONFIG	IESO = OFF
6
	CONFIG	PWRT = ON
7
	CONFIG	BOREN = ON, BORV = 3
8
	CONFIG	WDT = OFF
9
	CONFIG	MCLRE = ON
10
	CONFIG	PBADEN = OFF
11
	CONFIG	LVP = OFF
12
	CONFIG	CCP2MX = PORTC
13
	CONFIG	LPT1OSC = OFF
14
	CONFIG	STVREN = ON
15
	CONFIG	XINST = OFF
16
 
17
KBD_BAT			EQU		0xAA	; BAT tastiera OK
18
KBD_NOBAT		EQU		0xFC	; BAT tastiera fallito
19
KBD_ECHO		EQU		0xEE	; comando ECHO
20
KBD_ACK			EQU		0xFA	; ACK da tastiera
21
KBD_GETID		EQU		0xF2	; comando GET ID tastiera
22
KBD_IDL			EQU		0xAB	; ID tastiera
23
KBD_IDH			EQU		0x83
24
KBD_SETLED		EQU		0xED	; comando LED
25
KBD_ENABLE		EQU		0xF4	; abilita tastiera
26
KBD_SETSC		EQU		0xF0	; abilita scancode
27
KBD_TYPERATE	EQU		0xF3	; imposta typerate
28
KBD_RESEND		EQU		0xFE	; comando re-invio
29
KBD_RESET		EQU		0xFF	; comando reset
30
KBD_DEFRATE		EQU		B'00001011'		; default 250ms - 10.9/sec
31
KBD_DEFRATE2	EQU		B'00110111'		; secondario 500ms - 4/sec
32
 
33
KBD_BRK			EQU		0xF0	; break scan code
34
KBD_EXT			EQU		0xE0	; scan code esteso
35
KBD_EXT1		EQU		0xE1	; scan code esteso 1
36
 
37
 
38
; bit porta A
39
HLINT		EQU		RA0		; stato linea IRQ HOST
40
HLNMI		EQU		RA1		; stato linea NMI HOST
41
 
42
; bit PORTA B
43
KDATAIN		EQU		RB0
44
HDRQIN		EQU		RB1
45
RESIN		EQU		RB2
46
KCLKIN		EQU		RB3
47
KCLKO		EQU		RB4
48
KDATAO		EQU		RB5
49
 
50
RBMASK		EQU		B'00001101'
51
 
52
; bit PORTA C
53
KFRRD		EQU		RC0		; LOW -> lettura file reg
54
KFRWE		EQU		RC1		; LOW -> scrittura file reg
55
 
56
KFRSRP		EQU		RC3		; LOW -> clear linea DRQ
57
KFRSSN		EQU		RC4		; LOW -> set linea NMI
58
KFRSSI		EQU		RC5		; LOW -> set linea INT
59
KBVOFF		EQU		RC6		; LOW -> VCC tastiera OFF
60
KBVON		EQU		RC7		; LOW -> VCC tastiera ON
61
 
62
KRESET		EQU		H'000'	; KStatus<0> -> RESET
63
KTIMEO 		EQU		H'001'	; KStatus<1> -> TIMEOUT
64
KPARY 		EQU		H'002'	; KStatus<2> -> PARITY ERROR (RX)
65
KSTOP 		EQU		H'003'	; KStatus<3> -> BIT STOP ERROR (RX)
66
KBACK		EQU		H'004'	; KStatus<4> -> ACK BIT ERROR (TX)
67
KBTX		EQU		H'006'	; KStatus<6> -> TRASMISSIONE COMPLETA (TX)
68
KBRX		EQU		H'007'	; KStatus<7> -> RICEZIONE COMPLETA (RX)
69
 
70
KBRXERR		EQU		B'0001100'
71
 
72
TMR0P4		EQU		B'00000001'	; TMR0 stop, prescaler = 4, 16 bit
73
TMR0P0		EQU		B'00001000'	; TMR0 stop, no prescaler, 16 bit
74
TMR0P256	EQU		B'00000111'	; TMR0 stop, prescaler = 256, 16 bit
75
 
76
#define		bmi		bn
77
#define		bpl		bnn
78
 
79
;---- MACRO ---------------------------------------------------------------
80
 
81
ldw	macro	f               ; Carica registro W da registro file
82
	movf	f, w
83
	endm
84
 
85
SCLOCKL		macro
86
	bcf		LATB, KCLKO
87
			endm
88
 
89
SCLOCKH		macro
90
	bsf		LATB, KCLKO
91
			endm
92
 
93
SDATAL		macro
94
	bcf		LATB, KDATAO
95
			endm
96
 
97
SDATAH		macro
98
	bsf		LATB, KDATAO
99
			endm
100
 
101
; count in ms per TMR0 con prescaler = 4 e clock = 20MHz (periodo 800ns)
102
; max. count = 52ms
103
#define	CNTTMR0(count)		(0x10000 - ((count * D'1250')))
104
 
105
; counter in us per TMR0 (no prescaler, clock 20MHz, TCYCLE = 200ns)
106
; max. counter = 13100us
107
#define CNTUSTMR0(count)	(0x10000 - (count * 5))
108
 
109
; count in ms per TMR0 con prescaler = 256 e clock = 20MHz (periodo 51.2us)
110
; max. count = 3355ms, minimo 1ms
111
#define	CNTMSTMR0(count)	(0x10000 - ((count * D'625')) / D'32')
112
 
113
T20MS		EQU		CNTTMR0(D'20')		; counter 20ms
114
T40MS		EQU		CNTTMR0(D'40')		; counter 40ms
115
T20US		EQU		CNTUSTMR0(D'20')	; counter 20us (no prescaler)
116
T100US		EQU		CNTUSTMR0(D'100')	; counter 100us (no prescaler)
117
T1500MS		EQU		CNTMSTMR0(D'1500')	; counter 1500ms (prescaler = 256)
118
 
119
 
120
;---- REGISTRI ------------------------------------------------------------
121
 
122
RamVars		udata_acs	0x000
123
KbdIDL		res	1						; ID tastiera
124
KbdIDH		res	1
125
KFRFlag		res	1
126
KFRRdCnt	res	1
127
KFRRd0		res	1
128
KFRRd1		res	1
129
KFRRd2		res	1
130
KFRRd3		res	1
131
E1PtrL		res	1						; puntatore tab. sequenza tasto PAUSE
132
E1PtrH		res	1
133
E1Cnt		res	1						; contatore sequenza E1
134
RxData		res	1						; temp: byte letto da coda RX
135
RxCnt		res	1						; numero bytes buffer di ricezione
136
RxFlag		res	1						; flag status buffer ricezione
137
TxHeadL		res	1						; puntatore corrente Head a buffer TX
138
TxHeadH		res	1
139
TxTailL		res	1						; puntatore corrente Tail a buffer TX
140
TxTailH		res	1
141
TxFlag		res	1						; flag operazioni TX
142
TxCnt		res	1						; contatore word nel buffer TX
143
TxData0		res	1						; primo byte codice tasto
144
TxData1		res	1						; secondo byte codice tasto
145
T0CntL		res	1						; valore contatore per TMR0
146
T0CntH		res	1
147
KCnt		res	1						; utilizzati da RxKeyb e TxKeyb
148
KPar		res	1
149
KStatus		res	1
150
KBuf		res	1
151
TmpB		res	1
152
KbdFlag		res	1						; flag tastiera
153
KbdFlag2	res	1						; flag secondario tastiera
154
RxCode		res	1						; codice scansione rilocato
155
ShfSt		res	1						; stato tasto SHIFT
156
TglSt		res	1						; stato tasti toggle
157
CtlSt		res	1						; stato tasti CTRL/ALT
158
TCtlSt		res	1
159
TShfSt		res	1
160
LockSt		res	1
161
LedSt		res	1
162
TTglSt		res	1
163
TLockSt		res	1
164
TPortB		res	1
165
RptSt		res	1
166
MapCfg		res	1
167
Caps		res	1
168
 
169
 
170
;S_Temp		res	1						; salva registri in ISR LOW
171
;W_Temp		res	1
172
 
173
;RxExt		res	1
174
;RxExt1		res	1
175
;RxBrk		res	1
176
;RxE1		res	1
177
 
178
;RamBuf1		udata_acs	0x040
179
;RxBuffer	res			0x040
180
 
181
;RamBuf2		udata		0x080
182
;RxBuffer2	res			0x080
183
 
184
;RamBuf3		udata		0x100
185
;TxBuffer	res			0x100
186
 
187
;RamBuf4		udata		0x200
188
;TxBuffer2	res			0x0F0
189
;TxBufEnd	res			1
190
 
191
;RXBUFLEN	EQU			(0x40 + 0x80)
192
;TXBUFLEN	EQU			(0x100 + 0x0F0)
193
 
194
 
195
; bit di TxFlag
196
TXOVR		EQU		H'007'				; overrun buffer TX
197
SKPCTLB		EQU		H'006'				; skip CTRL tasti speciali
198
SKPALTB		EQU		H'005'				; skip ALT tasti speciali
199
SKPSHFB		EQU		H'004'				; skip SHIFT tasti speciali
200
 
201
SKPALL		EQU		B'01110000'			; maschera skip-all
202
 
203
; bit di RxFlag
204
RXOVR		EQU		H'007'				; overrun buffer RX
205
RXBRK		EQU		H'006'				; pending break codice
206
RXEXT		EQU		H'005'				; pending E0 scan code esteso
207
RXEXT1		EQU		H'004'				; pending E1 scan code (tasto PAUSE)
208
RXE1ERR		EQU		H'003'				; errore sequenza E1
209
 
210
RXMASK		EQU		B'10000000'			; maschera azzeramento flag
211
E1SEQCNT	EQU		D'7'				; numero bytes sequenza E1
212
 
213
; bit di KbdFlag
214
KBFND		EQU		H'007'
215
KBBAT		EQU		H'006'
216
KBVID		EQU		H'005'
217
KBBAT2		EQU		H'004'
218
KBRATE		EQU		H'003'
219
KBENABLE	EQU		H'002'
220
KBSCOK		EQU		H'001'
221
KBLEDOK		EQU		H'000'
222
 
223
; bit di KbdFlag2
224
KBNOBAT		EQU		H'007'
225
 
226
; bit di KFRFlag
227
KFRFULL		EQU		H'007'
228
 
229
; bit di CtlSt
230
LSHFB		EQU		H'000'			; L-SHIFT
231
LCTLB		EQU		H'001'			; L-CTRL
232
LALTB		EQU		H'002'			; L-ALT
233
RSHFB		EQU		H'003'			; R-SHIFT
234
RCTLB		EQU		H'004'			; R-CTRL
235
RALTB		EQU		H'005'			; R-ALT
236
ACTLB		EQU		H'006'			; L-CTRL OR R-CTRL
237
AALTB		EQU		H'007'			; L-ALT OR R-ALT
238
 
239
; maschera bit CtlSt
240
LSHFM		EQU		B'00000001'		; L-SHIFT
241
LCTLM		EQU		B'00000010'		; L-CTRL
242
LALTM		EQU		B'00000100'		; L-ALT
243
RSHFM		EQU		B'00001000'		; R-SHIFT
244
RCTLM		EQU		B'00010000'		; R-CTRL
245
RALTM		EQU		B'00100000'		; R-ALT
246
ACTLM		EQU		B'01000000'		; L-CTRL OR R-CTRL
247
AALTM		EQU		B'10000000'		; L-ALT OR R-ALT
248
 
249
; maschera bit test CtlSt
250
SHIFTKM		EQU		(LSHFM | RSHFM)
251
CTRLKM		EQU		(LCTLM | RCTLM)
252
ALTKM		EQU		(LALTM | RALTM)
253
ALLALTCTLM	EQU		(ACTLM | AALTM)
254
 
255
; bit di ShfSt
256
ASHFB		EQU		H'007'			; L-SHIFT OR R-SHIFT
257
ALTCTLB		EQU		H'006'			; L-CTRL OR R-CTRL OR L-ALT OR R-ALT
258
 
259
 
260
; maschera bit ShfSt
261
ASHFM		EQU		B'10000000'		; L-SHIT OR R-SHIFT
262
ALTCTLM		EQU		B'01000000'		; L-CTRL OR R-CTRL OR L-ALT OR R-ALT
263
 
264
SHFALL		EQU		(ASHFM | ALTCTLM)
265
 
266
; bit di TglSt e LockSt (eccetto PAUSB)
267
CAPSB		EQU		H'007'			; CAPS-LOCK toggle bit
268
NUMLB		EQU		H'006'			; NUM-LOCK toggle bit
269
SCRLB		EQU		H'005'			; SCROLL-LOCK toggle bit
270
PAUSB		EQU		H'004'			; tasto PAUSE toggle bit
271
INSTB		EQU		H'002'			; bit stato per toggle INSERT
272
;INSB		EQU		H'002'			; bit stato per INSERT
273
ESCB		EQU		H'001'			; bit stato per ESC
274
PRNSCB		EQU		H'000'			; bit stato per PRINT SCRN
275
 
276
; maschera bit TglSt
277
CAPSM		EQU		B'10000000'		; CAPS-LOCK toggle bit
278
NUMLM		EQU		B'01000000'		; CAPS-LOCK toggle bit
279
SCRLM		EQU		B'00100000'		; SCROLL-LOCK toggle bit
280
PAUSM		EQU		B'00010000'		; tasto PAUSE toggle bit
281
INSTM		EQU		B'00000100'		; maschera bit toggle INSERT
282
;INSM		EQU		B'00000100'		; maschera bit INSERT
283
ESCM		EQU		B'00000010'		; maschera bit ESC
284
PRNSCM		EQU		B'00000001'		; maschera bit PRINT SCRN
285
 
286
; maschera bit tasti NO-REPEAT - RptSt
287
PWRM		EQU		B'10000000'		; POWER
288
SLEEPM		EQU		B'01000000'		; SLEEP
289
WAKEM		EQU		B'00100000'		; WAKE UP
290
LGUIM		EQU		B'00010000'		; L-GUI
291
RGUIM		EQU		B'00001000'		; R-GUI
292
GUIAPPM		EQU		B'00000100'		; GUI APP
293
ESCAPEM		EQU		B'00000010'		; ESC
294
PRINTM		EQU		B'00000001'		; PRINT SCRN
295
 
296
ESCPRNM		EQU		(ESCM | PRNSCM)
297
 
298
; bit di MapCfg
299
MAPITB		EQU		H'007'			; mappa IT
300
MAPALPHA	EQU		H'006'			; flag lettera alfabetica
301
 
302
;FLAGSND		EQU		B'10000000'		; invia flag
303
;TOGGLESND	EQU		B'10010000'		; invia toggle
304
;EXTTGLSND	EQU		B'10110000'		; invia tasto controllo + toggle low
305
 
306
; bit di TxData0
307
KEYCTL		EQU		H'007'			; bit codice di controllo/ASCII
308
KEYRLS		EQU		H'006'			; bit tasto rilasciato
309
KEYCTL2		EQU		H'005'			; bit codice di controllo/flag
310
KEYTGL		EQU		H'004'			; bit invio toggle low (4 bit)
311
 
312
; top RAM
313
#ifdef __DEBUG
314
TOPRAM		EQU		0x2F2
315
#else
316
TOPRAM		EQU		0x300
317
#endif
318
 
319
RXBUFLEN	EQU		0xFE					; dimensione buffer RX
320
RxBuffer	EQU		0x040					; start buffer RX
321
RxBufEnd	EQU		(RxBuffer + RXBUFLEN)	; end buffer RX + 1
322
TxBuffer	EQU		(RxBufEnd)				; start buffer TX
323
TxBufEnd	EQU		TOPRAM					; fine buffer TX + 1
324
TXBUFLEN	EQU		(TxBufEnd - TxBuffer)	; dimensione buffer TX
325
TXMAXCNT	EQU		(TXBUFLEN / 2)			; dimensione buffer TX in word
326
 
327
	LIST