2020-04-02 23:21:53 -04:00
|
|
|
( ACIA
|
|
|
|
|
|
|
|
Manage I/O from an asynchronous communication interface adapter
|
|
|
|
(ACIA). provides "EMIT" to put c char on the ACIA as well as
|
|
|
|
an input buffer. You have to call "~ACIA" on interrupt for
|
|
|
|
this module to work well.
|
|
|
|
|
|
|
|
CONFIGURATION
|
|
|
|
|
|
|
|
ACIA_CTL: IO port for the ACIA's control registers
|
|
|
|
ACIA_IO: IO port for the ACIA's data registers
|
2020-04-04 17:07:35 -04:00
|
|
|
ACIA_MEM: Address in memory that can be used variables shared
|
|
|
|
with ACIA's native words. 8 bytes used.
|
2020-04-02 23:21:53 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
0x20 CONSTANT ACIABUFSZ
|
|
|
|
|
2020-04-11 15:11:36 -04:00
|
|
|
( Points to ACIA buf )
|
|
|
|
: ACIA( [ ACIA_MEM 4 + LITN ] ;
|
|
|
|
( Points to ACIA buf end )
|
|
|
|
: ACIA) [ ACIA_MEM 6 + LITN ] ;
|
|
|
|
( Read buf pointer. Pre-inc )
|
|
|
|
: ACIAR> [ ACIA_MEM LITN ] ;
|
|
|
|
( Write buf pointer. Post-inc )
|
|
|
|
: ACIAW> [ ACIA_MEM 2 + LITN ] ;
|
|
|
|
( This means that if W> == R>, buffer is full.
|
|
|
|
If R>+1 == W>, buffer is empty. )
|
|
|
|
|
|
|
|
|
2020-04-02 23:21:53 -04:00
|
|
|
: ACIA$
|
|
|
|
H@ DUP DUP ACIA( ! ACIAR> !
|
2020-04-16 08:18:55 -04:00
|
|
|
1+ ACIAW> ! ( write index starts one position later )
|
2020-04-02 23:21:53 -04:00
|
|
|
ACIABUFSZ ALLOT
|
|
|
|
H@ ACIA) !
|
|
|
|
( setup ACIA
|
|
|
|
CR7 (1) - Receive Interrupt enabled
|
|
|
|
CR6:5 (00) - RTS low, transmit interrupt disabled.
|
|
|
|
CR4:2 (101) - 8 bits + 1 stop bit
|
|
|
|
CR1:0 (10) - Counter divide: 64
|
|
|
|
)
|
|
|
|
0b10010110 ACIA_CTL PC!
|
|
|
|
|
|
|
|
( setup interrupt )
|
2020-04-04 10:31:22 -04:00
|
|
|
( 4e == INTJUMP )
|
|
|
|
0xc3 0x4e RAM+ C! ( JP upcode )
|
|
|
|
['] ~ACIA 0x4f RAM+ !
|
2020-04-02 23:21:53 -04:00
|
|
|
(im1)
|
|
|
|
;
|
|
|
|
|
|
|
|
: KEY
|
2020-04-08 08:26:04 -04:00
|
|
|
( inc then fetch )
|
2020-04-16 08:18:55 -04:00
|
|
|
ACIAR> @ 1+ DUP ACIA) @ = IF
|
2020-04-08 08:26:04 -04:00
|
|
|
DROP ACIA( @
|
|
|
|
THEN
|
|
|
|
|
2020-04-02 23:21:53 -04:00
|
|
|
( As long as R> == W>-1, it means that buffer is empty )
|
2020-04-08 08:26:04 -04:00
|
|
|
BEGIN DUP ACIAW> @ = NOT UNTIL
|
2020-04-02 23:21:53 -04:00
|
|
|
|
2020-04-08 08:26:04 -04:00
|
|
|
ACIAR> !
|
2020-04-04 17:07:35 -04:00
|
|
|
ACIAR> @ C@
|
2020-04-02 23:21:53 -04:00
|
|
|
;
|
|
|
|
|
|
|
|
: EMIT
|
|
|
|
( As long at CTL bit 1 is low, we are transmitting. wait )
|
|
|
|
BEGIN ACIA_CTL PC@ 0x02 AND UNTIL
|
|
|
|
( The way is clear, go! )
|
2020-04-04 14:27:23 -04:00
|
|
|
ACIA_IO PC!
|
2020-04-02 23:21:53 -04:00
|
|
|
;
|
|
|
|
|