; must be Off:
pin_vl p0_booster_shutdown
- D 0x60
+ D 0x81
bt_f_if1 xdebug+6, 0
bs_f xdebug+6, 1
goto cdu_on
;
; See i2clib.asm for documentation of the interface to this file.
- include /usr/share/gputils/header/p18f458.inc
- radix dec
- include ../iwjpictest/insn-aliases.inc
+ ; include /usr/share/gputils/header/p18f458.inc
+ ; radix dec
+ ; include ../iwjpictest/insn-aliases.inc
- include ../iwjpictest/clockvaries.inc
- include panic.inc
- include morse+auto.inc
- include i2clib.incm
+ ; include ../iwjpictest/clockvaries.inc
+ ; include panic.inc
+ ; include morse+auto.inc
+ ; include i2clib.incm
+ include common.inc
;======================================================================
; NOTATION
;----------
i2cm_interrupt
+ D 0x50 ;!P
bt_f_if0 PIR1, SSPIF
return
; We have an interrupt:
;...
i2cm_interrupt_definite
+ D 0x51 ;!P
mov_ff SSPSTAT, sspstat
mov_ff SSPCON1, sspcon1
mov_ff SSPCON2, sspcon2
and_wfw sspcon1
bra_nz m_event_bad
+ mov_fw st ;!P
+ call debugbyte ;!P
+
; No ? Well, then the I2C should be idle now:
mov_fw sspcon2
+ call debugbyte ;!P
and_lw ~((1<<ACKSTAT) | (1<<ACKDT)) ; those two are ok if set
bra_nz m_event_bad
; OK...
mangle($1) if m/^(\w+)\b/;
s/\b(\w+)\b/ $mangle{$1} ? "$pfx$1" : $1 /ge;
}
- $codesection .= $_;
+ $codesection .= $_
+ unless m/\;\!P\s*$/;
} elsif (m/^\;\#MANGLE\# (\w+)$/) {
$mangle{$1}= 1;
$l= '';
code
;----------------------------------------
i2cmu_write_next_byte
+ D 0x61
+ mov_fw cwslave
+ call debugbyte
; add calls to getwritebyte_<foo> here:
+ D 0x62
+ mov_lfsr 0x5f+2, 0
+ mov_fw INDF0
+ call debugbyte
call polarity_getwritebyte
+ D 0x63
+ mov_lfsr 0x5f+2, 0
+ mov_fw INDF0
+ call debugbyte
call points_getwritebyte
+ D 0x64
+ mov_lfsr 0x5f+2, 0
+ mov_fw INDF0
+ call debugbyte
; end of list of calls to getwritebyte_<foo>
; so, no-one wants this slave:
bs_f STATUS, Z
i2cm_intrl @
; handles i2c interrupt using i2cm_interrupt[_definite],
; according to the rules for <something>_intrl.
+ D 0x60
bt_f_if0 PIR1, SSPIF
return
call i2cm_interrupt_definite
; (according to CDU Enable LAT bit)
cdu_timeout equ 200 ; ms
+cdu_inittimeout equ 750 ; ms
ptix2latbit equ 0x300 ; has to be a multiple of 0x100
ptix2latbit_section udata ptix2latbit
cdu_off @
cdu_panichook @
pin_l p0_cdu_enable
-;...
+ mov_lw (cdu_inittimeout * 1000) / tickdiv_us + 1
+ mov_wf cducharging
+ return
+
;-----
cdu_discharged
mov_lw (cdu_timeout * 1000) / tickdiv_us + 1
clr_f xdebug+0
return
+boom3
+ panic morse_TI3
+
;----------------------------------------
master_interrupt_low @
enter_interrupt_low
D 0x80
+ mov_lfsr 0x5f+2, 0
+ mov_fw INDF0
+ xor_lw 0x40
+ bra_nz boom3
call tick_intrl
- ;Dl 0x01
+ D 0x01
call nmra_serialrx_intrl
- ;Dl 0x02
+ D 0x02
call power_fault_intrl
- ;Dl 0x03
+ D 0x03
call serialtxfc_intrl
- ;Dl 0x04
+ D 0x04
call serialtx_intrl
- ;Dl 0x05
+ D 0x05
call points_local_intrl
- ;Dl 0x06
+ D 0x06
call i2cm_intrl
bs_f xdebug+0, 5
panic morse_IL
mov_lfsr polarity_cmds, 0
mov_fw cwslave
add_wff FSR0L
+ bt_f_if0 INDF0, 7
+ return
+ ; yes, we have something:
+
mov_fw INDF0
clr_f INDF0 ; we're about to write this
- bra_n i2c_getwritebyte_yes
- ; no:
- bs_f xdebug+0, 7
- return
+ bra i2c_getwritebyte_yes
;======================================================================
include final.inc