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.
; 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
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
; 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)
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