FILES= variables vectors \
panic routines-led i2clib+panic \
- misc detect points serout \
+ misc detect points waggle serout \
syncwrite mascan energy \
reverse nmra-stream tick watchdog
; interrupt, or any routine run during initialisation.
; May therefore not be used in background loop with
; interrupts enabled. May not be used by high-priority
-; ISR (unless explicitly saved, eg isrh_fsr0_{save,restore}).
+; ISR (unless explicitly saved, eg intrlh_fsr0_{save,restore}).
;
; High ISR May be used/trashed by any routine run in high-priority
; interrupt, or any routine run during initialisation.
mov_ff STKPTR, isr_low_save_stkptr
endm
-intrh_fsr0_save macro
- mov_ff FSR0L, isr_high_save_fsr0
- mov_ff FSR0H, isr_high_save_fsr0+1
+intrlh_fsr0_save macro ; Low ISR on master, High ISR on slave
+ mov_ff FSR0L, isr_lh_save_fsr0
+ mov_ff FSR0H, isr_lh_save_fsr0+1
endm
-intrh_fsr0_restore macro
- mov_ff isr_high_save_fsr0, FSR0L
- mov_ff isr_high_save_fsr0+1, FSR0H
+intrlh_fsr0_restore macro
+ mov_ff isr_lh_save_fsr0, FSR0L
+ mov_ff isr_lh_save_fsr0+1, FSR0H
endm
intrl_handled_core macro ; for internal use only
;
; 11RRRRRR Set reverse to RRRRRR, see reverse.asm
; 100PPPPP Fire point PPPPP
+; 101WWWWX Set waggler WWWW to X
;
; 00000000 Acknowlege that slave has crashed, and
; switch into crash readout mode
Dl 0x91
; add calls to getwritebyte_<foo> here:
call polarity_getwritebyte
+ call waggle_getwritebyte
call points_getwritebyte
; end of list of calls to getwritebyte_<foo>
; so, no-one wants this slave:
; Anyone else to write to ?
; add calls to needwrite_<foo> here:
call polarity_needwrite
+ call waggle_needwrite
call points_needwrite
; end of list of calls to needwrite_<foo>
# W - watchdog
WX ; bad watchdog command
+# A - waggles
+AX ; Host sent >2-byte WAGGLE command
+AB ; Host WAGGLE when already waggling
+AU ; Waggling nonexistent waggle
+
# Messages for i2clib, S*
SM i2clib+panic:st,:sspstat,:sspcon1,:sspcon2 ; m.,i., ctrlr bad state
SS SSPSTAT,SSPCON1 ; s.,i., controller bad state
mov_wf pointmsg ; pointmsg = SS zz zz pp pp pp pp pp
- intrh_fsr0_save ; point_set_pin uses FSR0, see below
+ intrlh_fsr0_save ; point_set_pin uses FSR0, see below
call point_set_pin
- intrh_fsr0_restore
+ intrlh_fsr0_restore
clr_f TMR3L ; also copies TMR3H into actual timer register
bs_f T3CON, TMR3ON
bt_f_if1 STATUS, Z ; nothing ?
return
; we need to write something:
-;...
-;----------
-point_needwrite_yes
pop
goto i2c_needwrite
bra polarity_local_do
bt_w_if0 5
bra point_local_do
+ bra waggle_local_do
+
i2csu_write_if_bad
mov_wf t
panic morse_DX
isr_low_save_status res 1 ; in common.inc
isr_low_save_stkptr res 1 ;
-isr_high_save_fsr0 res 2 ; for isrh_fsr0_{save,restore}
+isr_lh_save_fsr0 res 2 ; for intrlh_fsr0_{save,restore}
xdebug res 8
;----------------------------------------------------------------------
command_waggle @
- ; ie 1010 1Yss
- ; OSSS wwww
+ ; ie 1010 1sss
+ ; OSS wwwwV
tst_f_ifnz waggle_message
bra command_waggle_busy
- mov_fw POSTINC0 ; W = 1010 1Yss
- and_lw 0x03 ; W = 0000 00ss
- mov_lw waggle_slave ; slave = 0000 00ss
+ mov_fw PREINC0 ; F0->[1], W = OSS wwwwV N = 0
+ bra_n command_waggle_badmsg
+ and_lw 0x1f ; W = 000 wwwwV
+ xor_wff INDF0 ; [1] = 0SS 00000
+ ior_lw 0xa0 ; W = 101 wwwwV
+ mov_wf waggle_message ; message = 101 wwwwV
- rr_fw INDF0 ; W = w0SSS www
- rr_w ; W = ww0SSS ww
- and_lw 0x1c ; W = 000S SS00
- add_wff waggle_slave ; slave = 000S SSss C = 0
+ rr_fw POSTDEC0 ; F0->[0], W = 00SS 0000
+ rr_w ; W = 000S S000
+ xor_wfw INDF0 ; W = 101S Tsss
+ xor_lw 0xa8 ; W = 000S Ssss
+ mov_wf waggle_slave ; slave = 000S Ssss
- ; C = Y
- rlc_fw INDF0 ; W = sss wwwwY C = O
- bra_c command_waggle_badmsg
- and_lw 0x1f ; W = 000 wwwwY
- ior_lw 0xa0 ; W = 101 wwwwY
- mov_wf waggle_message ; message = 101 wwwwY
-
- tst_f_ifnz waggle_slave
- bra waggle_local_do
+ bra_z waggle_local_do
goto i2c_needwrite
;----------