more IEC work - iec_tx_command can now detect missing devices

This commit is contained in:
FeralChild64 committed 2019-06-21 21:47:39 +02:00
1 parent 5ae749b552
commit b21ce3116d
5 files changed
+45 -38

No files matched your search

+17
View File
@@ -15,7 +15,24 @@ iec_tx_byte:
pla pla
jsr iec_tx_common jsr iec_tx_common
;; All done - give device time to tell if they are busy by pulling DATA
;; They should do it within 1ms
ldx #$FF
* lda CI2PRA
;; BPL here is checking that bit 7 of $DD00 clears,
;; i.e, that the DATA line is pulled by drive
bpl +
dex
bne -
bpl iec_tx_byte_error
*
;; All done ;; All done
clc clc
rts rts
iec_tx_byte_error:
jsr iec_set_idle
jmp kernalerror_DEVICE_NOT_FOUND
+22 -2
View File
@@ -14,7 +14,7 @@ iec_tx_command:
;; Did at least one device respond by pulling DATA? ;; Did at least one device respond by pulling DATA?
lda CI2PRA lda CI2PRA
and #BIT_CI2PRA_DAT_IN and #BIT_CI2PRA_DAT_IN ; XXX try to optimize this, move to separate routine
beq + beq +
;; No devices present on the bus, so we can immediately return with device not found ;; No devices present on the bus, so we can immediately return with device not found
@@ -39,7 +39,27 @@ iec_tx_command:
pla pla
jsr iec_tx_common jsr iec_tx_common
;; All done ;; According to https://www.pagetable.com/?p=1135 there is some complicated and dangerous
;; flow here, but http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf (page 6)
;; advices to just wait 1ms and check the DATA status
jsr wait1ms
lda CI2PRA
and #BIT_CI2PRA_DAT_IN ; XXX try to optimize this, move to separate routine
beq +
;; XXX possible optimization of the flow above: for many commands it is enough
;; to wait for the DATA being pulled, as confirmation is expected from
;; a single device only - but not sure if it's worth the trouble
jsr printf
.byte "DBG: NO CONFIRMATION FROM DEVICE", $0D, 0
jsr iec_set_idle
jmp kernalerror_DEVICE_NOT_FOUND
*
;; All done - before exiting wait a moment and restore bus to idle state
jsr iec_wait20us
jsr iec_set_idle
clc clc
rts rts
+2 -26
View File
@@ -1,6 +1,7 @@
;; This is a common part of iec_tx_byte and iec_tx_command ;; This is a common part of iec_tx_byte and iec_tx_command
;; Implemented based on https://www.pagetable.com/?p=1135, https://github.com/mist64/cbmbus_doc ;; Implemented based on https://www.pagetable.com/?p=1135, https://github.com/mist64/cbmbus_doc
;; and http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf
iec_tx_common: iec_tx_common:
@@ -49,32 +50,7 @@ iec_tx_common_bit_is_sent:
bpl iec_tx_common_nextbit bpl iec_tx_common_nextbit
pla pla
;; Whole byte send, make sure ATN is released rts ; Flow continues differently for data/command
jsr iec_release_atn_clk_data
;; XXX the flow below is REALLY dangerous, as if there are multiple devices,
;; one can signal that it's busy much earlier (more than 100ms) than the other.
;; Can we do something about it?
;; All done - give devices time to tell if they are busy by pulling DATA
;; They should do it within 1ms
ldx #$FF
* lda CI2PRA
;; BPL here is checking that bit 7 of $DD00 clears,
;; i.e, that the DATA line is pulled by drive
bpl +
dex
bne -
bpl iec_tx_common_done
*
;; Wait 100us to give busy devices some time
jsr iec_wait100us
iec_tx_common_done:
;; Byte sent, return
clc
rts
iec_tx_common_nextbit: iec_tx_common_nextbit:
+4 -10
View File
@@ -84,25 +84,19 @@ open_iec:
;; Request device to talk ;; Request device to talk
lda current_device_number lda current_device_number
jsr talk jsr talk
bcs open_iec_error ; XXX what about the accumulator? bcs open_iec_error
jsr printf
.byte "DBG: OPEN 1", $0D, 0
;; Send secondary address ;; Send secondary address
lda current_secondary_address lda current_secondary_address
jsr second jsr second
bcs open_iec_error ; XXX what about the accumulator? bcs open_iec_error
jsr printf
.byte "DBG: OPEN 2", $0D, 0
;; Turnaround ;; Turnaround
jsr iec_turnaround_to_listen jsr iec_turnaround_to_listen
bcs open_iec_error ; XXX what about the accumulator? bcs open_iec_error
jsr printf jsr printf
.byte "DBG: OPEN 3 - DEVICE EXISTS", $0D, 0 .byte "DBG: TURNAROUND SUCCEEDED", $0D, 0
;; Indicate success ;; Indicate success
lda #$00 lda #$00