;----------------------------------------------------------------------
udata_acs
+; for reading and detection:
b res 1 ; byte just read
cslot res 1 ; current slave in slave table, points to flags byte
cbyte res 1
; M010 0000 we're expecting more detection byte 2
; 1000 0000 we're expecting an extra byte
- code
;======================================================================
; HANDLING OF I2C EVENTS
+near_getwritebyteyes code
+;----------------------------------------
+getwritebyte_yes
+ pop ; we don't care where we were in i2cmu_write_next_byte
+ bc_f STATUS, Z ; yes, we want to write this byte
+ return ; from i2cmu_write_next_byte
+
+ code
+;----------------------------------------
+i2cmu_write_next_byte
+ ; add calls to getwritebyte_<foo> here:
+ call getwritebyte_polarity
+ call getwritebyte_points
+ ; end of list of calls to getwritebyte_<foo>
+ ; so, no-one wants this slave:
+ bs_f STATUS, Z
+ return
+
+ bra_nz write_another_slave
+
+
+
+ return
+
;----------------------------------------
i2cm_intrl
; handles i2c interrupt using i2cm_interrupt[_definite],
call i2cm_interrupt_definite
intrl_handled_nostack
-;----------------------------------------
-i2cmu_done panic morse_MD
-
-;----------------------------------------
-i2cmu_write_next_byte
- panic morse_UI
-
;======================================================================
; PROCESSING OF INCOMING BYTES - CORE AND DETECTION
; DECIDING WHICH SLAVE TO ADDRESS
;...
i2c_arrange_something
+i2cmu_done
; figure out what to do next - which pic to address, etc.
- panic morse_UG
+ mov_fw needwrite_slave
+ bra_nz arrange_write
+
+ ; add calls to needwrite_<foo> here:
+ call needwrite_polarity
+ call needwrite_points
+ ; end of list of calls to needwrite_<foo>
+
+ ; no writing needed, we have to read:
+ mov_lfsr slavetable, 1 ; FSR1H -> slavetable
+ mov_ff cslot, FSR1L ; FSR1 -> current ste_flags
+ mov_lw ste_size ; W = ste_size
+nextslave_loop
+ add_wff FSR1L ; FSR1 -> next ste_flags
+ bt_f_if0 INDF1, stf_present
+ bra nextslave_loop
+
+nextslave_reloop_resume
+ mov_ff FSR1L, cslot ; cslot -> new ste_flags
+ bt_f_if1 POSTDEC1, stf_sentinel ; FSR1 -> ste_slave
+ bra nextslave_reloop
+
+ mov_fw INDF1 ; W = new slave number
+ goto i2cm_read_start
+
+nextslave_reloop
+ mov_lfsr slavetable + ste_size + ste_flags
+ bra nextslave_reloop_resume
+
+fixme do not i2cm_read_start if no room in buffer
+fixme check that we don't accidentally skip reading a slave
;======================================================================
; PROCESSING OF INCOMING BYTES - EXTRA (NON-DETECTION)