36 #if (NUM_I2C_MODS >= 1)
55 u32_temp = u32_temp -
FCY/10000000L - 1;
57 I2C1CONbits.I2CEN = 1;
67 u8_wdtState = _SWDTEN;
71 while (I2C1CONbits.SEN);
72 _SWDTEN = u8_wdtState;
83 u8_wdtState = _SWDTEN;
87 while (I2C1CONbits.RSEN);
88 _SWDTEN = u8_wdtState;
99 u8_wdtState = _SWDTEN;
103 while (I2C1CONbits.PEN);
104 _SWDTEN = u8_wdtState;
116 u8_wdtState = _SWDTEN;
119 while (I2C1STATbits.TRSTAT);
120 _SWDTEN = u8_wdtState;
122 if (I2C1STATbits.ACKSTAT != I2C_ACK) {
138 u8_wdtState = _SWDTEN;
141 while (I2C1STATbits.TRSTAT);
142 _SWDTEN = u8_wdtState;
144 return(I2C1STATbits.ACKSTAT);
157 u8_wdtState = _SWDTEN;
159 while (I2C1CON & 0x1F);
160 I2C1CONbits.RCEN = 1;
161 while (!I2C1STATbits.RBF);
165 while (I2C1CON & 0x1F);
166 I2C1CONbits.ACKDT = u8_ack2Send;
167 I2C1CONbits.ACKEN = 1;
168 while (I2C1CONbits.ACKEN);
169 _SWDTEN = u8_wdtState;
208 for (u16_i=0; u16_i < u16_cnt; u16_i++) {
251 for (u16_i=0; u16_i < u16_cnt; u16_i++) {
252 if (u16_i != u16_cnt-1) *pu8_data =
getI2C1(I2C_ACK);
253 else *pu8_data =
getI2C1(I2C_NAK);
259 #endif // #if (NUM_I2C_MODS >= 1)
307 #if (NUM_I2C_MODS >= 2)
322 void configI2C2(
uint16_t u16_FkHZ) {
326 u32_temp = u32_temp -
FCY/10000000L - 1;
328 I2C2CONbits.I2CEN = 1;
334 void startI2C2(
void) {
338 u8_wdtState = _SWDTEN;
342 while (I2C2CONbits.SEN);
343 _SWDTEN = u8_wdtState;
350 void rstartI2C2(
void) {
354 u8_wdtState = _SWDTEN;
356 I2C2CONbits.RSEN = 1;
358 while (I2C2CONbits.RSEN);
359 _SWDTEN = u8_wdtState;
366 void stopI2C2(
void) {
370 u8_wdtState = _SWDTEN;
374 while (I2C2CONbits.PEN);
375 _SWDTEN = u8_wdtState;
387 u8_wdtState = _SWDTEN;
390 while (I2C2STATbits.TRSTAT);
391 _SWDTEN = u8_wdtState;
393 if (I2C2STATbits.ACKSTAT != I2C_ACK) {
409 u8_wdtState = _SWDTEN;
412 while (I2C2STATbits.TRSTAT);
413 _SWDTEN = u8_wdtState;
415 return(I2C2STATbits.ACKSTAT);
428 u8_wdtState = _SWDTEN;
430 while (I2C2CON & 0x1F);
431 I2C2CONbits.RCEN = 1;
432 while (!I2C2STATbits.RBF);
436 while (I2C2CON & 0x1F);
437 I2C2CONbits.ACKDT = u8_ack2Send;
438 I2C2CONbits.ACKEN = 1;
439 while (I2C2CONbits.ACKEN);
440 _SWDTEN = u8_wdtState;
451 putI2C2(I2C_WADDR(u8_addr));
463 putI2C2(I2C_WADDR(u8_addr));
478 putI2C2(I2C_WADDR(u8_addr));
479 for (u16_i=0; u16_i < u16_cnt; u16_i++) {
493 putI2C2(I2C_RADDR(u8_addr));
494 *pu8_d1 = getI2C2(I2C_NAK);
506 putI2C2(I2C_RADDR(u8_addr));
507 *pu8_d1 = getI2C2(I2C_ACK);
508 *pu8_d2 = getI2C2(I2C_NAK);
521 putI2C2(I2C_RADDR(u8_addr));
522 for (u16_i=0; u16_i < u16_cnt; u16_i++) {
523 if (u16_i != u16_cnt-1) *pu8_data = getI2C2(I2C_ACK);
524 else *pu8_data = getI2C2(I2C_NAK);
530 #endif // #if (NUM_I2C_MODS >= 2)