Blame | Last modification | View Log | Download | RSS feed
NOLIST
CONFIG OSC = EC
CONFIG FCMEN = OFF
CONFIG IESO = OFF
CONFIG PWRT = ON
CONFIG BOREN = ON, BORV = 3
CONFIG WDT = OFF
CONFIG MCLRE = ON
CONFIG PBADEN = OFF
CONFIG LVP = OFF
CONFIG CCP2MX = PORTC
CONFIG LPT1OSC = OFF
CONFIG STVREN = ON
CONFIG XINST = OFF
KBD_BAT EQU 0xAA ; BAT tastiera OK
KBD_NOBAT EQU 0xFC ; BAT tastiera fallito
KBD_ECHO EQU 0xEE ; comando ECHO
KBD_ACK EQU 0xFA ; ACK da tastiera
KBD_GETID EQU 0xF2 ; comando GET ID tastiera
KBD_IDL EQU 0xAB ; ID tastiera
KBD_IDH EQU 0x83
KBD_SETLED EQU 0xED ; comando LED
KBD_ENABLE EQU 0xF4 ; abilita tastiera
KBD_SETSC EQU 0xF0 ; abilita scancode
KBD_TYPERATE EQU 0xF3 ; imposta typerate
KBD_RESEND EQU 0xFE ; comando re-invio
KBD_RESET EQU 0xFF ; comando reset
KBD_DEFRATE EQU B'00001011' ; default 250ms - 10.9/sec
KBD_DEFRATE2 EQU B'00110111' ; secondario 500ms - 4/sec
KBD_BRK EQU 0xF0 ; break scan code
KBD_EXT EQU 0xE0 ; scan code esteso
KBD_EXT1 EQU 0xE1 ; scan code esteso 1
; bit porta A
HLINT EQU RA0 ; stato linea IRQ HOST
HLNMI EQU RA1 ; stato linea NMI HOST
; bit PORTA B
KDATAIN EQU RB0
HDRQIN EQU RB1
RESIN EQU RB2
KCLKIN EQU RB3
KCLKO EQU RB4
KDATAO EQU RB5
RBMASK EQU B'00001101'
; bit PORTA C
KFRRD EQU RC0 ; LOW -> lettura file reg
KFRWE EQU RC1 ; LOW -> scrittura file reg
KFRSRP EQU RC3 ; LOW -> clear linea DRQ
KFRSSN EQU RC4 ; LOW -> set linea NMI
KFRSSI EQU RC5 ; LOW -> set linea INT
KBVOFF EQU RC6 ; LOW -> VCC tastiera OFF
KBVON EQU RC7 ; LOW -> VCC tastiera ON
KRESET EQU H'000' ; KStatus<0> -> RESET
KTIMEO EQU H'001' ; KStatus<1> -> TIMEOUT
KPARY EQU H'002' ; KStatus<2> -> PARITY ERROR (RX)
KSTOP EQU H'003' ; KStatus<3> -> BIT STOP ERROR (RX)
KBACK EQU H'004' ; KStatus<4> -> ACK BIT ERROR (TX)
KBTX EQU H'006' ; KStatus<6> -> TRASMISSIONE COMPLETA (TX)
KBRX EQU H'007' ; KStatus<7> -> RICEZIONE COMPLETA (RX)
KBRXERR EQU B'0001100'
TMR0P4 EQU B'00000001' ; TMR0 stop, prescaler = 4, 16 bit
TMR0P0 EQU B'00001000' ; TMR0 stop, no prescaler, 16 bit
TMR0P256 EQU B'00000111' ; TMR0 stop, prescaler = 256, 16 bit
#define bmi bn
#define bpl bnn
;---- MACRO ---------------------------------------------------------------
ldw macro f ; Carica registro W da registro file
movf f, w
endm
SCLOCKL macro
bcf LATB, KCLKO
endm
SCLOCKH macro
bsf LATB, KCLKO
endm
SDATAL macro
bcf LATB, KDATAO
endm
SDATAH macro
bsf LATB, KDATAO
endm
; count in ms per TMR0 con prescaler = 4 e clock = 20MHz (periodo 800ns)
; max. count = 52ms
#define CNTTMR0(count) (0x10000 - ((count * D'1250')))
; counter in us per TMR0 (no prescaler, clock 20MHz, TCYCLE = 200ns)
; max. counter = 13100us
#define CNTUSTMR0(count) (0x10000 - (count * 5))
; count in ms per TMR0 con prescaler = 256 e clock = 20MHz (periodo 51.2us)
; max. count = 3355ms, minimo 1ms
#define CNTMSTMR0(count) (0x10000 - ((count * D'625')) / D'32')
T20MS EQU CNTTMR0(D'20') ; counter 20ms
T40MS EQU CNTTMR0(D'40') ; counter 40ms
T20US EQU CNTUSTMR0(D'20') ; counter 20us (no prescaler)
T100US EQU CNTUSTMR0(D'100') ; counter 100us (no prescaler)
T1500MS EQU CNTMSTMR0(D'1500') ; counter 1500ms (prescaler = 256)
;---- REGISTRI ------------------------------------------------------------
RamVars udata_acs 0x000
KbdIDL res 1 ; ID tastiera
KbdIDH res 1
KFRFlag res 1
KFRRdCnt res 1
KFRRd0 res 1
KFRRd1 res 1
KFRRd2 res 1
KFRRd3 res 1
E1PtrL res 1 ; puntatore tab. sequenza tasto PAUSE
E1PtrH res 1
E1Cnt res 1 ; contatore sequenza E1
RxData res 1 ; temp: byte letto da coda RX
RxCnt res 1 ; numero bytes buffer di ricezione
RxFlag res 1 ; flag status buffer ricezione
TxHeadL res 1 ; puntatore corrente Head a buffer TX
TxHeadH res 1
TxTailL res 1 ; puntatore corrente Tail a buffer TX
TxTailH res 1
TxFlag res 1 ; flag operazioni TX
TxCnt res 1 ; contatore word nel buffer TX
TxData0 res 1 ; primo byte codice tasto
TxData1 res 1 ; secondo byte codice tasto
T0CntL res 1 ; valore contatore per TMR0
T0CntH res 1
KCnt res 1 ; utilizzati da RxKeyb e TxKeyb
KPar res 1
KStatus res 1
KBuf res 1
TmpB res 1
KbdFlag res 1 ; flag tastiera
KbdFlag2 res 1 ; flag secondario tastiera
RxCode res 1 ; codice scansione rilocato
ShfSt res 1 ; stato tasto SHIFT
TglSt res 1 ; stato tasti toggle
CtlSt res 1 ; stato tasti CTRL/ALT
TCtlSt res 1
TShfSt res 1
LockSt res 1
LedSt res 1
TTglSt res 1
TLockSt res 1
TPortB res 1
RptSt res 1
MapCfg res 1
Caps res 1
;S_Temp res 1 ; salva registri in ISR LOW
;W_Temp res 1
;RxExt res 1
;RxExt1 res 1
;RxBrk res 1
;RxE1 res 1
;RamBuf1 udata_acs 0x040
;RxBuffer res 0x040
;RamBuf2 udata 0x080
;RxBuffer2 res 0x080
;RamBuf3 udata 0x100
;TxBuffer res 0x100
;RamBuf4 udata 0x200
;TxBuffer2 res 0x0F0
;TxBufEnd res 1
;RXBUFLEN EQU (0x40 + 0x80)
;TXBUFLEN EQU (0x100 + 0x0F0)
; bit di TxFlag
TXOVR EQU H'007' ; overrun buffer TX
SKPCTLB EQU H'006' ; skip CTRL tasti speciali
SKPALTB EQU H'005' ; skip ALT tasti speciali
SKPSHFB EQU H'004' ; skip SHIFT tasti speciali
SKPALL EQU B'01110000' ; maschera skip-all
; bit di RxFlag
RXOVR EQU H'007' ; overrun buffer RX
RXBRK EQU H'006' ; pending break codice
RXEXT EQU H'005' ; pending E0 scan code esteso
RXEXT1 EQU H'004' ; pending E1 scan code (tasto PAUSE)
RXE1ERR EQU H'003' ; errore sequenza E1
RXMASK EQU B'10000000' ; maschera azzeramento flag
E1SEQCNT EQU D'7' ; numero bytes sequenza E1
; bit di KbdFlag
KBFND EQU H'007'
KBBAT EQU H'006'
KBVID EQU H'005'
KBBAT2 EQU H'004'
KBRATE EQU H'003'
KBENABLE EQU H'002'
KBSCOK EQU H'001'
KBLEDOK EQU H'000'
; bit di KbdFlag2
KBNOBAT EQU H'007'
; bit di KFRFlag
KFRFULL EQU H'007'
; bit di CtlSt
LSHFB EQU H'000' ; L-SHIFT
LCTLB EQU H'001' ; L-CTRL
LALTB EQU H'002' ; L-ALT
RSHFB EQU H'003' ; R-SHIFT
RCTLB EQU H'004' ; R-CTRL
RALTB EQU H'005' ; R-ALT
ACTLB EQU H'006' ; L-CTRL OR R-CTRL
AALTB EQU H'007' ; L-ALT OR R-ALT
; maschera bit CtlSt
LSHFM EQU B'00000001' ; L-SHIFT
LCTLM EQU B'00000010' ; L-CTRL
LALTM EQU B'00000100' ; L-ALT
RSHFM EQU B'00001000' ; R-SHIFT
RCTLM EQU B'00010000' ; R-CTRL
RALTM EQU B'00100000' ; R-ALT
ACTLM EQU B'01000000' ; L-CTRL OR R-CTRL
AALTM EQU B'10000000' ; L-ALT OR R-ALT
; maschera bit test CtlSt
SHIFTKM EQU (LSHFM | RSHFM)
CTRLKM EQU (LCTLM | RCTLM)
ALTKM EQU (LALTM | RALTM)
ALLALTCTLM EQU (ACTLM | AALTM)
; bit di ShfSt
ASHFB EQU H'007' ; L-SHIFT OR R-SHIFT
ALTCTLB EQU H'006' ; L-CTRL OR R-CTRL OR L-ALT OR R-ALT
; maschera bit ShfSt
ASHFM EQU B'10000000' ; L-SHIT OR R-SHIFT
ALTCTLM EQU B'01000000' ; L-CTRL OR R-CTRL OR L-ALT OR R-ALT
SHFALL EQU (ASHFM | ALTCTLM)
; bit di TglSt e LockSt (eccetto PAUSB)
CAPSB EQU H'007' ; CAPS-LOCK toggle bit
NUMLB EQU H'006' ; NUM-LOCK toggle bit
SCRLB EQU H'005' ; SCROLL-LOCK toggle bit
PAUSB EQU H'004' ; tasto PAUSE toggle bit
INSTB EQU H'002' ; bit stato per toggle INSERT
;INSB EQU H'002' ; bit stato per INSERT
ESCB EQU H'001' ; bit stato per ESC
PRNSCB EQU H'000' ; bit stato per PRINT SCRN
; maschera bit TglSt
CAPSM EQU B'10000000' ; CAPS-LOCK toggle bit
NUMLM EQU B'01000000' ; CAPS-LOCK toggle bit
SCRLM EQU B'00100000' ; SCROLL-LOCK toggle bit
PAUSM EQU B'00010000' ; tasto PAUSE toggle bit
INSTM EQU B'00000100' ; maschera bit toggle INSERT
;INSM EQU B'00000100' ; maschera bit INSERT
ESCM EQU B'00000010' ; maschera bit ESC
PRNSCM EQU B'00000001' ; maschera bit PRINT SCRN
; maschera bit tasti NO-REPEAT - RptSt
PWRM EQU B'10000000' ; POWER
SLEEPM EQU B'01000000' ; SLEEP
WAKEM EQU B'00100000' ; WAKE UP
LGUIM EQU B'00010000' ; L-GUI
RGUIM EQU B'00001000' ; R-GUI
GUIAPPM EQU B'00000100' ; GUI APP
ESCAPEM EQU B'00000010' ; ESC
PRINTM EQU B'00000001' ; PRINT SCRN
ESCPRNM EQU (ESCM | PRNSCM)
; bit di MapCfg
MAPITB EQU H'007' ; mappa IT
MAPALPHA EQU H'006' ; flag lettera alfabetica
;FLAGSND EQU B'10000000' ; invia flag
;TOGGLESND EQU B'10010000' ; invia toggle
;EXTTGLSND EQU B'10110000' ; invia tasto controllo + toggle low
; bit di TxData0
KEYCTL EQU H'007' ; bit codice di controllo/ASCII
KEYRLS EQU H'006' ; bit tasto rilasciato
KEYCTL2 EQU H'005' ; bit codice di controllo/flag
KEYTGL EQU H'004' ; bit invio toggle low (4 bit)
; top RAM
#ifdef __DEBUG
TOPRAM EQU 0x2F2
#else
TOPRAM EQU 0x300
#endif
RXBUFLEN EQU 0xFE ; dimensione buffer RX
RxBuffer EQU 0x040 ; start buffer RX
RxBufEnd EQU (RxBuffer + RXBUFLEN) ; end buffer RX + 1
TxBuffer EQU (RxBufEnd) ; start buffer TX
TxBufEnd EQU TOPRAM ; fine buffer TX + 1
TXBUFLEN EQU (TxBufEnd - TxBuffer) ; dimensione buffer TX
TXMAXCNT EQU (TXBUFLEN / 2) ; dimensione buffer TX in word
LIST