From c30602012cfc9cd38e37b135dbf925d65b3cbf83 Mon Sep 17 00:00:00 2001 From: ian Date: Tue, 27 Dec 2005 01:04:35 +0000 Subject: [PATCH] manage CDU fullness separately from point firing --- detpic/energy.asm | 3 +++ detpic/energy.fin | 1 + detpic/morse.messages | 5 +++-- detpic/points.asm | 43 +++++++++++++++++++++++++++++++------------ detpic/points.fin | 3 +++ detpic/program.asm | 3 +++ 6 files changed, 44 insertions(+), 14 deletions(-) diff --git a/detpic/energy.asm b/detpic/energy.asm index dab5b80..dbdebd9 100644 --- a/detpic/energy.asm +++ b/detpic/energy.asm @@ -19,5 +19,8 @@ command_power power_polarising panic morse_UER +power_panichook + panic morse_UEP + ;====================================================================== include final.inc diff --git a/detpic/energy.fin b/detpic/energy.fin index c0549db..5fd3c0d 100644 --- a/detpic/energy.fin +++ b/detpic/energy.fin @@ -1,2 +1,3 @@ extern command_power extern power_polarising + extern power_panichook diff --git a/detpic/morse.messages b/detpic/morse.messages index bf5dc69..06c9d15 100644 --- a/detpic/morse.messages +++ b/detpic/morse.messages @@ -51,6 +51,7 @@ TI5 ; for iwj # Unimplemented things UEC +UEP UER # Messages for i2clib, S* @@ -83,10 +84,10 @@ RG ; too many reversers boards PB points:pointmsg ; Firing point when already busy PI points:pointmsg,T3CON ; Unexpected Timer 3 interrupt PU points:pointmsg ; Firing nonexistent point +PC ; Firing point when CDU empty PS points:pointslave,points:pointmsg ; Firing point on nonexistent board PF ::t ; Flash mentions point not on board PX ; Host sent >2-byte POINT command PM ; Firing point when master/CDU busy -PC ; POINTED when already charging +PQ ; POINTED when already charging PA ; POINTED when already firing -PQ ; we're confused about CDU charged diff --git a/detpic/points.asm b/detpic/points.asm index d4d3bcd..62527b0 100644 --- a/detpic/points.asm +++ b/detpic/points.asm @@ -14,10 +14,13 @@ ; M Firing Counting up 100PPPPP 0000 0000 0x00 ; M Telling Off 100PPPPP 00SS Sss0 0x00 ; M Told Off 100PPPPP 0000 0000 0x00 -; M Charging Off 100PPPPP 0000 0000 >0 +; M Charging Off 00000000 0000 0000 >0 ; ; notes: firing see ie, slave*2 Counts down ; timeout detect.asm in ticks +; +; cducharging only counts if the cdu is enabled +; (according to CDU Enable LAT bit) cdu_timeout equ 200 ; ms @@ -280,6 +283,9 @@ command_point tst_f_ifnz pointmsg bra command_point_busy + tst_f_ifnz cducharging + bra command_point_cduempty + swap_fw POSTINC0 ; W = 0SSS 1010 and_lw 0x70 ; W = 0SSS 0000 rr_w ; W = 00SS S000 @@ -304,6 +310,7 @@ command_point command_point_badmsg panic morse_PX command_point_busy panic morse_PB +command_point_cduempty panic morse_PC ;---------- command_point_ifslave @@ -344,41 +351,53 @@ points_getwritebyte cdu_init clr_f pointslave clr_f pointmsg - clr_f cducharging +;... +;----- +cdu_offp +cdu_panichook + pin_l p0_cdu_enable +;... +;----- +cdu_discharged + mov_lw cdu_timeout / 10 ; time in ms, converted to 10ms ticks + mov_wf cducharging + return + +;-------------------- +cdu_on + pin_h p0_cdu_enable return ;-------------------- cdu_tick + bt_f_if0 LATB, p0_cdu_enable >> 4 + return + tst_f_ifnz cducharging dec_f_ifnz cducharging ; so, decrement only if it was nonzero return ; return if we either didn't decrement, ; or didn't reach zero - bt_f_if0 pointmsg, 7 - bra cdu_charged_not_charging - ; ok: - - clr_f pointmsg ; cducharging is already zero, from above mov_lw b'00101000' ; CHARGED goto serial_addbyte -cdu_charged_not_charging panic morse_PQ - near_gots code ;-------------------- got_pointed tst_f_ifnz cducharging bra pointed_already_charging + bt_f_if0 pointmsg, 7 bra pointed_butnot_firing - mov_lw cdu_timeout / 10 ; time in ms, converted to 10ms ticks - mov_wf cducharging + + clr_f pointmsg + call cdu_discharged mov_lw b'00100000' ; POINTED goto serial_addbyte pointed_butnot_firing panic morse_PA -pointed_already_charging panic morse_PC +pointed_already_charging panic morse_PQ ;====================================================================== include final.inc diff --git a/detpic/points.fin b/detpic/points.fin index 38ccdc9..33ea40c 100644 --- a/detpic/points.fin +++ b/detpic/points.fin @@ -8,3 +8,6 @@ extern got_pointed extern cdu_init extern cdu_tick + extern cdu_on + extern cdu_off + extern cdu_panichook diff --git a/detpic/program.asm b/detpic/program.asm index 18333e5..b11ed6f 100644 --- a/detpic/program.asm +++ b/detpic/program.asm @@ -56,6 +56,9 @@ common_local_init ;---------------------------------------- panic_kill_hook + call power_panichook + call cdu_panichook + return ;---------- intrl_handled_routine -- 2.30.2