From: ian Date: Wed, 21 Dec 2005 12:45:57 +0000 (+0000) Subject: make fromserial update to go to next buffer interrupt-safe; have only one invocation... X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=654ea9e4508abeb9112c27f4bfd595519382162c;p=trains.git make fromserial update to go to next buffer interrupt-safe; have only one invocation of intrl_handled_nostack --- diff --git a/detpic/nmra-stream.asm b/detpic/nmra-stream.asm index 7d01036..f88fbf4 100644 --- a/detpic/nmra-stream.asm +++ b/detpic/nmra-stream.asm @@ -39,7 +39,8 @@ totrackbit res 1 ; bit location of pointer within byte ; data provided by the host; this means that (fromserial & 0xf0) is ; the first buffer which fails to contain a complete nmra message. ; fromserial is updated only by the (low priority) serial receive - ; interrupt handler. + ; interrupt handler. Furthermore, it always maintains a correct + ; and valid value for use by the high-priority nmra readout ISR. ; ; totrack points to the first remaining full byte, which is currently ; being transmitted; if nothing is currently being transmitted @@ -217,7 +218,7 @@ fixme need to check both interrupt handlers here and look for refies too mov_lw 0x0f and_wfw fromserial bra_z receive_message_too_long - +serial_receive_done intrl_handled_nostack receive_message_too_long @@ -231,32 +232,30 @@ end_message ; so what's the first byte then ? mov_lw 0xf0 and_wff FSR0L - and_wff fromserial - com_fw INDF0 + and_wff fromserial ; fromserial := 00BB0000 + com_fw INDF0 ; where BB is this buffer bra_nz not_nmra_message ; so, first byte is FF (since complement of it is zero) ; so, move to next buffer advance_write_buffer -; clear low 4 bits of fromserial and increment top 4 bits -; aaaabbbb -> bbbbaaaa -> bbbb(aaaa+1) -> 0000(aaaa+1) -> (aaaa+1)0000 +; increment top 4 bits of fromserial (already cleared low 4 bits) debug '5' - swap_fa fromserial - inc_fa fromserial - mov_lw 0xF - and_wffa fromserial - swap_fa fromserial + mov_fw fromserial ; W = 00BB0000 + add_lw 0x10 ; W = 0?CC0000 + bc_w 6 ; W = 00CC0000 + mov_wf fromserial ; where BB is this buffer + ; and CC is next buffer + fixme check for overruns ie if we caught up with totrack -; clear bit 6 (will set back to buffer 0 if has overflowed to 4) - debug '6' - bc_fa fromserial,6 - - return + bra serial_receive_done not_nmra_message + ; we've already set FSR0 and fromserial to point + ; back to beginning of the same buffer call serialrx_generalmsg - intrl_handled_nostack + bra serial_receive_done ;****************************************************************************