From: ian Date: Sun, 25 Dec 2005 13:03:27 +0000 (+0000) Subject: i2cmu_done and i2c_arrange_something initial implementation X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=ad0b48a0eac3df228408fca991c0533edf51d506;p=trains.git i2cmu_done and i2c_arrange_something initial implementation --- diff --git a/detpic/mascan.asm b/detpic/mascan.asm index fa8c679..92ce973 100644 --- a/detpic/mascan.asm +++ b/detpic/mascan.asm @@ -6,6 +6,7 @@ ;---------------------------------------------------------------------- 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 @@ -15,10 +16,33 @@ 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_ here: + call getwritebyte_polarity + call getwritebyte_points + ; end of list of calls to getwritebyte_ + ; 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], @@ -28,13 +52,6 @@ i2cm_intrl 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 @@ -183,8 +200,39 @@ i2c_arrange_next_byte ; 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_ here: + call needwrite_polarity + call needwrite_points + ; end of list of calls to needwrite_ + + ; 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) diff --git a/detpic/variables.asm b/detpic/variables.asm index e0380c8..18681e3 100644 --- a/detpic/variables.asm +++ b/detpic/variables.asm @@ -27,6 +27,8 @@ isr_high_save_fsr0 res 2 ; for isrh_fsr0_{save,restore} xdebug res 8 +; for writing to slaves: +cwslave res 1 ; slave we're currently actually writing to needwrite_slave res 1 ; 0 means we don't need to write to any slave ; non-0 means at least this slave ; and perhaps others @@ -79,6 +81,8 @@ ste_detmsgh equ 7 ; dk 1 001 1 000 being 1 001 Y SSS ; .k entry is constant, created during init'n ; flags in ste_flags: stf_detect equ 7 ; Gk this is a detectors board +stf_sentinel equ 6 ; Gk sentinel slot at end of table +stf_detpresent equ 5 ; dk this board has some detectors (or slot is sentinel) include final.inc