IEC cleanups and size optimization
This commit is contained in:
1 parent
ee499b6b21
commit
e3314f8b8f
6 files changed
+74
-100
No files matched your search
@@ -19,11 +19,73 @@ iec_tx_byte:
|
||||
;; and it is going to be a data byte (released ATN)
|
||||
jsr iec_release_atn_clk_data
|
||||
|
||||
;; Common part of iec_txbyte and iec_tx_common - waits for devices
|
||||
;; and transmits a byte
|
||||
;; 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
|
||||
;; and http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf
|
||||
|
||||
iec_tx_common:
|
||||
|
||||
;; Timing is critical here - execute on disabled IRQs
|
||||
php
|
||||
sei
|
||||
|
||||
;; Wait till all receivers are ready, they should all release DATA
|
||||
jsr iec_wait_for_data_release
|
||||
|
||||
;; At this point a delay 256 usec or more is considered EOI - add waits if necessary
|
||||
bcc +
|
||||
jsr iec_wait100us
|
||||
jsr iec_wait100us
|
||||
jsr iec_wait60us
|
||||
|
||||
;; XXX waits above should be enough - why do we need more waits???
|
||||
jsr iec_wait100us
|
||||
jsr iec_wait100us
|
||||
jsr iec_wait100us
|
||||
|
||||
;; Receiver should now acknowledge EOI by pulling data for at least 60 usec
|
||||
jsr iec_wait60us
|
||||
jsr iec_wait_for_data_release
|
||||
*
|
||||
;; Pull CLK back to indicate that DATA is not valid, keep it for 60us
|
||||
;; We can use this routine as we don't hold DATA anyway (and its state doesn't even matter)
|
||||
|
||||
jsr iec_pull_clk_release_data_oneshot
|
||||
jsr iec_wait60us
|
||||
|
||||
;; Now, we can start transmission of 8 bits of data
|
||||
ldx #7
|
||||
|
||||
iec_tx_common_sendbit:
|
||||
;; Is next bit 0 or 1?
|
||||
lda IEC_TMP2
|
||||
lsr
|
||||
sta IEC_TMP2
|
||||
bcs +
|
||||
|
||||
;; Bit is 0
|
||||
jsr iec_release_clk_pull_data
|
||||
jmp iec_tx_common_bit_is_sent
|
||||
*
|
||||
;; Bit is 1
|
||||
jsr iec_release_clk_data
|
||||
|
||||
iec_tx_common_bit_is_sent:
|
||||
|
||||
;; Wait 20us, so that device(s) can pick DATA
|
||||
jsr iec_wait20us
|
||||
|
||||
;; Pull CLK for 20us again, before sending the next bit
|
||||
;; or performing any other action
|
||||
jsr iec_pull_clk_release_data_oneshot
|
||||
jsr iec_wait20us
|
||||
|
||||
;; More bits to send?
|
||||
dex
|
||||
bpl iec_tx_common_sendbit
|
||||
|
||||
plp
|
||||
|
||||
jsr iec_tx_common
|
||||
|
||||
;; Give device time to tell if they are busy by pulling DATA
|
||||
;; They should do it within 1ms
|
||||
ldx #$FF
|
||||
@@ -36,5 +98,3 @@ iec_tx_byte:
|
||||
bpl iec_return_DEVICE_NOT_FOUND
|
||||
*
|
||||
jmp iec_return_success
|
||||
|
||||
|
||||
Reference in new issue
Block a user