From 4fef18d7d5cffebe650c46cf3303f3657063d3a5 Mon Sep 17 00:00:00 2001 From: ian Date: Tue, 27 Dec 2005 00:45:50 +0000 Subject: [PATCH] cdu implementation, and it compiles --- detpic/morse.messages | 6 ++-- detpic/points.asm | 66 +++++++++++++++++++++++++++++++++++-------- 2 files changed, 58 insertions(+), 14 deletions(-) diff --git a/detpic/morse.messages b/detpic/morse.messages index cabe631..bf5dc69 100644 --- a/detpic/morse.messages +++ b/detpic/morse.messages @@ -52,9 +52,6 @@ TI5 ; for iwj # Unimplemented things UEC UER -UCT -UCI -UCP # Messages for i2clib, S* SM i2clib+panic:st,:sspstat,:sspcon1,:sspcon2 ; m.,i., ctrlr bad state @@ -90,3 +87,6 @@ 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 +PA ; POINTED when already firing +PQ ; we're confused about CDU charged diff --git a/detpic/points.asm b/detpic/points.asm index 117d850..d4d3bcd 100644 --- a/detpic/points.asm +++ b/detpic/points.asm @@ -6,10 +6,20 @@ ;====================================================================== ; VARIABLES, HARDWARE, ETC ; -; Idle Idle Firing Charging -; (slave) (master) (master) -; Timer 3 Off Off On, counting up Off -; pointmsg undefined 0x00 message from master message +; Timer 3 pointmsg pointslave cducharging +; +; S Idle Off undefined undefined undefined +; S Firing Counting up 100PPPPP undefined undefined +; M Idle Off 00000000 0000 0000 0x00 +; 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 +; +; notes: firing see ie, slave*2 Counts down +; timeout detect.asm in ticks + +cdu_timeout equ 200 ; ms ptix2latbit equ 0x300 ; has to be a multiple of 0x100 ptix2latbit_section udata ptix2latbit @@ -17,8 +27,9 @@ ptix2latbit_section udata ptix2latbit ; for unused point, 0x00 and 0x00 udata_acs -pointslave res 1 ; 00SS Sss0 ie slave*2 ! +pointslave res 1 pointmsg res 1 +cducharging res 1 udata 0x340 slave2ptinfo res maxpics @@ -322,19 +333,52 @@ points_getwritebyte bt_f_if0 STATUS, Z ; right slave ? return ; yes: - mov_fw pointslave + clr_f pointslave ; we're writing now, excellent + mov_fw pointmsg goto i2c_getwritebyte_yes ;====================================================================== ; CDU -near_gots code +;-------------------- +cdu_init + clr_f pointslave + clr_f pointmsg + clr_f cducharging + return + +;-------------------- +cdu_tick + 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: -cdu_tick panic morse_UCT -cdu_init panic morse_UCI -; For master pic only. Sorts out the CDU's pin. + clr_f pointmsg + ; cducharging is already zero, from above + mov_lw b'00101000' ; CHARGED + goto serial_addbyte + +cdu_charged_not_charging panic morse_PQ -got_pointed panic morse_UCP +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 + mov_lw b'00100000' ; POINTED + goto serial_addbyte + +pointed_butnot_firing panic morse_PA +pointed_already_charging panic morse_PC ;====================================================================== include final.inc -- 2.30.2