From: ian Date: Sun, 25 Dec 2005 16:56:39 +0000 (+0000) Subject: abolish lasttelldone in favour of acknmra X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=74bf865d4a1cd0f395ac002bdee100ad1f180df2;p=trains.git abolish lasttelldone in favour of acknmra --- diff --git a/detpic/morse.messages b/detpic/morse.messages index 96592f6..550f8bc 100644 --- a/detpic/morse.messages +++ b/detpic/morse.messages @@ -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 diff --git a/detpic/nmra-stream.asm b/detpic/nmra-stream.asm index 89a8588..4bd54b5 100644 --- a/detpic/nmra-stream.asm +++ b/detpic/nmra-stream.asm @@ -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 diff --git a/detpic/variables.asm b/detpic/variables.asm index 18681e3..90db760 100644 --- a/detpic/variables.asm +++ b/detpic/variables.asm @@ -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)