1 ;######################################################################
2 ; i2clib.inc - I2C LIBRARY - IMPLEMENTATION
4 ; See i2clib.asm for documentation of the interface to this file.
6 include /usr/share/gputils/header/p18f458.inc
8 include ../iwjpictest/insn-aliases.inc
10 ;============================================================
11 ; COMMON ADMINISTRATIVE ROUTINES
20 ; W slave number undefined
23 mov_lw 0x16 ; !SSPEN, CKP(release), I2C 7-bit slave
25 mov_lw 0x81 ; GCEN, SEN
27 mov_lw 0x8 ; SMP(noslew), !CKE, !BF(empty)
40 ; We have an interrupt. What are the possibilities ?
43 chkval macro mask, value, label
49 ; bits we want to check
51 ; SMP CKE D_A R_W UA BF
52 ; set clr data? read? clr full?
54 chkval 0xe3, 0x81, got_addr
55 chkval 0xe7, 0xa1, got_data_write
56 chkval 0xe7, 0xa4, sent_data_read
61 and_lw 0xe7 ; all except P and S
64 ; bits which might sensibly be set
67 chkval macro value, label
68 xor_lw value ^ chkval_last
72 chkval 0x80 ; addr dunno
77 bt_f_if0 DATA_ADDRESS, SSPSTAT
81 ; computes slave address in form suitable for use in i2c controller
82 ; actual i2c slave address is (slave number) + 0b0001000
83 ; W slave number i2c address * 2