From 1135ff9d1e3dea2ee6ed3044afe8d0f77578eeff Mon Sep 17 00:00:00 2001 From: ian Date: Sun, 13 Nov 2005 15:14:33 +0000 Subject: [PATCH] wip; before undo redo i2cs_interrupt --- detpic/i2clib.asm | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/detpic/i2clib.asm b/detpic/i2clib.asm index f008d4d..e5f9cd3 100644 --- a/detpic/i2clib.asm +++ b/detpic/i2clib.asm @@ -14,8 +14,8 @@ t res 1 -st res 1 -st_subsequent equ 0 +st res 1 ; bitmask: +st_writing equ 0 code @@ -58,6 +58,49 @@ i2cs_interrupt_wcolsspov_endif ; Find out what's just happened: mov_ff SSPSTAT, t + ; bits we want to check + ; 80 60 20 10 08 04 02 01 + ; SMP CKE D_A P S R_W UA BF + ; set clr data? stop start read? clr full? + + bt_f_if1 t, I2C_START + bra si_if_start + +si_if_notstart + ; So it should be stop + mov_fw t + and_lw 0xdf ; ?D_A + xor_lw 0x90 ; SMP, !CKE, P; !S, !R_W, !UA, !BF + bra_nz si_if_bad + + ; Were we receiving ? + bt_f_if0 st, st_writing + return + + ; Yes, we were receiving: + bc_f st, st_writing + goto i2csu_write_done + ; tail call; we couldn't do anything after that + ; anyway since it might well reenter us. + +si_if_start + bt_f_if1 t, BF + bra si_if_bufferfull +si_if_bufferempty + bt_f_if1 t, R_W ;read? + bra si_if_bufferempty_reading +si_if_bufferempty_notreading + ; So we think this is just a START (which we want to ignore) + mov_fw t + and_lw 0xdf ; ?D_A + xor_lw 0x88 ; SMP, !CKE, !P; S, !R_W, !UA, !BF + bra_nz si_if_bad + + ; OK, ignore it + return + + + chkval macro mask, value, label mov_fw t -- 2.30.2