F_I2C_CTRL_H equ 00h
F_I2C_CTRL_L equ 01h
-; i2c specifit stuff
+; i2c specific stuff
I2C_BUFF_PAGE equ 4 ; put i2c relevant stuff into buffer page 4
PIC_NO equ 00h ; pic no goes to 400h
I2C_CTRL equ 01h ; i2c ctrl bit goes to 401h
+I2C_MASTER equ 0 ; bit 0 of I2C_CTRL is 1=master 0=slave
; i2c setup
+ movlb I2C_BUFF_PAGE ; ser BSR=i2c BSR (4)
+
+ btfss I2C_CTRL,I2C_MASTER,1 ; test whether PIC is master
+ goto pic_master_setup ; if so, set up as master
+ goto pic_slave_setup ; else set up as slave
+
+
+pic_master_setup
+
+
+
+
+pic_slave_setup
+
+
+
+
+
; p68
; p314
; p 275 ID locs
tblrd * ; read i2c
- movff TABLAT, I2C_CTRL ; move i2c_ctrl byte into normal memory
+ movf TABLAT,0,0 ; move i2c_ctrl byte into normal memory
+ movwf I2C_CTRL,1
; now have: PIC number in 400h, i2c control byte in 401h