title 'CSI/O Test program' ; maclib hdz80 maclib exec maclib iomap ; true equ 0ffffh false equ not true cr equ 0dh lf equ 0ah ; ; hd64180 equ true ; mvi c,csio$vec ; CSIO interrupt vector setup command lxi d,csio$hdlr ; -> CSIO interrupt handler rst 1 ; Install using the EXEC processor/handler ; mvi c,inln$chn rst 1 db cr,lf,'---- CSI/O Test Program ----' db cr,lf,0 ; xra a sta disable ; 00 = enabled. ; ; mvi a,055h sta data ; in ip$rd ; Read links cma ; Convert to positive logic ani 0000$0111b ; Use bottom 3 bits for Csio Speed sta speed ; Save in the CSI/O baud rate divisor ; ; Send first byte out, interrupt enabled lda data out trdr ; Send data lda speed ori 0101$0000b ; Transmit + end interrupt enable + speed outo cntr,a ; Should be sending NOW. ; ; ---- Loop back here to wait for the exit command ---- ; ; Each time the transmitter empties, the hlander will send another byte ; according to the enable byte and the speed selected. ; loop: out 085h ; Clear watchdog out 085h in ip$rd ; Read switch cma ; Turn around ani 0010$0000b ; Look for a plugged bit 5 to exit job jnz exit ; Terminate on top bit ; ; Read links for the speed to be used in ip$rd cma ani 0000$0111b ; Csio Speed now sta speed ; jmp loop ; page ;---------------------------------------------------------------- ; Handle CSIO interrupts ; ; This quite simple. The routine will keep sending the data byte ; at the selected speed till the disable flag is set. The it will ; just disable interrupts on the CSIO. ; ; NOTE that at the maximum speed, the watchdog must be cleared by ; this routine since they happen so blindingly fast. ;---------------------------------------------------------------- ; csio$hdlr: push h push b push d push psw ; lda disable ; 00 = send more data ora a jnz csio$skip ; ; ---- Send the byte in the data area out ---- ; lda data outo trdr,a ; Load data ; ; ---- Generate the baud rate divisor and enable tx and interrupts etc ---- ; lda speed ; CSI/O Clock ori 0101$0000b ; Enable interrupts + transmitter outo cntr,a ; Send command to transmit data jmp csio$end ; csio$skip: lda speed outo cntr,a ; Send divisor ONLY, disables interrupts etc. ; csio$end: out 085h ; clear watchdog out 085h pop psw pop d pop b pop h ei ret ; Internal interrupts only require RET ; ;---------------------------------------------------------------- ; To exit this program safely, disable the CSIO sending with the ; "disable" flag then wait for the CSIO to be not busy sending. ; ONLY THEN can we disable the interrupt vector. ;---------------------------------------------------------------- ; exit: mvi a,1 sta disable ; mvi c,inln$chn rst 1 db cr,lf,'Turning Off CSI/O',0 ; exit$wait: out 085h ino a,cntr ; Get CSIO status ani 0001$0000b ; Transmitting still ? jrnz exit$wait ; Wait to stop ; mvi c,inln$chn rst 1 db cr,lf,'Job Ended',0 ; ; mvi c,clr$vec ; Disable all interrupt vectors rst 1 ; jmp 03 ; ;---------------------------------------------------------------- ; Get the CSIO end flag status ; 00 = NOT idle ; 01 = Last function ended ;---------------------------------------------------------------- ; csio$est: ino a,cntr ; Read Csio status ani 1000$0000b ret ; ; Send data out the CSIO for others to use. ; send$csio: lda data outo trdr,a ; Load data lda speed ori 0101$0000b ; Or in send and Interrupt enable outo cntr,a ; Sending NOW ret ; data ds 1 speed: ds 1 disable ds 1 ; end ; ; ; ;