* $Id: sccf.asm,v 1.1 1998/02/02 08:18:04 taubert Exp $ case on * Install an interrupt handler into the SIM tool. This uses the SIM * library so it's really easy InstallInt START ph4 #IntVect pea PortNum jsl INSTALLINTVECT rts oldVect ENTRY dc i4'0' END * Remove our SCC interrupt handler from the Main Interrupt Vector RemoveInt START ph4 #IntVect pea PortNum jsl REMOVEINTVECT rts END IntVect START using SerialData longa off longi off php long x ; JAWAID! *whap* ; check_stuff needs RR0 contents, not RR3! ; tay we need this for check_stuff bit #Channel_Rx beq t_Tx_Int phb phk plb phd long m lda SerialDP tcd short m ; *whap* ; sty PortControl lda >PortControl pha lda >PortData sta PortControl ; error reset lda #$30 sta >PortControl weepers lda #0 ; Reset high IUS sta >PortControl lda #$38 sta >PortControl lda >PortControl bit #1 bne lp1 ; more data! pld plb gohome anop plp clc rtl notOurIntr anop plp sec rtl t_Tx_Int anop bit #Channel_Tx beq statusInt lda SerialDP tcd short m phb phk plb doTxChar ldy PortData iny cpy PortControl lda #$38 sta >PortControl plb pld ; ply bra gohome turnOffTxInt lda #%00101000 sta >PortControl lda #0 sta SerialDP tcd short m phb phk plb lda >PortControl bit #%00100000 ; check status of CTS line bne turniton lda #1 sta PortControl lda #$38 sta >PortControl plb pld ; ply jmp gohome turniton lda PortControl ; *whap* ; lda dtty+t_select_proc cmp #$FFFF beq done * someone is selecting on us, so call selwakeup with the process ID * and our collision flag pha lda >dtty+privFlags and #TS_RCOLL pha jsl >dtty+t_selwakeup lda >dtty+privFlags and #TS_RCOLL.EOR.$FFFF sta >dtty+privFlags lda #$FFFF sta >dtty+t_select_proc done anop short m goaway anop rts * we lost carrier detect, so send a sighup signal sighupit anop long m lda #$FFFF sta >$E00408 pea 1 ; push signal number lda >dtty+t_devNum pha ; push our device number jsl dtty+t_sendSignal * short m ; see done, above bra done END longa on longi on * ReadBuffer and WriteBuffer expect the D register to be set properly * (i.e., to SerialDP) ReadBuffer START using SerialData php short m sei ldy PortControl ; lda >PortControl ; bit #Tx_empty see if something is in the Tx latch ; beq addToBuffer and if so stick char in the buffer lda PortData lda #1 sta PortControl ; check the CTS line to make sure bit #%00100000 ; the printer can accept data... beq flowCheck ; if not, then wait for it txfull lda >PortControl ; make sure the transmit buffer bit #%00000100 ; is empty beq txfull pla sta >PortData ; write our data! long m return END InitSCC START php sei short m lda >PortControl lda #$09 sta >PortControl lda #%00000010+PortReset channel reset, turn intrs off sta >PortControl nop nop nop nop nop nop nop nop ldx #0 a_ian_loop lda async_data,x cmp #$FF beq a_ian_leap sta >PortControl * What's the timer for? inx bra a_ian_loop a_ian_leap anop long m plp rtl async_data dc i1'$04,$44' X16 clock mode, 1 stop bit dc i1'$02,$00' no interrupt vector dc i1'$03,%11100000' rx 8 bits/char, rx off, auto enables dc i1'$05,$62' DTR = 0, tx 8 bits/char, tx off, RTS = 1 dc i1'$09,%0010' no reset, all ints off dc i1'$0A,$00' NRZ data encoding dc i1'$0B,Reg11' xtal on, rx clock = brg out, tx clock = brg_out initBaudLo ENTRY dc i1'$0C,$04' low byte of brg time constant initBaudHi ENTRY dc i1'$0D,$00' high byte of brg time constant dc i1'$0E,$80' source = brg, brg clock = xtal, brg off dc i1'$0E,$01' brg on, brg clock = xtal dc i1'$03,%11100001' rx 8 bits/char, rx on dc i1'$05,DTR' DTR = 0, tx 8 bits/char, tx on, RTS = 1 dc i1'$0F,%00101000' interrupt on CTS status change * dc i1'$01,%00010001' rx char ints enable * dc i1'$09,%00001010' master interrupt enable dc i1'$FF' END InitSCC2 START using SerialData php sei short m lda >PortControl lda #1 sta >PortControl lda #%00010010 ; intr on all rx and tx sta >PortControl lda #9 sta >PortControl lda #%1010 sta >PortControl ; hum, just for kicks... lda #0 sta >PortControl ; error reset lda #$30 sta >PortControl lda #0 ; Reset high IUS sta >PortControl lda #$38 sta >PortControl plp rts END longa on longi on DeInitSCC START using SerialData * Turn off the SCC's interrupt generation completely php sei short m lda >PortControl lda #9 sta >PortControl lda #%0010 sta >PortControl lda #1 sta >PortControl lda #0 sta >PortControl lda >PortData lda #%11010000 sta >PortControl nop nop nop nop nop lda #%00101000 sta >PortControl nop nop nop nop nop lda #9 sta >PortControl lda #%1010 sta >PortControl ; lda >SerFlag ; and #%11111000 ; sta >SerFlag ; lda >ourSerFlag ; and #%11111000 ; sta >ourSerFlag long m plp rts END StartSerial START using SerialData result equ 0 subroutine (4:dp,4:inb,4:outb),2 stz result lda inb ldy #in_buf sta [dp],y lda inb+2 ldy #in_buf+2 sta [dp],y lda outb ldy #out_buf sta [dp],y lda outb+2 ldy #out_buf+2 sta [dp],y phd lda dp sta >SerialDP tcd ; 'return' will restore this lda #0 sta SerialDP tcd lp lda PortControl lda #DTR+$80 sta >PortControl sta PortControl lda #DTR sta >PortControl sta SerialDP tcd php short m sei lda #5 sta >PortControl lda #DTR sta >PortControl sta SerialDP tcd php sei short m lda #5 sta >PortControl lda #DTR+$80 sta >PortControl sta baudTbl,x sta CurBaud * reset the baud rate in the SCC tax short m lda >PortControl lda #$0C sta >PortControl txa sta >PortControl lda #$0D sta >PortControl txa xba sta >PortControl long m realFIN plp rts end