PIC24 Support Libraries
pic24_i2c.c
Go to the documentation of this file.
1 /*
2  * "Copyright (c) 2008 Robert B. Reese, Bryan A. Jones, J. W. Bruce ("AUTHORS")"
3  * All rights reserved.
4  * (R. Reese, reese_AT_ece.msstate.edu, Mississippi State University)
5  * (B. A. Jones, bjones_AT_ece.msstate.edu, Mississippi State University)
6  * (J. W. Bruce, jwbruce_AT_ece.msstate.edu, Mississippi State University)
7  *
8  * Permission to use, copy, modify, and distribute this software and its
9  * documentation for any purpose, without fee, and without written agreement is
10  * hereby granted, provided that the above copyright notice, the following
11  * two paragraphs and the authors appear in all copies of this software.
12  *
13  * IN NO EVENT SHALL THE "AUTHORS" BE LIABLE TO ANY PARTY FOR
14  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
15  * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE "AUTHORS"
16  * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
17  *
18  * THE "AUTHORS" SPECIFICALLY DISCLAIMS ANY WARRANTIES,
19  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20  * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
21  * ON AN "AS IS" BASIS, AND THE "AUTHORS" HAS NO OBLIGATION TO
22  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
23  *
24  * Please maintain this header in its entirety when copying/modifying
25  * these files.
26  *
27  *
28  */
29 
30 #include "pic24_i2c.h"
31 #include <stdio.h> //for NULL definition
32 #include "pic24_util.h"
33 #include "pic24_clockfreq.h"
34 
35 // Only include if this UART exists.
36 #if (NUM_I2C_MODS >= 1)
37 
38 // Documentation for this file. If the \file tag is not present,
39 // this file will not be documented.
40 // Note: place this comment below the #if NUM_I2C_MODS so Doxygen
41 // will only see it once.
42 /** \file
43  * I2C support functions. \see pic24_i2c.h for details.
44  */
45 
46 
47 /**
48 Configure and enable the I2C1 module for operation at \em u16_FkHZ kHZ clock speed.
49 \param u16_FkHZ specifies clock speed in kHZ
50 */
51 void configI2C1(uint16_t u16_FkHZ) {
52  uint16_t u16_temp;
53 
54  u16_temp = (FCY/1000L)/((uint16_t) u16_FkHZ);
55 #if defined(__PIC24E__) || defined(__dsPIC33E__)
56  // This ignores the gobbler pulse delay, which is device dependent and small.
57  u16_temp = (u16_temp - 1);
58 #else
59  u16_temp = u16_temp - FCY/10000000L - 1;
60 #endif
61  // The SCL divider only uses 9 bits.
62  if (u16_temp > 511) u16_temp = 511;
63  I2C1BRG = u16_temp;
64  I2C1CONbits.I2CEN = 1;
65 }
66 
67 /**
68 Operation: Perform an I2C start operation.
69 */
70 void startI2C1(void) {
71  uint8_t u8_wdtState;
72 
73  sz_lastTimeoutError = "I2C1 Start";
74  u8_wdtState = _SWDTEN; //save WDT state
75  _SWDTEN = 1; //enable WDT
76  I2C1CONbits.SEN = 1; // initiate start
77  // wait until start finished
78  while (I2C1CONbits.SEN);
79  _SWDTEN = u8_wdtState; //restore WDT
80  sz_lastTimeoutError = NULL;
81 }
82 
83 /**
84 Operation: Perform an I2C repeated start operation.
85 */
86 void rstartI2C1(void) { // repeated start
87  uint8_t u8_wdtState;
88 
89  sz_lastTimeoutError = "I2C1 RStart";
90  u8_wdtState = _SWDTEN; //save WDT state
91  _SWDTEN = 1; //enable WDT
92  I2C1CONbits.RSEN = 1; // initiate start
93  // wait until start finished
94  while (I2C1CONbits.RSEN);
95  _SWDTEN = u8_wdtState; //restore WDT
96  sz_lastTimeoutError = NULL;
97 }
98 
99 /**
100 Operation: Perform an I2C stop operation.
101 */
102 void stopI2C1(void) {
103  uint8_t u8_wdtState;
104 
105  sz_lastTimeoutError = "I2C1 Stop";
106  u8_wdtState = _SWDTEN; //save WDT state
107  _SWDTEN = 1; //enable WDT
108  I2C1CONbits.PEN=1; // initiate stop, PEN=1
109  //wait until stop finished
110  while (I2C1CONbits.PEN);
111  _SWDTEN = u8_wdtState; //restore WDT
112  sz_lastTimeoutError = NULL;
113 }
114 
115 /**
116 Operation: Send one byte (\em u8_val), if NAK is returned use reportError() function to save error and do software reset.
117 \param u8_val byte to send
118 */
119 void putI2C1(uint8_t u8_val) {
120  uint8_t u8_wdtState;
121 
122  sz_lastTimeoutError = "I2C1 Put";
123  u8_wdtState = _SWDTEN; //save WDT state
124  _SWDTEN = 1; //enable WDT
125  I2C1TRN = u8_val; // write byte
126  while (I2C1STATbits.TRSTAT); // wait for 8bits+ ack bit to finish
127  _SWDTEN = u8_wdtState; //restore WDT
128  sz_lastTimeoutError = NULL;
129  if (I2C1STATbits.ACKSTAT != I2C_ACK) {
130  //NAK returned
131  reportError("I2CPUT1, NAK returned.");
132  }
133 }
134 
135 /**
136 Operation: Send one byte (\em u8_val), return the acknowledgement bit that comes back from the slave. This
137 function does not error out if a NAK is returned.
138 \param u8_val byte to send
139 \return Ack bit value returned from slave.
140 */
142  uint8_t u8_wdtState;
143 
144  sz_lastTimeoutError = "I2C1 Put";
145  u8_wdtState = _SWDTEN; //save WDT state
146  _SWDTEN = 1; //enable WDT
147  I2C1TRN = u8_val; // write byte
148  while (I2C1STATbits.TRSTAT); // wait for 8bits+ ack bit to finish
149  _SWDTEN = u8_wdtState; //restore WDT
150  sz_lastTimeoutError = NULL;
151  return(I2C1STATbits.ACKSTAT);
152 }
153 
154 /**
155 Operation: Wait for a byte byte on the I2C bus, send \em u8_ack2Send as the acknowledgement bit to send back to the slave.
156 \param u8_ack2Send ack bit to send back to slave after byte is read
157 \return byte read from slave
158 */
159 uint8_t getI2C1(uint8_t u8_ack2Send) {
160  uint8_t u8_wdtState;
161  uint8_t u8_inByte;
162 
163  sz_lastTimeoutError = "I2C1 Get";
164  u8_wdtState = _SWDTEN; //save WDT state
165  _SWDTEN = 1; //enable WDT
166  while (I2C1CON & 0x1F); //wait for idle condition
167  I2C1CONbits.RCEN = 1; //enable receive
168  while (!I2C1STATbits.RBF); //wait for receive byte
169  CLRWDT();
170  u8_inByte = I2C1RCV; //read byte;
171  //wait for idle condition before attempting ACK
172  while (I2C1CON & 0x1F); //lower 5 bits must be 0
173  I2C1CONbits.ACKDT = u8_ack2Send; //ACK bit to send back on receive
174  I2C1CONbits.ACKEN = 1; //enable ACKbit transmittion
175  while (I2C1CONbits.ACKEN); //wait for completion
176  _SWDTEN = u8_wdtState; //restore WDT
177  sz_lastTimeoutError = NULL;
178  return(u8_inByte); //return the value
179 }
180 /**
181 Transaction: Write 1 byte (\em u8_d1) to I2C slave at address \em u8_addr.
182 \param u8_addr Slave I2C address
183 \param u8_d1 Byte to send
184 */
185 void write1I2C1(uint8_t u8_addr,uint8_t u8_d1) {
186  startI2C1();
187  putI2C1(I2C_WADDR(u8_addr));
188  putI2C1(u8_d1);
189  stopI2C1();
190 }
191 /**
192 Transaction: Write 2 bytes (\em u8_d1, \em u8_d2) to I2C slave at address \em u8_addr.
193 \param u8_addr Slave I2C address
194 \param u8_d1 First byte to send
195 \param u8_d2 Second byte to send
196 */
197 void write2I2C1(uint8_t u8_addr,uint8_t u8_d1, uint8_t u8_d2) {
198  startI2C1();
199  putI2C1(I2C_WADDR(u8_addr));
200  putI2C1(u8_d1);
201  putI2C1(u8_d2);
202  stopI2C1();
203 }
204 
205 /**
206 Transaction: Write \em u16_cnt bytes stored in buffer \em *pu8_data to I2C slave at address \em u8_addr.
207 \param u8_addr Slave I2C address
208 \param pu8_data Pointer to buffer containing bytes to send
209 \param u16_cnt Number of bytes to send
210 */
211 void writeNI2C1(uint8_t u8_addr,uint8_t* pu8_data, uint16_t u16_cnt) {
212  uint16_t u16_i;
213  startI2C1();
214  putI2C1(I2C_WADDR(u8_addr));
215  for (u16_i=0; u16_i < u16_cnt; u16_i++) {
216  putI2C1(*pu8_data);
217  pu8_data++;
218  }
219  stopI2C1();
220 }
221 /**
222 Transaction: Read one byte from I2C slave at address \em u8_addr, save to \em *pu8_d1.
223 As per the I2C standard, a NAK is returned for the last byte read from the slave, ACKs are returned for the other bytes.
224 \param u8_addr Slave I2C address
225 \param pu8_d1 Pointer to location to store byte read from slave
226 */
227 void read1I2C1(uint8_t u8_addr,uint8_t* pu8_d1) {
228  startI2C1();
229  putI2C1(I2C_RADDR(u8_addr));
230  *pu8_d1 = getI2C1(I2C_NAK); //last ack bit from master to slave during read must be a NAK
231  stopI2C1();
232 }
233 /**
234 Transaction: Read two bytes from I2C slave at address \em u8_addr, save to \em *pu8_d1, \em *pu8_d2.
235 As per the I2C standard, a NAK is returned for the last byte read from the slave, ACKs are returned for the other bytes.
236 \param u8_addr Slave I2C address
237 \param pu8_d1 Pointer to location to store first byte read from slave
238 \param pu8_d2 Pointer to location to store second byte read from slave
239 */
240 void read2I2C1(uint8_t u8_addr,uint8_t* pu8_d1, uint8_t* pu8_d2) {
241  startI2C1();
242  putI2C1(I2C_RADDR(u8_addr));
243  *pu8_d1 = getI2C1(I2C_ACK);
244  *pu8_d2 = getI2C1(I2C_NAK);
245  stopI2C1();
246 }
247 /**
248 Transaction: Read \em u16_cnt bytes from I2C slave at address \em u8_addr, save to buffer \em *pu8_data.
249 As per the I2C standard, a NAK is returned for the last byte read from the slave, ACKs are returned for the other bytes.
250 \param u8_addr Slave I2C address
251 \param pu8_data Pointer to buffer for storing bytes read from slave
252 \param u16_cnt Number of bytes read from slave.
253 */
254 void readNI2C1(uint8_t u8_addr,uint8_t* pu8_data, uint16_t u16_cnt) {
255  uint16_t u16_i;
256  startI2C1();
257  putI2C1(I2C_RADDR(u8_addr));
258  for (u16_i=0; u16_i < u16_cnt; u16_i++) {
259  if (u16_i != u16_cnt-1) *pu8_data = getI2C1(I2C_ACK);
260  else *pu8_data = getI2C1(I2C_NAK);
261  pu8_data++;
262  }
263  stopI2C1();
264 }
265 
266 #endif // #if (NUM_I2C_MODS >= 1)
267 
268 
269 
270 
271 
272 
273 
274 
275 
276 
277 
278 
279 /*
280  * "Copyright (c) 2008 Robert B. Reese, Bryan A. Jones, J. W. Bruce ("AUTHORS")"
281  * All rights reserved.
282  * (R. Reese, reese_AT_ece.msstate.edu, Mississippi State University)
283  * (B. A. Jones, bjones_AT_ece.msstate.edu, Mississippi State University)
284  * (J. W. Bruce, jwbruce_AT_ece.msstate.edu, Mississippi State University)
285  *
286  * Permission to use, copy, modify, and distribute this software and its
287  * documentation for any purpose, without fee, and without written agreement is
288  * hereby granted, provided that the above copyright notice, the following
289  * two paragraphs and the authors appear in all copies of this software.
290  *
291  * IN NO EVENT SHALL THE "AUTHORS" BE LIABLE TO ANY PARTY FOR
292  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
293  * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE "AUTHORS"
294  * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
295  *
296  * THE "AUTHORS" SPECIFICALLY DISCLAIMS ANY WARRANTIES,
297  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
298  * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
299  * ON AN "AS IS" BASIS, AND THE "AUTHORS" HAS NO OBLIGATION TO
300  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
301  *
302  * Please maintain this header in its entirety when copying/modifying
303  * these files.
304  *
305  *
306  */
307 
308 #include "pic24_i2c.h"
309 #include <stdio.h> //for NULL definition
310 #include "pic24_util.h"
311 #include "pic24_clockfreq.h"
312 
313 // Only include if this UART exists.
314 #if (NUM_I2C_MODS >= 2)
315 
316 // Documentation for this file. If the \file tag is not present,
317 // this file will not be documented.
318 // Note: place this comment below the #if NUM_I2C_MODS so Doxygen
319 // will only see it once.
320 /** \file
321  * I2C support functions. \see pic24_i2c.h for details.
322  */
323 
324 
325 /**
326 Configure and enable the I2C2 module for operation at \em u16_FkHZ kHZ clock speed.
327 \param u16_FkHZ specifies clock speed in kHZ
328 */
329 void configI2C2(uint16_t u16_FkHZ) {
330  uint16_t u16_temp;
331 
332  u16_temp = (FCY/1000L)/((uint16_t) u16_FkHZ);
333 #if defined(__PIC24E__) || defined(__dsPIC33E__)
334  // This ignores the gobbler pulse delay, which is device dependent and small.
335  u16_temp = (u16_temp - 1);
336 #else
337  u16_temp = u16_temp - FCY/10000000L - 1;
338 #endif
339  // The SCL divider only uses 9 bits.
340  if (u16_temp > 511) u16_temp = 511;
341  I2C2BRG = u16_temp;
342  I2C2CONbits.I2CEN = 1;
343 }
344 
345 /**
346 Operation: Perform an I2C start operation.
347 */
348 void startI2C2(void) {
349  uint8_t u8_wdtState;
350 
351  sz_lastTimeoutError = "I2C2 Start";
352  u8_wdtState = _SWDTEN; //save WDT state
353  _SWDTEN = 1; //enable WDT
354  I2C2CONbits.SEN = 1; // initiate start
355  // wait until start finished
356  while (I2C2CONbits.SEN);
357  _SWDTEN = u8_wdtState; //restore WDT
358  sz_lastTimeoutError = NULL;
359 }
360 
361 /**
362 Operation: Perform an I2C repeated start operation.
363 */
364 void rstartI2C2(void) { // repeated start
365  uint8_t u8_wdtState;
366 
367  sz_lastTimeoutError = "I2C2 RStart";
368  u8_wdtState = _SWDTEN; //save WDT state
369  _SWDTEN = 1; //enable WDT
370  I2C2CONbits.RSEN = 1; // initiate start
371  // wait until start finished
372  while (I2C2CONbits.RSEN);
373  _SWDTEN = u8_wdtState; //restore WDT
374  sz_lastTimeoutError = NULL;
375 }
376 
377 /**
378 Operation: Perform an I2C stop operation.
379 */
380 void stopI2C2(void) {
381  uint8_t u8_wdtState;
382 
383  sz_lastTimeoutError = "I2C2 Stop";
384  u8_wdtState = _SWDTEN; //save WDT state
385  _SWDTEN = 1; //enable WDT
386  I2C2CONbits.PEN=1; // initiate stop, PEN=1
387  //wait until stop finished
388  while (I2C2CONbits.PEN);
389  _SWDTEN = u8_wdtState; //restore WDT
390  sz_lastTimeoutError = NULL;
391 }
392 
393 /**
394 Operation: Send one byte (\em u8_val), if NAK is returned use reportError() function to save error and do software reset.
395 \param u8_val byte to send
396 */
397 void putI2C2(uint8_t u8_val) {
398  uint8_t u8_wdtState;
399 
400  sz_lastTimeoutError = "I2C2 Put";
401  u8_wdtState = _SWDTEN; //save WDT state
402  _SWDTEN = 1; //enable WDT
403  I2C2TRN = u8_val; // write byte
404  while (I2C2STATbits.TRSTAT); // wait for 8bits+ ack bit to finish
405  _SWDTEN = u8_wdtState; //restore WDT
406  sz_lastTimeoutError = NULL;
407  if (I2C2STATbits.ACKSTAT != I2C_ACK) {
408  //NAK returned
409  reportError("I2CPUT2, NAK returned.");
410  }
411 }
412 
413 /**
414 Operation: Send one byte (\em u8_val), return the acknowledgement bit that comes back from the slave. This
415 function does not error out if a NAK is returned.
416 \param u8_val byte to send
417 \return Ack bit value returned from slave.
418 */
419 uint8_t putNoAckCheckI2C2(uint8_t u8_val) {
420  uint8_t u8_wdtState;
421 
422  sz_lastTimeoutError = "I2C2 Put";
423  u8_wdtState = _SWDTEN; //save WDT state
424  _SWDTEN = 1; //enable WDT
425  I2C2TRN = u8_val; // write byte
426  while (I2C2STATbits.TRSTAT); // wait for 8bits+ ack bit to finish
427  _SWDTEN = u8_wdtState; //restore WDT
428  sz_lastTimeoutError = NULL;
429  return(I2C2STATbits.ACKSTAT);
430 }
431 
432 /**
433 Operation: Wait for a byte byte on the I2C bus, send \em u8_ack2Send as the acknowledgement bit to send back to the slave.
434 \param u8_ack2Send ack bit to send back to slave after byte is read
435 \return byte read from slave
436 */
437 uint8_t getI2C2(uint8_t u8_ack2Send) {
438  uint8_t u8_wdtState;
439  uint8_t u8_inByte;
440 
441  sz_lastTimeoutError = "I2C2 Get";
442  u8_wdtState = _SWDTEN; //save WDT state
443  _SWDTEN = 1; //enable WDT
444  while (I2C2CON & 0x1F); //wait for idle condition
445  I2C2CONbits.RCEN = 1; //enable receive
446  while (!I2C2STATbits.RBF); //wait for receive byte
447  CLRWDT();
448  u8_inByte = I2C2RCV; //read byte;
449  //wait for idle condition before attempting ACK
450  while (I2C2CON & 0x1F); //lower 5 bits must be 0
451  I2C2CONbits.ACKDT = u8_ack2Send; //ACK bit to send back on receive
452  I2C2CONbits.ACKEN = 1; //enable ACKbit transmittion
453  while (I2C2CONbits.ACKEN); //wait for completion
454  _SWDTEN = u8_wdtState; //restore WDT
455  sz_lastTimeoutError = NULL;
456  return(u8_inByte); //return the value
457 }
458 /**
459 Transaction: Write 1 byte (\em u8_d1) to I2C slave at address \em u8_addr.
460 \param u8_addr Slave I2C address
461 \param u8_d1 Byte to send
462 */
463 void write1I2C2(uint8_t u8_addr,uint8_t u8_d1) {
464  startI2C2();
465  putI2C2(I2C_WADDR(u8_addr));
466  putI2C2(u8_d1);
467  stopI2C2();
468 }
469 /**
470 Transaction: Write 2 bytes (\em u8_d1, \em u8_d2) to I2C slave at address \em u8_addr.
471 \param u8_addr Slave I2C address
472 \param u8_d1 First byte to send
473 \param u8_d2 Second byte to send
474 */
475 void write2I2C2(uint8_t u8_addr,uint8_t u8_d1, uint8_t u8_d2) {
476  startI2C2();
477  putI2C2(I2C_WADDR(u8_addr));
478  putI2C2(u8_d1);
479  putI2C2(u8_d2);
480  stopI2C2();
481 }
482 
483 /**
484 Transaction: Write \em u16_cnt bytes stored in buffer \em *pu8_data to I2C slave at address \em u8_addr.
485 \param u8_addr Slave I2C address
486 \param pu8_data Pointer to buffer containing bytes to send
487 \param u16_cnt Number of bytes to send
488 */
489 void writeNI2C2(uint8_t u8_addr,uint8_t* pu8_data, uint16_t u16_cnt) {
490  uint16_t u16_i;
491  startI2C2();
492  putI2C2(I2C_WADDR(u8_addr));
493  for (u16_i=0; u16_i < u16_cnt; u16_i++) {
494  putI2C2(*pu8_data);
495  pu8_data++;
496  }
497  stopI2C2();
498 }
499 /**
500 Transaction: Read one byte from I2C slave at address \em u8_addr, save to \em *pu8_d1.
501 As per the I2C standard, a NAK is returned for the last byte read from the slave, ACKs are returned for the other bytes.
502 \param u8_addr Slave I2C address
503 \param pu8_d1 Pointer to location to store byte read from slave
504 */
505 void read1I2C2(uint8_t u8_addr,uint8_t* pu8_d1) {
506  startI2C2();
507  putI2C2(I2C_RADDR(u8_addr));
508  *pu8_d1 = getI2C2(I2C_NAK); //last ack bit from master to slave during read must be a NAK
509  stopI2C2();
510 }
511 /**
512 Transaction: Read two bytes from I2C slave at address \em u8_addr, save to \em *pu8_d1, \em *pu8_d2.
513 As per the I2C standard, a NAK is returned for the last byte read from the slave, ACKs are returned for the other bytes.
514 \param u8_addr Slave I2C address
515 \param pu8_d1 Pointer to location to store first byte read from slave
516 \param pu8_d2 Pointer to location to store second byte read from slave
517 */
518 void read2I2C2(uint8_t u8_addr,uint8_t* pu8_d1, uint8_t* pu8_d2) {
519  startI2C2();
520  putI2C2(I2C_RADDR(u8_addr));
521  *pu8_d1 = getI2C2(I2C_ACK);
522  *pu8_d2 = getI2C2(I2C_NAK);
523  stopI2C2();
524 }
525 /**
526 Transaction: Read \em u16_cnt bytes from I2C slave at address \em u8_addr, save to buffer \em *pu8_data.
527 As per the I2C standard, a NAK is returned for the last byte read from the slave, ACKs are returned for the other bytes.
528 \param u8_addr Slave I2C address
529 \param pu8_data Pointer to buffer for storing bytes read from slave
530 \param u16_cnt Number of bytes read from slave.
531 */
532 void readNI2C2(uint8_t u8_addr,uint8_t* pu8_data, uint16_t u16_cnt) {
533  uint16_t u16_i;
534  startI2C2();
535  putI2C2(I2C_RADDR(u8_addr));
536  for (u16_i=0; u16_i < u16_cnt; u16_i++) {
537  if (u16_i != u16_cnt-1) *pu8_data = getI2C2(I2C_ACK);
538  else *pu8_data = getI2C2(I2C_NAK);
539  pu8_data++;
540  }
541  stopI2C2();
542 }
543 
544 #endif // #if (NUM_I2C_MODS >= 2)
545 
546 
547 
548 
549 
550 
551 
552 
553 
554 
555 
556 
void read2I2C1(uint8_t u8_addr, uint8_t *pu8_d1, uint8_t *pu8_d2)
Definition: pic24_i2c.c:240
void read1I2C1(uint8_t u8_addr, uint8_t *pu8_d1)
Definition: pic24_i2c.c:227
void stopI2C1(void)
Definition: pic24_i2c.c:102
#define CLRWDT()
Clear the watch-dog timer.
Definition: pic24_chip.h:75
void putI2C1(uint8_t u8_val)
Definition: pic24_i2c.c:119
uint8_t getI2C1(uint8_t u8_ack2Send)
Definition: pic24_i2c.c:159
Configures the system clock.
_PERSISTENT const char * sz_lastTimeoutError
Definition: pic24_util.c:134
#define FCY
void rstartI2C1(void)
Definition: pic24_i2c.c:86
void configI2C1(uint16_t u16_FkHZ)
Definition: pic24_i2c.c:51
void startI2C1(void)
Definition: pic24_i2c.c:70
void write1I2C1(uint8_t u8_addr, uint8_t u8_d1)
Definition: pic24_i2c.c:185
void write2I2C1(uint8_t u8_addr, uint8_t u8_d1, uint8_t u8_d2)
Definition: pic24_i2c.c:197
unsigned char uint8_t
An abbreviation for an 8-bit unsigned integer.
Definition: dataXferImpl.h:194
void reportError(const char *sz_errorMessage)
Definition: pic24_util.c:183
uint8_t putNoAckCheckI2C1(uint8_t u8_val)
Definition: pic24_i2c.c:141
void writeNI2C1(uint8_t u8_addr, uint8_t *pu8_data, uint16_t u16_cnt)
Definition: pic24_i2c.c:211
void readNI2C1(uint8_t u8_addr, uint8_t *pu8_data, uint16_t u16_cnt)
Definition: pic24_i2c.c:254