nmractrl res 1 ; state relevant to NMRA control
transmitbit equ 7 ; bit 7: 0/1 bit currently being transmitted
nextaction equ 6 ; bit 6: change polarity on next interrupt y/n
- ; nmractrl is a bitmask, and only the bits above are used
+ ; nmractrl is a bitmask, and only the bits above are used
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
- ;
- ; buffers are each 16 bytes (this is hardwired)
- ; and there are four of them starting at 0x500, 0x510, 0x520, 0x530.
- ; plus a copy of the watchdog `stop everything' command at 0x540.
- ;
- ; fromserial and totrack are pointers into the buffer page
- ;
- ; fromserial points to the first empty byte, where we will put new
- ; 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. 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
- ; because there is no nmra data at all then totrack points to the
- ; start of the same buffer as fromserial
- ;
- ; We maintain the following properties, notionally:
- ;
- ; totrack <= fromserial < totrack
- ;
- ; \ \
- ; \ `- equal would mean overrun
- ; \
- ; `- equal if we have nothing but
- ; idle to trasmit
- ;
+ ;
+ ; buffers are each 16 bytes (this is hardwired)
+ ; and there are four of them starting at 0x500, 0x510, 0x520, 0x530.
+ ; plus a copy of the watchdog `stop everything' command at 0x540.
+ ;
+ ; fromserial and totrack are pointers into the buffer page
+ ;
+ ; fromserial points to the first empty byte, where we will put new
+ ; 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. 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
+ ; because there is no nmra data at all then totrack points to the
+ ; start of the same buffer as fromserial
+ ;
+ ; We maintain the following properties, notionally:
+ ;
+ ; totrack <= fromserial < totrack
+ ;
+ ; \ \
+ ; \ `- equal would mean overrun
+ ; \
+ ; `- equal if we have nothing but
+ ; idle to trasmit
+ ;
bufferpage equ 5