From fb19b5a0de9462b9b119f7daaec1fee5691b869c Mon Sep 17 00:00:00 2001 From: ian Date: Sun, 25 Dec 2005 23:14:03 +0000 Subject: [PATCH] detection on master board --- detpic/detect.asm | 31 +++++++++++- detpic/detect.inc | 2 + detpic/mascan.asm | 106 +++++++++++++++++++++++++++++++++--------- detpic/morse.messages | 3 ++ detpic/program.asm | 2 + detpic/variables.asm | 1 - 6 files changed, 119 insertions(+), 26 deletions(-) diff --git a/detpic/detect.asm b/detpic/detect.asm index f26a45b..6ebbd1a 100644 --- a/detpic/detect.asm +++ b/detpic/detect.asm @@ -369,7 +369,7 @@ new_i2c_outmsg ; C xx xx xx xx xx 00 xx xx ; D xx xx xx xx xx xx 04 05 ;---------- ; E xx xx xx xx xx 02 xx xx -backgroundloop_reversers +backgroundloop_reversers_core macro rr_fw PORTA ; W xx xx 01 xx 03 xx xx xx (now) and_wff scana ; a xx xx 01 xx 03 xx xx xx (cumulative) mov_fw PORTD ; D xx xx xx xx xx xx 04 05 (now) @@ -378,10 +378,13 @@ backgroundloop_reversers bc_f buf0,2 ; buf0 MM zz zz ss zz 00 zz zz (cumulative) bt_f_if0 PORTE,2 ; 02 (now) bc_f buf0,4 ; buf0 MM zz zz 02 zz ss zz zz (cumulative) + endm +backgroundloop_reversers + backgroundloop_reversers_core backgroundloop_again backgroundloop_reversers ;---------- ; buf0 MM zz zz 02 zz 00 zz zz -i2csu_read_begin_reversers +read_begin_calc_buf0_reversers macro mov_fw scana ; W xx xx 01 xx 03 xx xx xx and_lw 0x28 ; W zz zz 01 zz 03 zz zz zz ior_wff buf0 ; buf0 MM zz 01 02 03 00 zz zz @@ -389,13 +392,37 @@ i2csu_read_begin_reversers mov_fw scand ; W xx xx xx xx xx xx 04 05 and_lw 0x03 ; W zz zz zz zz zz zz 04 05 ior_wfw buf0 ; W MM zz 01 02 03 00 04 05 + endm +i2csu_read_begin_reversers + read_begin_calc_buf0_reversers call i2cs_read_data rcall new_i2c_outmsg bra i2csu_read_begin_either_tail +;====================================================================== +; FOR MASTER + +;---------- +backgroundloop_master + backgroundloop_reversers_core + bra backgroundloop_master + +;---------- +read_detection_head_master + read_begin_calc_buf0_reversers + bra_n read_detection_head_master_badmore + set_f scana + set_f scand + mov_ff buf0_startval, buf0 + return + +;----- +read_detection_head_master_badmore + panic morse_DM + ;====================================================================== include final.inc diff --git a/detpic/detect.inc b/detpic/detect.inc index 0b84d60..a882223 100644 --- a/detpic/detect.inc +++ b/detpic/detect.inc @@ -1,5 +1,7 @@ extern detect_local_init extern detect_slave_init extern slave_add_short_message + extern read_detection_head_master + extern backgroundloop_master extern backgroundloop_reversers extern backgroundloop_detectors diff --git a/detpic/mascan.asm b/detpic/mascan.asm index 1a2f804..69c316f 100644 --- a/detpic/mascan.asm +++ b/detpic/mascan.asm @@ -18,7 +18,8 @@ cbyte res 1 ; ???? ???1 reading halted due to lack of buffer space: cbyte_halted equ 0 ; also set briefly while we decide what to do next -wslave res 1 ; slave we need to write to +wslave res 1 ; slave we need to write to +outmsg_targetlen res 1 ; ;====================================================================== ; HANDLING OF I2C EVENTS @@ -211,28 +212,26 @@ nextslave_nowrite cmp_fw_ifle outmsg_targetlen return ; target len < actual len, do not add anything ; ok, there's space, go ahead: + bc_f cbyte, cbyte_halted + mov_lw ste_size + add_wff cslot ; cslot -> next ste_flags 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 + mov_fw cslot, FSR1L ; FSR1 -> new ste_flags + bt_f_if1 POSTDEC1, stf_sentinel ; FSR1 -> ste_slave - bra nextslave_reloop - ; no wrap around: + bra nextslave_looparound + ; Ok, we have a slave: mov_fw INDF1 ; W = new slave number - bc_f cbyte, cbyte_halted goto i2cm_read_start -nextslave_reloop - mov_lfsr slavetable + ste_size + ste_flags - bra nextslave_reloop_resume +nextslave_looparound + ; now we do our own detection + mov_lw (slavetable + ste_flags) & 0xff ; select our own slot + mov_wf cslot + call read_detection_head_master + goto i2cmu_read_got_byte ;---------------------------------------- i2cmu_done @@ -280,13 +279,74 @@ i2c_consider_restartread ; INITIALISATION mascan_init - add_lw -maxpic/2 ; at 9600, about 1ms per char; - ; we reckon on about 2 pics per ms. So if - ; we have at least maxpic/2 then we won't - ; run out before we have scanned them all - coincidentally is about 1 pic cmp_fw_ifle - mov_fw outmsg_end - sub_wfw + mov_lw slavetable & 0xff + mov_wf cslot + clr_f cbyte + clr_f wslave + + mov_lw 2 + mov_lfsr slavetable, 0 ; FSR0 -> slavetable + load_tblptr pic2detinfo ; TBLPTR* -> pic2detinfo + clr_f t ; t = loop counter +mascan_init_loop + tblrd_postinc_fixup ; TABLAT = EOOOOSSS + mov_fw TABLAT ; W = EOOOOSSS, N = E + + tblrd_postinc_fixup ; TABLAT = DSSSSSSS, N (still) = E + bra_nn mascan_init_ifabsent + + mov_ff t, POSTINC0 ; ste_slave = slave + mov_wf u ; u = 1OOOOSSS + and_lw 0x78 + bra_nz mascan_bad_detinfo0 + ; ok ; u = 10000SSS + + mov_fw TABLAT ; W = DSSSSSSS + and_lw 0x80 ; W = D0000000 + mov_wf POSTINC0 ; ste_flags = D0000000 + + mov_fw TABLAT ; W = DSSSSSSS + bc_w 7 ; W = 0SSSSSSS = first + add_lw -0xf8 ; W = first - 0xf8 = detbasel + mov_wf POSTINC0 ; detbasel + + clr_f POSTINC0 ; lastd0 + clr_f POSTINC0 ; lastd1 + clr_f POSTINC0 ; lastd2 + set_f POSTINC0 ; unused + + mov_fw u ; W = 10000SSS + xor_lw b'10011000' ^ 0x80 ; W = detmsgh + mov_wf POSTINC0 ; detmsgh + +mascan_init_ifabsent + inc_f t ; next slave + bt_f_if0 t, maxpics_ln2 + bra mascan_init_loop + ; we've read the whole flash table + + if slavetable = 0x400 + bt_f_if1 FSR0H, 0 + bra mascan_bad_toomany + endif + + clr_f POSTINC0 ; ste_slave + mov_lw (1<