From: ian Date: Sat, 10 May 2008 11:43:12 +0000 (+0000) Subject: Implement waggle X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=d291e4bf7ed8cad298c2e436fb2a9794beaabd9e;p=trains.git Implement waggle --- diff --git a/detpic/Makefile b/detpic/Makefile index b947e9e..32ad5ef 100644 --- a/detpic/Makefile +++ b/detpic/Makefile @@ -4,7 +4,7 @@ PICNOS= 0 1 2 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 diff --git a/detpic/common.inc b/detpic/common.inc index afbd055..c92abfa 100644 --- a/detpic/common.inc +++ b/detpic/common.inc @@ -49,7 +49,7 @@ tickdiv_us equ tick_us * tickdiv ; 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. @@ -189,14 +189,14 @@ enter_interrupt_low macro 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 diff --git a/detpic/detect.asm b/detpic/detect.asm index 49bcf74..3d57473 100644 --- a/detpic/detect.asm +++ b/detpic/detect.asm @@ -50,6 +50,7 @@ ; ; 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 diff --git a/detpic/mascan.asm b/detpic/mascan.asm index 36c16f4..9a1b820 100644 --- a/detpic/mascan.asm +++ b/detpic/mascan.asm @@ -42,6 +42,7 @@ i2cmu_write_next_byte Dl 0x91 ; add calls to getwritebyte_ here: call polarity_getwritebyte + call waggle_getwritebyte call points_getwritebyte ; end of list of calls to getwritebyte_ ; so, no-one wants this slave: @@ -253,6 +254,7 @@ i2cmu_done ; Anyone else to write to ? ; add calls to needwrite_ here: call polarity_needwrite + call waggle_needwrite call points_needwrite ; end of list of calls to needwrite_ diff --git a/detpic/morse.messages b/detpic/morse.messages index 5a23384..e35a02b 100644 --- a/detpic/morse.messages +++ b/detpic/morse.messages @@ -57,6 +57,11 @@ IL INTCON,INTCON3,PIR1,PIR2 ; Interrupt source not found (low pri.) # 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 diff --git a/detpic/points.asm b/detpic/points.asm index 8f711a1..9ccc07b 100644 --- a/detpic/points.asm +++ b/detpic/points.asm @@ -56,9 +56,9 @@ point_local_do @ 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 @@ -234,9 +234,6 @@ points_needwrite @ bt_f_if1 STATUS, Z ; nothing ? return ; we need to write something: -;... -;---------- -point_needwrite_yes pop goto i2c_needwrite diff --git a/detpic/program.asm b/detpic/program.asm index 43f7fd7..b210f21 100644 --- a/detpic/program.asm +++ b/detpic/program.asm @@ -221,6 +221,8 @@ i2csu_write_data 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 diff --git a/detpic/variables.asm b/detpic/variables.asm index 978571e..d06b87c 100644 --- a/detpic/variables.asm +++ b/detpic/variables.asm @@ -24,7 +24,7 @@ isr_low_save_w res 1 ; see {enter,return}_interrupt_low 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 diff --git a/detpic/waggle.asm b/detpic/waggle.asm index ab56f0c..f5beee3 100644 --- a/detpic/waggle.asm +++ b/detpic/waggle.asm @@ -84,29 +84,25 @@ wagglers_local_init ;---------------------------------------------------------------------- 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 ;----------