chiark / gitweb /
test-sofar supports crashread protocol
authorian <ian>
Sun, 18 Dec 2005 19:50:27 +0000 (19:50 +0000)
committerian <ian>
Sun, 18 Dec 2005 19:50:27 +0000 (19:50 +0000)
detpic/test-sofar.asm

index 2b256f6dbf6770df448a72f32e69b71b7fe7c3f8..5b854bf5426f9241a95058c9973784c8d979eb9f 100644 (file)
@@ -67,6 +67,7 @@
 ch                     res     1
 mode                   res     1
 mode_readhex           equ     0
+mode_crashread         res     1
 
 readwrite              res     1
  ; ff means we're writing or going to write, FSR1
@@ -96,10 +97,17 @@ master_interrupt_low
 ; buffer is 0x200 onwards
 ; FSR0 is buffer pointer
 ; FSR2 is the write cursor
+; FSR1 is the crash readout protocol cursor
+;      (and may be trashed by non-crash-readout things)
 
 master
        clr_f   mode
 
+       call    bitnum2bit_init
+       call    points_local_init
+       call    polarity_local_init
+       call    detect_local_init
+
        call    serial_setup
        call    i2cm_init
        call    led_green
@@ -138,7 +146,20 @@ serialu_read_char
 
        mov_lw  ~0x1f
        and_wfw ch
-       bra_z   m_ch_bad
+       bra_z   m_ch_readown
+
+       ; digit ?
+       mov_fw  ch
+       add_lw  -('9'+1)
+       bra_nn  m_ch_notdigit
+       add_lw  ('9'+1) - '0'
+       bra_z   m_ch_0
+       bra_nn  m_ch_digit
+
+m_ch_notdigit
+
+       bt_f_if1 mode, mode_crashread
+       bra     m_ch_crashsetown
 
        mov_lw  ','
        xor_wfw ch
@@ -164,14 +185,6 @@ serialu_read_char
        xor_wfw ch
        bra_z   m_ch_dollar
 
-       mov_fw  ch
-       add_lw  -('9'+1)
-       bra_nn  m_ch_notdigit
-       add_lw  ('9'+1) - '0'
-       bra_z   m_ch_0
-       bra_nn  m_ch_digit
-
-m_ch_notdigit
        mov_fw  ch
        mov_wf  POSTINC0
        clr_f   INDF0
@@ -200,9 +213,31 @@ m_ch_hat
 ;----------
 m_ch_setreadwrite
        mov_fw  ch
+       bra_z   m_ch_startcrashread
        mov_wf  readwrite
        return
 
+;----------
+m_ch_crashsetown
+       mov_fw  ch
+       goto    panic_crashread_setpointer
+
+;----------
+m_ch_readown
+       bc_f    ch, 4 ; ch is now our byte counter
+m_ch_readown_loop
+       mov_fw  POSTINC1
+       call    serial_write_char
+       dec_f_ifnz ch
+       bra     m_ch_readown_loop
+       return
+
+;----------
+m_ch_startcrashread
+       bs_f    mode,mode_crashread
+       mov_lfsr 0x0,1
+       return
+
 ;----------
 m_ch_comma
        goto    i2cm_read_another