mov_wf panic_address
clr_f STKPTR ; avoids stack overruns
+ call panic_kill_hook
+
; re-initialise timer0 config
call read_pic_no
bra_z panic_setup_if_master
;---------------------------------------------------------------------------
; macro is passed a message code morse_XY and panics displaying this message
-; by flashing the perpic LED
+; by flashing the perpic LED. After disabling interrupts and resetting
+; the stack this will call panic_kill_hook (which should shut down any
+; scary peripherals).
panic macro message
movlw (message - morse_messages_start)/4
; SPC set buffer pointer to start, set that byte to 0xff
; 0 set buffer pointer to start, clear that byte
; other append char to buffer, clear byte at buffer pointer
-;
+;
+; + turn on booster (polarity=L) and cdu
; $ toggle hex mode for reading
;
; Output characters:
xor_wfw ch
bra_z m_ch_spc
+ mov_lw '+'
+ xor_wfw ch
+ bra_z m_ch_plus
+
+ mov_lw '$'
+ xor_wfw ch
+ bra_z m_ch_dollar
+
mov_fw ch
add_lw -('9'+1)
bra_nn m_ch_notdigit
m_ch_stop
goto i2cm_read_done
+;----------
+m_ch_plus
+ pin_l p0_booster_shutdown
+ pin_l p0_booster_dirn
+ pin_h p0_booster_pwm
+ pin_h p0_cdu_enable
+ return
+
+;----------
+m_ch_dollar
+ bs_f mode,mode_readhex
+ return
+
;----------
m_ch_digit
; W now contains intended slave number
mov_fw POSTINC2
return
+;----------
+panic_kill_hook
+ bt_f_if0 idloc1,idloc1_master
+ return
+ ; master:
+ pin_h p0_booster_shutdown
+ pin_l p0_cdu_enable
+ return
+
;======================================================================
m_delay4 rcall m_delay2