chiark / gitweb /
manage CDU fullness separately from point firing
authorian <ian>
Tue, 27 Dec 2005 01:04:35 +0000 (01:04 +0000)
committerian <ian>
Tue, 27 Dec 2005 01:04:35 +0000 (01:04 +0000)
detpic/energy.asm
detpic/energy.fin
detpic/morse.messages
detpic/points.asm
detpic/points.fin
detpic/program.asm

index dab5b8006971ee0134f6f80aecdf46f6f38ff7c8..dbdebd98432256ca20d6bc29131f7ff3e7fcb435 100644 (file)
@@ -19,5 +19,8 @@ command_power
 power_polarising
        panic   morse_UER
 
+power_panichook
+       panic   morse_UEP
+
 ;======================================================================
  include final.inc
index c0549dbba6a6214a0bc9d259ae48846515e83062..5fd3c0d00c94e9df32127e2f27dddc3980449caf 100644 (file)
@@ -1,2 +1,3 @@
  extern command_power
  extern power_polarising
+ extern power_panichook
index bf5dc69879f46177c3cb57b641eedab661c44ca0..06c9d15c5b32d7ea2d369b064dfdabbd88c2dc5d 100644 (file)
@@ -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
index d4d3bcdc8bb7a1ae98e7b67d8020fc46dae05700..62527b03e624d58955092e7a727911b983194bec 100644 (file)
 ; 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
index 38ccdc9ee33b3738e8e362c4a84bc50952701290..33ea40c1005a7fe4620e1d9dc0804be834f23b26 100644 (file)
@@ -8,3 +8,6 @@
  extern got_pointed
  extern cdu_init
  extern cdu_tick
+ extern cdu_on
+ extern cdu_off
+ extern cdu_panichook
index 18333e51c90bf7b8d8c59625184dcb4c40ebe018..b11ed6f677c29f47efe621d5182db0ce8989e4db 100644 (file)
@@ -56,6 +56,9 @@ common_local_init
 
 ;----------------------------------------
 panic_kill_hook
+       call    power_panichook
+       call    cdu_panichook
+       return
 
 ;----------
 intrl_handled_routine