\r
; Simple polling drivers for ASCI0 and ASCI1\r
\r
- extrn ioiniml\r
\r
global as0init\r
global as0ista,as0inp\r
global as1ista,as1inp\r
global as1osta,as1out\r
\r
- include config.inc\r
- include z180reg.inc\r
+ extrn as_init\r
\r
\r
-;--------------------------------------------------------------\r
-;\r
-;\r
-; TC = (f PHI /(2*baudrate*Clock_mode)) - 2\r
-;\r
-; TC = (f PHI / (32 * baudrate)) - 2\r
-;\r
+ maclib z180reg.inc\r
+ maclib config.inc\r
+\r
+ dseg\r
\r
- cseg\r
+;--------------------------------------------------------------\r
+; Init Serial I/O for input and output (ASCI 0/1)\r
;\r
-; Init Serial I/O for console input and output (ASCI1)\r
+; b: device number\r
;\r
\r
-; TODO: set baudrate\r
\r
as0init:\r
- ld hl,initab0\r
- jp ioiniml\r
+ ld c,0 ;asci channel number\r
+ jp as_init\r
\r
as1init:\r
- ld hl,initab1\r
- jp ioiniml\r
-\r
-\r
-\r
-\r
-initab0:\r
- db 1,stat0,0 ;Disable rx/tx interrupts\r
- ;Enable baud rate generator\r
- db 1,asext0,M_BRGMOD+M_DCD0DIS+M_CTS0DIS\r
- db 2,astc0l,low 28, high 28\r
- db 1,cntlb0,M_MPBT ;No MP Mode, X16\r
- db 1,cntla0,M_RE+M_TE+M_MOD2 ;Rx/Tx enable, 8N1\r
- db 0\r
-\r
-initab1:\r
- db 1,stat1,0 ;Disable rx/tx ints, disable CTS1\r
- db 1,asext1,M_BRGMOD ;Enable baud rate generator\r
- db 2,astc1l,low 3, high 3\r
- db 1,cntlb1,M_MPBT ;No MP Mode, X16\r
- db 1,cntla1,M_RE+M_TE+M_MOD2 ;Rx/Tx enable, 8N1\r
- db 0\r
+ ld c,1 ;asci channel number\r
+ jp as_init\r
\r
\r
;--------------------------------------------------------------\r
\r
as0inp:\r
in0 a,(stat0)\r
- rlca\r
- jr nc,as0inp\r
- in0 a,rdr0\r
+ bit RDRF,a\r
+ jr z,as0inp\r
+\r
+ in0 c,(rdr0)\r
+ and a,M_OVRN+M_PERR+M_FE\r
+ jr z,as0in_ex\r
+\r
+ in0 a,(cntla0)\r
+ res EFR,a\r
+ out0 (cntla0),a\r
+as0in_ex:\r
+ ld a,c\r
ret\r
\r
as1inp:\r
+ in0 a,(stat1)\r
+ bit RDRF,a\r
+ jr z,as1inp\r
+\r
+ in0 c,(rdr1)\r
+ and a,M_OVRN+M_PERR+M_FE\r
+ jr z,as1in_ex\r
+\r
+ in0 a,(cntla1)\r
+ res EFR,a\r
+ out0 (cntla1),a\r
+as1in_ex:\r
+ ld a,c\r
+ ret\r
+\r
+ if 0\r
in0 a,(stat1)\r
rlca\r
jr nc,as1inp\r
in0 a,rdr1\r
ret\r
-\r
+ endif\r
\r
\r
as0osta:\r