chiark / gitweb /
cdu implementation, and it compiles
authorian <ian>
Tue, 27 Dec 2005 00:45:50 +0000 (00:45 +0000)
committerian <ian>
Tue, 27 Dec 2005 00:45:50 +0000 (00:45 +0000)
detpic/morse.messages
detpic/points.asm

index cabe631aa939496c922e625a94a82fa7f724a9e8..bf5dc69879f46177c3cb57b641eedab661c44ca0 100644 (file)
@@ -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
index 117d850d283e3624d7a63eea47a18a4da50fa2d0..d4d3bcdc8bb7a1ae98e7b67d8020fc46dae05700 100644 (file)
@@ -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