From: ian Date: Wed, 21 Dec 2005 14:06:51 +0000 (+0000) Subject: get rid of {master,slave}.{asm,inc}; disable test-sofar; work on sorting out master... X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=380fce012b0f6e56c41e5936276eb1fcbbc2aab3;p=trains.git get rid of {master,slave}.{asm,inc}; disable test-sofar; work on sorting out master program --- diff --git a/detpic/Makefile b/detpic/Makefile index db272fb..efb91c2 100644 --- a/detpic/Makefile +++ b/detpic/Makefile @@ -4,8 +4,8 @@ PICNOS= 0 1 2 PROGRAMS= program OBJS_program= vectors.o panic.o routines-led.o i2clib.o \ - misc.o slave.o detect.o variables.o points.o \ - syncwrite.o reverse.o test-sofar.o + misc.o detect.o variables.o points.o \ + syncwrite.o reverse.o XCODEN_program= morse XCODE1_program= blank2 ours+pindata @@ -16,7 +16,6 @@ INCLUDES= \ final.inc \ i2clib.inc \ i2clib.incm \ - master.inc \ misc.fin \ nmra-stream.fin \ panic.fin \ diff --git a/detpic/master.asm b/detpic/master.asm deleted file mode 100644 index ddd844e..0000000 --- a/detpic/master.asm +++ /dev/null @@ -1,125 +0,0 @@ -;====================================================================== - - include common.inc - code - -;---------- -; Program to implement the master. Does not return. Conditions on entry: -; interrupts INTCON set up but interrupts disabled -; i2c controller not set up / not enabled -; picno, idloc1 containing correct values read from flash - -master - call i2cm_init - call bitnum2bit_init -;x call points_local_init -;x call polarity_local_init -;x call detect_local_init - call serial_init - call nmra_init - - panic morse_TI4 -; fixme up to here - - call detect_slave_init - clr_f PCLATU - - bs_f INTCON, GIEH - bs_f INTCON, GIEL - - bt_f_if1 idloc1,idloc1_boarddet - goto backgroundloop_detectors - goto backgroundloop_reversers - -;---------- -master_interrupt_low - enter_interrupt_low - call ticker_intrl - call nmra_serialrx_intrl - ;call serialtx_intrl - call points_local_intrl - call i2cm_intrl - panic morse_IL - -;---------- -master_interrupt_high_notnmra - fixme - -serialrx_table_section code 0x2000 -;-------------------- -serialrx_generalmsg -; FSR0 -> start of message undefined -; *FSR0 message undefined -; -; ; INDF0=MM ww ww ww ww ii ii ii - rlc_fw INDF0 ; W = ww ww ww ww ii ii ii ?? C=MM Z=00 - bra_c serialrx_if_multibyte - bra_z command_crashed - ; single-byte non-0 command, has to be ON or OFF - ; ie supposedly ; INDF0=zz zz II zz zz zz zz PP C=zz - rrc_fw INDF0 ; W = zz zz zz II zz zz zz zz C=PP - xor_lw 0x10 ; W = zz zz zz zz zz zz zz zz C=PP Z=OK - bra_n serialrx_bad - goto command_power - -;----- -serialrx_if_multibyte - rr_fw INDF0 ; W = ii MM ww ww ww ww ii ii - and_lw 0x3c ; W = zz zz ww ww ww ww zz zz - add_wff PCL - ; <--- here is zero - - goto serialrx_bad ; 1 0000 xxx - goto command_ping ; 1 0001 xxx - goto command_polarity ; 1 0010 xxx - goto serialrx_bad ; 1 0011 xxx - goto command_point ; 1 0100 xxx - goto serialrx_bad ; 1 0101 xxx - goto serialrx_bad ; 1 0110 xxx - goto serialrx_bad ; 1 0111 xxx - goto serialrx_bad ; 1 1000 xxx - goto serialrx_bad ; 1 1001 xxx - goto serialrx_bad ; 1 1010 xxx - goto serialrx_bad ; 1 1011 xxx - goto serialrx_bad ; 1 1100 xxx - goto serialrx_bad ; 1 1101 xxx - goto serialrx_bad ; 1 1110 xxx - goto serialrx_bad ; 1 1111 xxx - - goto serialrx_bad ; 0 0000 xxx - goto serialrx_bad ; 0 0001 xxx - goto serialrx_bad ; 0 0000 xxx - -;----- -serialrx_bad - mov_ff INDF0, t - panic morse_HX - -; bra_z crashed_master_do -; mov_fw INDF0 -; bra_z crashed_master_do -; -; serialrx_check 0x00, 0x21, command_power_on -; serialrx_check 0x21, 0x20, command_power_off -; -; and_lw 0xf8 ; W^0x20 = MM ww ww ww ww zz zz zz -; -; serialrx_check 0x00, 0xa0, point_master_do -; serialrx_check 0xa0, 0x88, ping_master_do -; serialrx_check 0x88, 0x90, polarity_master_do -; -; serialrx_check 0x90, 0x90, polarity_master_do -; -; mov_wf t ; t = MM ww ww ww ww zz zz zz -; -; xor_lw 0x -; -; and_lw - - -;-------------------- -command_ping - panic morse_UC - -;---------------------------------------------------------------------- - include final.inc diff --git a/detpic/master.inc b/detpic/master.inc deleted file mode 100644 index 2e98250..0000000 --- a/detpic/master.inc +++ /dev/null @@ -1 +0,0 @@ -; extern master diff --git a/detpic/program.asm b/detpic/program.asm index 0d86f95..7c9c1a4 100644 --- a/detpic/program.asm +++ b/detpic/program.asm @@ -4,7 +4,10 @@ include common.inc code -;---------- +;====================================================================== +; COMMON TO MASTER AND SLAVE + +;---------------------------------------- vector_reset set_f qqTRISA @@ -25,8 +28,28 @@ vector_reset call idlocs_init tst_f_ifnz picno - goto slave - bra master + call slave_init + + tst_f_ifz picno + call master_init + + bs_f INTCON, GIEH + bs_f INTCON, GIEL + + bt_f_if1 idloc1,idloc1_boarddet + goto backgroundloop_detectors + goto backgroundloop_reversers + +;---------- +general_local_init +; called by {master,slave}_init immediately after they've init'd i2c. + clr_f PCLATU + call bitnum2bit_init + + call points_local_init + call polarity_local_init + call detect_local_init + return ;---------- i2cm_intrl @@ -42,6 +65,158 @@ intrl_handled_routine mov_ff isr_low_save_stkptr, STKPTR intrl_handled_core +;====================================================================== +; MASTER + +;---------------------------------------- +master_init +; Master-specific initialisation. + call i2cm_init + call common_local_init + call serial_init + call nmra_init + return + +;---------------------------------------- +master_interrupt_low + enter_interrupt_low + ;call ticker_intrl + call nmra_serialrx_intrl + ;call serialtx_intrl + ;call points_local_intrl + ;call i2cm_intrl + panic morse_IL + +;---------- +master_interrupt_high_notnmra + panic morse_IH + +;---------------------------------------------------------------------- +serialrx_table_section code 0x2000 + +;-------------------- +serialrx_generalmsg +; FSR0 -> start of message undefined +; *FSR0 message undefined +; +; ; INDF0=MM ww ww ww ww ii ii ii + rlc_fw INDF0 ; W = ww ww ww ww ii ii ii ?? C=MM Z=00 + bra_c serialrx_if_multibyte + bra_z command_crashed + ; single-byte non-0 command, has to be ON or OFF + ; ie supposedly ; INDF0=zz zz II zz zz zz zz PP C=zz + rrc_fw INDF0 ; W = zz zz zz II zz zz zz zz C=PP + xor_lw 0x10 ; W = zz zz zz zz zz zz zz zz C=PP Z=OK + bra_n serialrx_bad + goto command_power + +;----- +serialrx_if_multibyte + rr_fw INDF0 ; W = ii MM ww ww ww ww ii ii + and_lw 0x3c ; W = zz zz ww ww ww ww zz zz + add_wff PCL + ; <--- here is zero + + goto serialrx_bad ; 1 0000 xxx + goto command_ping ; 1 0001 xxx + goto command_polarity ; 1 0010 xxx + goto serialrx_bad ; 1 0011 xxx + goto command_point ; 1 0100 xxx + goto serialrx_bad ; 1 0101 xxx + goto serialrx_bad ; 1 0110 xxx + goto serialrx_bad ; 1 0111 xxx + goto serialrx_bad ; 1 1000 xxx + goto serialrx_bad ; 1 1001 xxx + goto serialrx_bad ; 1 1010 xxx + goto serialrx_bad ; 1 1011 xxx + goto serialrx_bad ; 1 1100 xxx + goto serialrx_bad ; 1 1101 xxx + goto serialrx_bad ; 1 1110 xxx + goto serialrx_bad ; 1 1111 xxx + + goto serialrx_bad ; 0 0000 xxx + goto serialrx_bad ; 0 0001 xxx + goto serialrx_bad ; 0 0000 xxx + +;----- +serialrx_bad + mov_ff INDF0, t + panic morse_HX + +; bra_z crashed_master_do +; mov_fw INDF0 +; bra_z crashed_master_do +; +; serialrx_check 0x00, 0x21, command_power_on +; serialrx_check 0x21, 0x20, command_power_off +; +; and_lw 0xf8 ; W^0x20 = MM ww ww ww ww zz zz zz +; +; serialrx_check 0x00, 0xa0, point_master_do +; serialrx_check 0xa0, 0x88, ping_master_do +; serialrx_check 0x88, 0x90, polarity_master_do +; +; serialrx_check 0x90, 0x90, polarity_master_do +; +; mov_wf t ; t = MM ww ww ww ww zz zz zz +; +; xor_lw 0x +; +; and_lw + +;-------------------- +command_ping + panic morse_UC + + code + +;====================================================================== +; SLAVE + +;---------------------------------------- +slave_init +; Slave-specific initialisation. + mov_fw picno + call i2cs_init + + bc_f T0CON, TMR0ON + + call common_local_init + call detect_slave_init + return + +;---------------------------------------- +slave_interrupt_low + enter_interrupt_low + call points_local_intrl + panic morse_IL + +;---------------------------------------- +i2csu_write_begin + return + +;---------------------------------------- +i2csu_write_data + call led_green + + bt_f_if1 picno,picno_panicd + goto i2csu_write_panicd + + bt_w_if0 7 + bra i2csu_write_if_special + bt_w_if1 6 + bra polarity_local_do + bt_w_if0 5 + bra point_local_do +i2csu_write_if_bad + mov_wf t + panic morse_DX + +i2csu_write_if_special + tst_w_ifnz + bra i2csu_write_if_bad + goto panic_crashread_commanded + ;====================================================================== ; MASTER/SLAVE deviations diff --git a/detpic/program.fin b/detpic/program.fin index 79e92db..f09b1a5 100644 --- a/detpic/program.fin +++ b/detpic/program.fin @@ -1,4 +1,2 @@ - extern slave - extern master extern i2cm_intrl extern message_for_master diff --git a/detpic/slave.asm b/detpic/slave.asm deleted file mode 100644 index 6125420..0000000 --- a/detpic/slave.asm +++ /dev/null @@ -1,66 +0,0 @@ -;====================================================================== -; -; On slave, FSR1 and FSR2 is reserved for i2c/detection routine -; and may not be touched by anything else. - - include common.inc - code - -;---------- -; Program to implement the slave. Does not return. Conditions on entry: -; interrupts INTCON set up but interrupts disabled -; i2c controller not set up / not enabled -; picno, idloc1 containing correct values read from flash - -slave - mov_fw picno - call i2cs_init - - bc_f T0CON, TMR0ON - - call bitnum2bit_init - call points_local_init - call polarity_local_init - call detect_local_init - call detect_slave_init - - bs_f INTCON, GIEH - bs_f INTCON, GIEL - - bt_f_if1 idloc1,idloc1_boarddet - goto backgroundloop_detectors - goto backgroundloop_reversers - -;---------- -i2csu_write_begin - return - -;---------- -i2csu_write_data - call led_green - - bt_f_if1 picno,picno_panicd - goto i2csu_write_panicd - - bt_w_if0 7 - bra i2csu_write_if_special - bt_w_if1 6 - bra polarity_local_do - bt_w_if0 5 - bra point_local_do -i2csu_write_if_bad - mov_wf t - panic morse_DX - -i2csu_write_if_special - tst_w_ifnz - bra i2csu_write_if_bad - goto panic_crashread_commanded - -;---------- -slave_interrupt_low - enter_interrupt_low - call points_local_intrl - panic morse_IL - - include final.inc