chiark / gitweb /
non-autoretrying short circuit cutout
authorian <ian>
Fri, 16 May 2008 18:17:44 +0000 (18:17 +0000)
committerian <ian>
Fri, 16 May 2008 18:17:44 +0000 (18:17 +0000)
cebpic/README.protocol
detpic/energy.asm
hostside/startup.c

index 1f59b99794b35c5505cc9e2691b47605c81f4189..abc89e89e15199b6d69c9b8e6d2ce86d99aba1a9 100644 (file)
@@ -67,7 +67,7 @@ From PIC to host:
  < 0 000 1011             (VT)  AAARGH   Followed by debug chars (only)
  < 0 000 1101             (CR)  WTIMEOUT  Watchdog timeout happened
  < 0 000 0111             (BEL) FAULT    Fault exists
- < 0 000 0110             (ACK) FIXED    Fault now fixed
+ < 0 000 0110             (ACK) RETRIABLE Fault may be tested once more
  < 0 000 0100             (ENQ)        WAGGLED   Pin changed according to WAGGLE
  < 0 0100 PPP             (20+)        POINTED   Point change done using capacitor P
  < 0 0101 PPP             (28+)        CHARGED   Point capacitor P is now charged
@@ -119,22 +119,21 @@ should be reenabled when the host transmits ON.
 
        Track and CDU                     Track and CDU
         disabled      -------ON------->          enabled
-               .
-              /|\                           |
-               |                            |Short circuit detected
-                \                           |
-                 \FIXED                   FAULT
-                  \                         |
-                   \__________________      V
-                       operator       `
-                   fixes the short     Short circuit
-                                     (User Fault indicator lit)
-
-
-If OFF is issued in the first 500ms following a short circuit, it will
-be ignored; if the short circuit persists, OFF during the following
-period will go to the `Track and CDU disabled' state without sending
-FIXED.
+          .     __                   __
+         /|\   |`-._             ON  ,-'|    |
+          |         `-._          ,-'        |Short circuit detected
+         |         OFF `-._   ,-'           |
+       OFF|                 ,-' _          FAULT
+         |              ,-'     `-._        |
+         |           ,-'           `-._     V
+                    '                  `
+       Track disabled                     Wait for post-fault
+       CDU enabled     <-----500ms------   minimum off time
+       User Fault lit       RETRIABLE
+
+
+If ON or OFF are issued in the first 500ms following a short circuit,
+they are ignored.
 
 
 POINTS and CDU
index c94d451494f0445934b998c357c0d59d91089afe..9fa46424c217c0f2f5435bcb5479f75f88446b2f 100644 (file)
@@ -81,19 +81,16 @@ power_polarising_tick @
 ;
 ; Off      shutdown  off  none   off                                 On
 ; On       power-up  on   none   off         Stopping,FAULT              Off
-; Stopping  shutdown  on   500ms  50% 1/100ms               Retry
-; Retry            power-up  off  50ms   off         Persists       Off,FIXED    Off
-; Persists  shutdown  off  90ms          on                         Retry        Off
-;
+; Stopping  shutdown  on   500ms  50% 1/100ms               Retriable
+; Retriable shutdown  on   none          on                                  On  Off
 ;                                              (no notation: event ignored)
 ;
-;              shutdown LAT    stop_wait       retry_wait
+;              shutdown LAT    stop_wait       retry_wait      cdu pointstate
 ;
-; Off          H (shutdown)    0               0
-; On           L (power-up)    0               0
-; Stopping     H (shutdown)    before Retry    for LED flash
-; Retry                L (power-up)    0               before Off
-; Persists     H (shutdown)    0               before retry
+; Off          H (shutdown)    0               0               off Charging
+; On           L (power-up)    0               0               on  any
+; Stopping     H (shutdown)    before Retry    for LED flash   on  any
+; Retriable    H (shutdown)    0               0               on  any
 ;
 ;                              (uses tickdiv)  (uses tick)
 
@@ -114,28 +111,23 @@ power_fault_init @
 command_power_section code 0x2080
 ;--------------------
 command_power_on @
-; Off -> On; noop in other states
-       pinlat_ifl p0_booster_shutdown
-       return  ; On or Retry
-       ; might be Off, Stopping or Persists:
-
-       tst_f_ifnz retry_wait
-       return  ; that deals with Stopping or Persists
-       ; must be Off:
+; Off, Retriable -> On; noop in other states
+       tst_f_ifnz stop_wait
+       return  ; that deals with Stopping
+       ; might be Off, On or Retriable, so safe to just turn On
 
+       pin_vh  p0_booster_userfault
+       pin_vh  p0_booster_pwm
        pin_vl  p0_booster_shutdown
-       Dl 0x81
        goto    cdu_on
 
 ;----------
 command_power_off @
-; On, Retry, Persists -> Off;  noop in Off or Stopping
+; On, Retriable -> Off;  noop in Off or Stopping
        tst_f_ifnz stop_wait
        return  ; that deals with Stopping
-       ; must be On, Off, Retry or Persists:
-       ; (it's harmless to do this if we were already Off)
-power_off_now
-       clr_f   retry_wait
+       ; must be Off, On or Retriable, so safe to just turn Off
+
        pin_vh  p0_booster_userfault
        pin_vh  p0_booster_shutdown
        goto    cdu_off
@@ -161,26 +153,15 @@ power_fault_intrl @
 
 ;-----
 fault_isactual
-       pinlat_ifh p0_booster_shutdown
-       bra faultintrl_noop
-               ; Off, Stopping or Persists - must have lost the race
-               ;  or flapped while we faffed.  Well, never mind, it's
-               ;  off now and we're taking care of it.  (If the host
-               ;  caused Off by OFF they can at worst send an OFF and
-               ;  immediate ON in about 2ms, so worst-case duty cycle
-               ;  for a short (if the host is perversely timed) is
-               ;      (our interrupt latency) / 2ms
-               ;  and if they ever don't manage to get the OFF through
-               ;  in time then we go into Stopping.)
-       ; must be On or Retry:
-
+       pin_vl  p0_booster_pwm
        pin_vh  p0_booster_shutdown
-       tst_f_ifnz retry_wait
-       bra     fault_persists ; that deals with Retry
-       ; must be On:
+
+       tst_f_ifnz stop_wait
+       bra     fault_isactual_ifalreadystopping
 
        mov_lw  b'00000111'
        call    serial_addbyte
+fault_isactual_ifalreadystopping
 
        mov_lw  stop_timeout / tickdiv_us
        mov_wf  stop_wait
@@ -188,36 +169,15 @@ fault_isactual
        rcall   power_stop_doflash
        intrl_handled_nostack
 
-;-----
-fault_persists ; Retry -> Persists (booster was shut down just a moment ago)
-       mov_lw  persist_timeout / tick_us
-       mov_wf  retry_wait
-       pin_vl  p0_booster_userfault
-faultintrl_noop
-       intrl_handled_nostack
-
 ;--------------------
 power_fault_tick @
        tst_f_ifnz retry_wait
        dec_f_ifnz retry_wait
        return
        ; retry_wait was running but has just reached zero;
-       ; we were in Stopping, Retry or Persists:
+       ; we were in Stopping.
 
-       tst_f_ifnz stop_wait
-       bra     power_stop_doflash ; that deals with Stopping (just flash)
-       ; must be Retry or Persists:
-
-       pinlat_ifh p0_booster_shutdown
-       bra     power_retry ; we were in Persists, now we can try again
-       ; we were in Retry and it worked.
-; go to Off:
-       pin_vh  p0_booster_shutdown
-       pin_vh  p0_booster_userfault
-       mov_lw  b'00000110'
-       goto    serial_addbyte
-
-;----------
+;-----
 power_stop_doflash
        pin_vhl p0_booster_userfault
        mov_lw  stopflash_timeout / tick_us
@@ -234,14 +194,11 @@ fault_tickdiv_rest
        dec_f_ifnz stop_wait
        return
        ; stop_wait was running but has just reached zero;
-       ; we were in Stopping, now we can Retry:
-       call    cdu_off
-power_retry
-       mov_lw  retry_timeout / tickdiv_us
-       mov_wf  retry_wait
-       pin_vl  p0_booster_shutdown
-       pin_vh  p0_booster_userfault
-       return
+       ; we were in Stopping, go to Retriable:
+       clr_f   retry_wait
+       pin_vl  p0_booster_userfault
+       mov_lw  b'00000110'
+       goto    serial_addbyte  
 
 ;----------
 fault_spurious_tickdiv
index 7e33d0cedf2ddce2fd1059b19e620b5f90b914dd..fc97508fcbde01ce58a7a4785ae3f926cbfd2336 100644 (file)
@@ -220,11 +220,6 @@ void on_pic_pong(const PicInsnInfo *pii, const PicInsn *pi, int objnum) {
     sta_goto(Sta_Settling);
 }
 
-void on_pic_fixed(const PicInsnInfo *pii, const PicInsn *pi, int objnum) {
-  if (sta_state >= Sta_Resolving) die("PIC sent unexpected FIXED");
-  if (sta_state == Sta_Fault) sta_goto(Sta_Resolving);
-}
-
 void on_pic_fault(const PicInsnInfo *pii, const PicInsn *pi, int objnum) {
   if (sta_state <= Sta_Ping) return;
   if (sta_state == Sta_Fault) die("PIC sent two FAULTs");
@@ -247,6 +242,7 @@ void on_pic_spurious(const PicInsnInfo *pii, const PicInsn *pi, int objnum) {
          " detection interrupts\n", objnum);
 }
 void on_pic_pointed(const PicInsnInfo *pii, const PicInsn *pi, int objnum) { }
+void on_pic_retriable(const PicInsnInfo *pii, const PicInsn *pi, int objnum){}
 
 static SegmentNum on_pic_detect_prep(int detyn, int objnum) {
   SegmentNum segn;