23 #include <p24FJ128GB106.h>
52 #ifdef I2C_HW //estamos usando I2C por hardware?
69 unsigned int config2, config1;
79 config1 = (I2C_ON & I2C_IDLE_CON & I2C_CLK_HLD & I2C_IPMI_DIS & I2C_7BIT_ADD
80 & I2C_SLW_DIS & I2C_SM_DIS & I2C_GCALL_DIS & I2C_STR_DIS & I2C_NACK
81 & I2C_ACK_DIS & I2C_RCV_DIS & I2C_STOP_DIS & I2C_RESTART_DIS & I2C_START_DIS);
83 OpenI2C1(config1,config2);
101 while(I2C1CONbits.SEN);
118 while(I2C1CONbits.PEN);
136 while(I2C1STATbits.TBF);
137 while(!IFS1bits.MI2C1IF);
138 IFS1bits.MI2C1IF = 0;
154 unsigned char data=0;
156 I2C1CONbits.RCEN = 1;
157 while(I2C1CONbits.RCEN);
158 I2C1CONbits.RCEN = 0;
159 I2C1STATbits.I2COV = 0;
164 while(I2C1CONbits.ACKEN);
169 #else //si no, hacerlo por software
192 volatile char SDA_VAR;
213 while(SDA_VAR==1 && retries){