chiark / gitweb /
abolish lasttelldone in favour of acknmra
authorian <ian>
Sun, 25 Dec 2005 16:56:39 +0000 (16:56 +0000)
committerian <ian>
Sun, 25 Dec 2005 16:56:39 +0000 (16:56 +0000)
detpic/morse.messages
detpic/nmra-stream.asm
detpic/variables.asm

index 96592f6e43112155cddcbdb294d21df57ba731a6..550f8bc7d03491be30eddbc1b26224ad2f9054c4 100644 (file)
@@ -28,6 +28,7 @@ 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
+HM                             ; host sent too much NMRA - ack count overflow
 HB                             ; data for host overran buffer
 
 # Regarding communications by master with slaves
index 89a858828dfb4f1e90b7d6e1093e3c77f168d723..4bd54b52e8a1fddea75b49ea171c28b662c74ff3 100644 (file)
@@ -29,7 +29,6 @@ nextaction    equ     6       ; bit 6: change polarity on next interrupt y/n
 fromserial     res     1       ; from-serial buffer location (in buffer bank)
 totrack                equ     FSR2L   ; to-track buffer location (in buffer bank)
 totrackbit     res     1       ; bit location of pointer within byte
-lasttelldone   res     1       ; last nmra msg we've told host we've finished
  ;
  ; buffers are each 16 bytes (this is hardwired)
  ; and there are four of them starting at 0x500, 0x510, 0x520, 0x530.
@@ -48,18 +47,15 @@ lasttelldone        res     1       ; last nmra msg we've told host we've finished
  ; because there is no nmra data at all then totrack points to the
  ; start of the same buffer as fromserial
  ;
- ; lasttelldone points to the last buffer whose complete transmission
- ; we've reported to the host.
- ;
  ; We maintain the following properties, notionally:
  ;
- ;  lasttelldone <= totrack <= fromserial < lasttelldone
+ ;  totrack <= fromserial < totrack
  ;
- ;              /             \            \
- ;             '               \            `- equal would mean overrun
- ;  equal if we have            \
- ;  told the host about our      `- equal if we have nothing but
- ;  current buffer state             idle to trasmit
+ ;            \            \
+ ;             \            `- equal would mean overrun
+ ;              \
+ ;               `- equal if we have nothing but
+ ;                   idle to trasmit
  ;
 
 bufferpage     equ     5
@@ -235,7 +231,7 @@ nmra_serialrx_intrl
 serial_receive_done
        intrl_handled_nostack
 
-receive_too_much_nmra          panic   morse_HW
+receive_too_much_nmra          panic   morse_HN
 receive_message_too_long       panic   morse_HW
 
 ; *** I *think* the interrupt bit is cleared by reading out of RCREG
@@ -261,12 +257,6 @@ advance_write_buffer
                                        ;  where BB is this buffer
                                        ;   and CC is next buffer
 
-       ; we have to check our proposed new value for fromserial
-       ; against totrack before we store it in fromserial;
-       ; otherwise there's the possibility that we will store
-       ; the new value, and then the high-priority ISR will
-       ; interrupt us and advance totrack onto the buffer we've
-       ; just filled, fooling us into thinking we've overrun.
        xor_wfw totrack                 ; W =           0?DD????
        and_lw  0x30                    ;               ..DD....
        bra_z   receive_too_much_nmra   ; where DD is (fromserial buffer)
@@ -440,9 +430,12 @@ advance_read_buffer
        bc_fa   totrack,6
        debug   '9'     ; write 'v' to serial port
 
-       bs_f    flags, flags_tellnmra   ; ensure we tell
-       bs_f    PIE1, TXIE              ;  host to send us more
+       inc_f   acknmra
+       bs_f    PIE1, TXIE      ; ensure we tell host to send us more
+       bt_f_if0 acknmra, 2
        return
+       ; oops:
+       panic   morse_HM
 
 
 
index 18681e332044344a96bf5443a253b029719631dd..90db76059081fa18d029a0cd8bbfc669bdd83026 100644 (file)
@@ -9,8 +9,8 @@ idloc1          res     1       ; from 2nd idlocs byte; bit 7 is master:
 idloc1_master  equ     7
 idloc1_boarddet        equ     6
 
+acknmra                res     1       ; must tell host about NMRA buffer state
 flags          res     1       ; miscellaneous state flags
-flags_tellnmra equ     7       ; must tell host about NMRA buffer state
 
 t              res     1       ; general temporary
 u              res     1       ; general temporary (another)