chiark / gitweb /
incoming point commands and outgoing to slave; ping commands
authorian <ian>
Mon, 26 Dec 2005 00:10:49 +0000 (00:10 +0000)
committerian <ian>
Mon, 26 Dec 2005 00:10:49 +0000 (00:10 +0000)
detpic/morse.messages
detpic/points.asm
detpic/program.asm

index 9491ae6a152bcf11ab5f580232793f4e9fdebbc9..e4a33f462a14ed936a1e4430f7c7cf11227b39de 100644 (file)
@@ -30,6 +30,7 @@ HF                            ; host RS232 framing error
 HN                             ; host sent too much NMRA - buffers full
 HM                             ; host sent too much NMRA - ack count overflow
 HB                             ; data for host overran buffer
+HP                             ; host sent >2-byte PING command
 
 # Regarding communications by master with slaves
 MX                             ; slave (or intern) sent bad extra byte
@@ -95,3 +96,5 @@ PB    points:pointmsg                 ; Firing point when already busy
 PI     points:pointmsg,T3CON           ; Unexpected Timer 3 interrupt
 PU     points:pointmsg                 ; Firing nonexistent point
 PF     ::t                             ; Flash mentions point not on board
+PX                                     ; Host sent >2-byte POINT command
+PM                                     ; Firing point when master/CDU busy
index 7ca27a442ff13c760a155da51cacdf7257ef885c..b7199bfe566abdd2c68bdecd2fba567db3535f10 100644 (file)
@@ -6,9 +6,10 @@
 ;----------------------------------------
 ; LOCAL POINTS - Variables, hardware, etc.
 ;
-;                      Idle            Firing
-;      Timer 3         Off             On, counting up
-;      pointmsg        undefined       message from master
+;              Idle        Idle        Firing                  Charging
+;              (slave)     (master)                            (master)
+; Timer 3      Off         Off         On, counting up         Off
+; pointmsg     undefined   0x00        message from master     message
 
 ptix2latbit equ 0x300 ; has to be a multiple of 0x100
 ptix2latbit_section udata ptix2latbit
@@ -16,6 +17,7 @@ ptix2latbit_section udata ptix2latbit
                        ; for unused point, 0x00 and 0x00
 
  udata_acs
+pointslave             res     1       ; 00SS Sss0  ie slave*2 !
 pointmsg               res     1
 
 ;======================================================================
@@ -233,6 +235,64 @@ point_timer_init_endif_masterslave
 
 ;======================================================================
 
+;----------------------------------------------------------------------
+command_point
+                                       ; FSR0 -> 1 0100 TTT  O TTTTTTT
+                                       ; ie            1010 0SSS
+                                       ;               OssT tttt
+       tst_f_ifnz pointmsg
+       bra     command_point_busy
+
+       swap_fw POSTINC0                ; W =           0SSS 1010
+       and_lw  0x70                    ; W =           0SSS 0000
+       rr_w                            ; W =           00SS S000
+       mov_wf  pointslave              ; pointslave =  00SS S000
+
+       mov_fw  INDF0                   ; W =           OssT tttt  N = O
+       bra_n   command_point_badmsg
+       ; OK:                           ; W =           0ssT tttt
+       and_lw  0x1f                    ; W =           000T tttt
+       bs_w    7                       ; W =           100T tttt
+       mov_wf  pointmsg                ; pointmsg =    100T tttt
+
+       swap_fw INDF0                   ; W =           tttt 0ssT
+       and_lw  0x06                    ; W =           0000 0ss0
+       ior_wff pointslave              ; pointslave =  00SS Sss0
+
+       rr_fw   pointslave              ; W =           000S SSss
+       bra_nz  point_needwrite_yes
+
+       mov_fw  pointmsg
+       goto    point_local_do
+
+command_point_badmsg panic morse_PX
+command_point_busy panic morse_PB
+
+;----------
+points_needwrite
+       rr_fw   pointslave              ; W =           000S SSss
+       bt_f_if1 STATUS, Z ; nothing ?
+       return
+       ; we need to write something:
+;...
+;----------
+point_needwrite_yes
+       pop
+       goto    i2c_needwrite
+
+;----------
+points_getwritebyte
+       rr_fw   pointslave
+       xor_wfw cwslave
+       bt_f_if0 STATUS, Z ; right slave ?
+       return
+       ; yes:
+       mov_fw  pointslave
+       goto    i2c_getwritebyte_yes
+
+;======================================================================
+; CDU
+
 near_gots code
 
 cdu_init       panic   morse_UCI
@@ -240,4 +300,5 @@ cdu_init    panic   morse_UCI
 
 got_pointed    panic   morse_UCP
 
+;======================================================================
  include final.inc
index bce676150ff094d162a7a4ee0b70704284062b8a..3a862fad3cbe09be4266017cdb3e93ca71c65d85 100644 (file)
@@ -121,7 +121,7 @@ serialrx_if_multibyte
        add_wff PCL
        ; <--- here is zero
 
-               goto    serialrx_bad            ; 1 0000 xxx
+               goto    serialrx_bad            ; 1 0000 xxx
        goto    command_ping            ; 1 0001 xxx
        goto    command_polarity        ; 1 0010 xxx
        goto    serialrx_bad            ; 1 0011 xxx
@@ -149,7 +149,16 @@ serialrx_bad
 
 ;--------------------
 command_ping
-command_point
+       mov_fw  POSTINC0
+       mov_ff  INDF0, t
+       call    serial_addbyte
+       mov_fw  t
+       bra_n   command_ping_bad
+       goto    serial_addbyte_another
+
+command_ping_bad panic morse_HP
+
+;--------------------
 command_crashed
        panic   morse_UC