; PCLATH Low ISR Not used
; t_dolocal Low ISR High ISR
; FSR1 Low ISR High ISR (detect[1])
-; FSR2 Low ISR High ISR (detect[1])
+; FSR2 High ISR (nmra) High ISR (detect[1])
;
; Trashed May be trashed by any routine anywhere. Saved
; during every ISR entry/exit.
; saves that register for the benefit of its callers.
;
; [1] FSR1 and FSR2 on slave pics are reserved exclusively for the
-; I2C response and detection code (detect.asm), after det_slave_init.
+; I2C response and detection code (detect.asm), after
+; detect_slave_init. Likewise FSR2 is reserved exclusively
+; for the NMRA output ISR after nmra_init.
;
; General-purpose hardware allocation:
;
; nmractrl is a bitmask, and only the bits above are used
fromserial res 1 ; from-serial buffer location (in buffer bank)
-totrack res 1 ; to-track buffer location (in buffer bank)
+totrack equ FSR2L ; to-track buffer location (in buffer bank)
totrackbit res 1 ; bit location of pointer within byte
;
; buffers are each 16 bytes (this is hardwired)
; initialise buffers (for bank 5, for nmra from-serial/to-track buffers)
mov_lw bufferpage
+ mov_wf FSR2H
clr_fa nmractrl ; for bits relevant to control of nmra stream
clr_fa fromserial ; for loc'n of write-from-usart ptr in buffers
; set na=cb=bit value, advance bit (i.e. rotate transmitbit right),
; check if bit7, if so, advance byte, return
- fixme save and restore FSR1
- fixme check other to-be-saved stuff ??
debug 'p'
- mov_ff totrack,FSR1L ; set low byte of IND1 pointer
- mov_lw bufferpage
- mov_wfa FSR1H ; set high byte of IND1 pointer
- mov_ff INDF1,WREG
+ mov_ff INDF2, WREG
and_wfwa totrackbit ; select bit to be transmitted
bra_z zero_bit_to_track
; currently on bit 7 of the byte, after having read rest of byte to
; track; check whether it is 1 or 0
- mov_ff totrack,FSR1L
- mov_lw bufferpage
- mov_wfa FSR1H
; if set, move to next buffer
- bt_fa_if1 INDF1,7
+ bt_fa_if1 INDF2,7
call advance_read_buffer
; if not set, move to next byte of samebuffer (increment totrack)
; (will be on bit 7 at this point anyway so no need to change totrackbit)
- bt_fa_if0 INDF1,7
+ bt_fa_if0 INDF2,7
inc_fa totrack
return