chiark / gitweb /
i2c read events supposedly done; now try to compile
authorian <ian>
Thu, 22 Dec 2005 13:22:46 +0000 (13:22 +0000)
committerian <ian>
Thu, 22 Dec 2005 13:22:46 +0000 (13:22 +0000)
detpic/Makefile
detpic/mascan.asm
detpic/morse.messages
detpic/serout.asm [new file with mode: 0644]
detpic/serout.fin [new file with mode: 0644]
detpic/variables.asm

index 04dc7d554869fb565b2ee0d09874a8dcbf16b1cd..1d8b12c26713ad04ade4f139e7bf80491c3fa2af 100644 (file)
@@ -4,7 +4,7 @@ PICNOS=         0 1 2
 
 PROGRAMS=              program
 OBJS_program=          vectors.o panic.o routines-led.o i2clib.o       \
-                       misc.o detect.o variables.o points.o            \
+                       misc.o detect.o variables.o points.o serout.o   \
                        syncwrite.o reverse.o nmra-stream.o mascan.o
 XCODEN_program=        morse
 XCODE1_program=        ours+pindata
@@ -27,6 +27,7 @@ INCLUDES=                                     \
                program.fin                     \
                reverse.fin                     \
                routines-led.fin                \
+               serout.fin                      \
                vectors.fin                     \
 
 VARSFILES=     variables
index 65a16f1ee0663c4785b06fddf11ef805b43f919e..23e80e2f9f1a846c238f663766f7e564ae144f5e 100644 (file)
@@ -3,6 +3,7 @@
 
  include common.inc
 
+;----------------------------------------------------------------------
  udata_acs
 
 b      res     1       ; byte just read
@@ -10,20 +11,11 @@ cslot       res     1       ; current slave in slave table, points to flags byte
 cbyte  res     1
        ; one of the following:
        ;       0000 0000       we're expecting the first byte
-       ;       
-       ;       M0BB 0001       we have rec
-       ;       M0BB 0001       we have rec
-
-       ;       MM zz B2 B1 zz zz zz II
-       ;
-       ;       main byte from slave
-; M0BB0000
-                       ; where M is 1 iff we're expecting an `extra byte'
-                       ; otherwise NN is the detection byte we're expecting
-
-sc             res     1
-sc_extra       equ     7 ; we're 
+       ;       M0B1 0000       we're expecting more detection byte 1
+       ;       M010 0000       we're expecting more detection byte 2
+       ;       1000 0000       we're expecting an extra byte
 
+;----------------------------------------------------------------------
 slavetable_section udata 0x280
 
 ste_szln2      equ     3
@@ -42,6 +34,7 @@ stf_detect    equ     7
 
  code
 ;======================================================================
+; HANDLING OF I2C EVENTS
 
 ;----------------------------------------
 i2cm_intrl
@@ -52,6 +45,16 @@ i2cm_intrl
        call    i2cm_interrupt_definite
        intrl_handled_nostack
 
+;----------------------------------------
+i2cmu_done     panic   morse_MD
+
+;----------------------------------------
+i2cmu_write_next_byte
+       panic   morse_UI
+
+;======================================================================
+; PROCESSING OF INCOMING BYTES
+
 ;----------------------------------------
 i2cmu_read_got_byte
 ;              Beforehand      At call
@@ -117,32 +120,6 @@ read_got_detectbyte_something
        ior_wff FSR1L           ; FSR1L ->      detmsgh
        return ; to addmsgs_<something>
 
-;----------
-read_prep_detectbyte
-;  W           adjusted detbase l
-;  cbyte       set for next byte to read
-;  b           received byte
-;  FSR1 ->     lastd<n>
-;  TOS ->      goto addmsgs_<something>
-;  NOS         return address for i2cmu_read_got_byte
-       mov_wf  t               ; t =           adj.detbasel
-       mov_fw  b               ; W =           ?d??dddd
-       xor_wfw INDF1           ; lastd<n> =    ?C??CCCC, Z iff same
-       bra_nz  read_got_detectbyte_something
-       xor_wfw INDF1           ; lastd<n> =    ?d??dddd
-       ; there's nothing to do
-       pop
-;...
-;----------------------------------------
-i2c_arrange_next_byte
-       tst_f_ifnz cbyte
-       goto    i2cm_read_another
-;...
-;----------------------------------------
-i2c_arrange_something
-; figure out what to do next - which pic to address, etc.
-       panic   morse_UG
-
 ;----------------------------------------
 read_got_notfirst
        bt_f_if1 cbyte, 4
@@ -154,7 +131,7 @@ read_got_notfirst
        bt_f_if0 b, 7           ; any more ?
        bc_f    cbyte, 7
        bc_f    b, 7
-       call    process_got_extra
+       rcall   process_got_extra
        bra     i2c_arrange_next_byte
 
 ;----------------------------------------
@@ -169,7 +146,36 @@ loopback_read_byte
        bra_z   slave_got_aargh
        panic   morse_MX
 
-;========================================
+;----------
+read_prep_detectbyte
+;  W           adjusted detbase l
+;  cbyte       set for next byte to read
+;  b           received byte
+;  FSR1 ->     lastd<n>
+;  TOS ->      goto addmsgs_<something>
+;  NOS         return address for i2cmu_read_got_byte
+       mov_wf  t               ; t =           adj.detbasel
+       mov_fw  b               ; W =           ?d??dddd
+       xor_wfw INDF1           ; lastd<n> =    ?C??CCCC, Z iff same
+       bra_nz  read_got_detectbyte_something
+       xor_wfw INDF1           ; lastd<n> =    ?d??dddd
+       ; there's nothing to do
+       pop
+;...
+;----------------------------------------
+i2c_arrange_next_byte
+       tst_f_ifnz cbyte
+       goto    i2cm_read_another
+;...
+;======================================================================
+; DECIDING WHICH SLAVE TO ADDRESS
+;...
+i2c_arrange_something
+; figure out what to do next - which pic to address, etc.
+       panic   morse_UG
+
+;======================================================================
+; GENERATION OF DETECTION MESSAGES FOR HOST - MAD BT_F_IF1 TABLES
 
 addmsg_testbit macro bit
        bt_f_if1 w, bit
@@ -239,70 +245,13 @@ addmsg
        mov_fw  INDF1           ; W =           1 001 0 SSS
        mov_wf  u               ; u =           1 001 0 SSS
        mov_fw  b               ; W =           ?d??dddd
-stuff here
-       and_wfw INDF0           ; W =           .....d..
-
-       xor_wfw
-
-       bt_w_if1 INDF1,
-
-
-
-
-read_got_detectbyte_allsame
-       mov_wf  INDF1           ; lastd<n> =    ?d??dddd
-
-       pop     ; skip return address
-read_done_byte
-
-
-
-       and_lw  0x80            ; W =           M0BB0000 / M0000000 ie M0BB0000
-
-       ; this is a first (head) byte from a detectors board:
-
-                               
-       and_lw  0xb0            ; W =           M0BB0000
-       
-read_got_
-       mov_fw  b
-       xor_wf  PREINC1, 
-
-       mov_wf  b
-
-       mov_
-       and_lw  
-
-       
-                               ; W = b =       MdBBdddd / 
-       and_wfw INDF1           ; flags, =      10110000 / 10000000
-       mov_wf  cbyte           ; cbyte =       M0BB0000 / M0000000
-
-       bt_f_
-       
-       
-
-       bt_f_if1 cbyte, 4
-       bra     read_got_moredet1
-       bt_f_if1 cbyte, 5
-       bra     read_got_moredet2
-       
-       
-       mov_fw  cbyte
-       
-       bra_n   read_got_extra
-       bra_nz  read_got_moredet
-
-       bt_f_if1 sc, sc_extra
-       bra     got_read_extra
-
-got_read_extra
-       panic   morse_UX
-
-;----------------------------------------
-i2cmu_done
-i2cmu_write_next_byte
-       panic   morse_UI
+       and_wfw INDF0           ; W =           .....d..,  Z iff detect
+       bt_f_if1 STATUS, Z
+       bs_f    u, 3            ; u =           1 001 Y SSS
+       mov_fw  u
+       rcall   serial_addbyte
+       mov_fw  t
+       goto    serial_addbyte_another
 
 ;======================================================================
  include final.inc
index cd704f39d896b8b56665b9a768e62d097c68ae94..85c1c53f3c6fdebb61116d8831cc0fd71df7e526 100644 (file)
@@ -27,10 +27,12 @@ HW  ::t                     ; host sent message which was too long
 HO                             ; host RS232 read overrun
 HF                             ; host RS232 framing error
 HN                             ; host sent too much NMRA - buffers full
+HB                             ; data for host overran buffer
 
 # Regarding communications by master with slaves
 MX                             ; slave (or intern) sent bad extra byte
 MR     mascan::b,mascan::cslot ; reversers set byte with zz bit set
+MD                             ; i2cmu_done !
 
 # Problematic interrupts
 IH     INTCON,INTCON3,PIR1,PIR2,PIR3 ; Interrupt source not found (high pri.)
diff --git a/detpic/serout.asm b/detpic/serout.asm
new file mode 100644 (file)
index 0000000..cd5e845
--- /dev/null
@@ -0,0 +1,30 @@
+;======================================================================
+
+;----------------------------------------
+serial_addbyte
+;  W           byte for transmission to host   trashed
+;  FSR0                any                             set for serial_addbyte_another
+;  outmsg_*    buffer not full                 adjusted appropriately
+;  STATUS      any                             trashed
+;  all others  any                             not interfered with
+;
+       mov_lfsr outbuf, 0
+       mov_ff  outmsg_end, FSR0L
+;...
+serial_addbyte_another
+;  W           byte for transmission to host   trashed
+;  FSR0                from serial_addbyte[_another]   set for serial_addbyte_another
+;  outmsg_*    buffer not full                 adjusted appropriately
+;  STATUS      any                             trashed
+;  all others  any                             not interfered with
+;
+       mov_wf  POSTIN0C
+       bc_f    FSR0L, 7
+       mov_fw  FSR0L
+       mov_wf  outmsg_end
+       xor_wfw outmsg_begin
+       bra_z   serial_addbyte_toomany
+       return
+
+;-----
+serial_addbyte_toomany panic morse_HB
diff --git a/detpic/serout.fin b/detpic/serout.fin
new file mode 100644 (file)
index 0000000..ea60779
--- /dev/null
@@ -0,0 +1,2 @@
+ extern serial_addbyte
+ extern serial_addbyte_another
index 9dfca8255497bd704333c269e06a3ad0f12b443f..b17624062a8d0d8d508a02bf60391b06073bc9d4 100644 (file)
@@ -15,6 +15,7 @@ t             res     1       ; general temporary
 u              res     1       ; general temporary (another)
 t_dolocal      res     1       ; temporary for <foo>_local_do
 outmsg_end     res     1       ; first empty byte in outbuf
+outmsg_begin   res     1       ; first full byte in outbuf
 
 isr_low_save_w         res     1 ; see {enter,return}_interrupt_low
 isr_low_save_status    res     1 ;  in common.inc