LMS 2012
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
c_i2c.c
Go to the documentation of this file.
1 /*
2  * LEGO® MINDSTORMS EV3
3  *
4  * Copyright (C) 2010-2013 The LEGO Group
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  */
20 
21 
54 #include "lms2012.h"
55 #include "c_com.h"
56 #include "c_bt.h"
57 #include "c_i2c.h"
58 
59 #include <stdio.h>
60 #include <fcntl.h>
61 #include <stdlib.h>
62 #include <unistd.h>
63 #include <string.h>
64 #include <signal.h>
65 #include <sys/mman.h>
66 #include <time.h>
67 #include <errno.h>
68 
69 #include <sys/ioctl.h>
70 #include <linux/i2c.h>
71 #include <linux/i2c-dev.h>
72 #include <pthread.h>
73 
74 
75 /* I2C Adresses */
76 enum
77 {
78  WRITE_DATA = 0x2A, // Also referred to as 0x54
79  READ_STATUS = 0x2A, // Also referred to as 0x55
80  WRITE_RAW = 0x2B, // Also referred to as 0x56
81  READ_DATA = 0x2B // Also referred to as 0x57
82 };
83 
84 /* Bluetooth pins needs to be synchronized with pins in d_bt.c */
85 enum
86 {
91 };
92 
93 enum
94 {
95  SET = 0,
96  CLEAR = 1,
97  HIIMP = 2
98 };
99 
100 enum
101 {
103  CRC_ERROR = 0x02,
107 };
108 
109 
110 #define I2CBUF_SIZE 150
111 #define APPDATABUF_SIZE 150
112 #define MODE2BUF_SIZE 1024 // Must be power of 2
113 #define MIN_MSG_LEN 6
114 #define SLEEPuS ((ULONG)(1000))
115 #define SEC_1 (((ULONG)(1000000))/SLEEPuS)
116 
117 typedef struct
118 {
122 } MODE2BUF;
123 
124 
125 static int I2cFile;
126 static int BtFile;
127 static int ThreadRunState;
128 static MODE2BUF Mode2InBuf;
129 char *RtnMsg = "I2c Func thread end";
130 static struct i2c_rdwr_ioctl_data msg_rdwr;
131 static struct i2c_msg i2cmsg;
132 
133 static UBYTE Status;
134 
135 static READBUF *pReadBuf;
136 static WRITEBUF *pMode2WriteBuf;
137 
138 static char *pBundleIdString;
139 static char *pBundleSeedIdString;
140 
141 static char TmpBuf[I2CBUF_SIZE + 1];
142 
143 
144 UBYTE I2cReadStatus(UBYTE *pBuf);
145 UBYTE I2cReadCts(void);
146 int I2cRead(int fd, unsigned int addr, char *buf, unsigned char len);
147 int I2cWrite(int fd, unsigned int addr, char *buf, unsigned char len);
148 void* I2cCtrl(void *ptr);
149 
150 void I2cSetPIC_RST(void);
151 void I2cClearPIC_RST(void);
152 void I2cSetPIC_EN(void);
153 void I2cClearPIC_EN(void);
154 void I2cHiImpPIC_EN(void);
155 
156 
157 #define BUFBytesFree (((Mode2InBuf.OutPtr - Mode2InBuf.InPtr) - 1) & ((UWORD)(MODE2BUF_SIZE - 1)))
158 #define BUFBytesAvail ((Mode2InBuf.InPtr - Mode2InBuf.OutPtr) & ((UWORD)(MODE2BUF_SIZE - 1)))
159 #define BUFAddInPtr(Val) (Mode2InBuf.InPtr = ((Mode2InBuf.InPtr + Val) & ((UWORD)(MODE2BUF_SIZE - 1))))
160 #define BUFAddOutPtr(Val) (Mode2InBuf.OutPtr = ((Mode2InBuf.OutPtr + Val) & ((UWORD)(MODE2BUF_SIZE - 1))))
161 
162 #define DISCONNDueToErr {\
163  cBtDiscChNo(0);\
164  ThreadRunState = 0;\
165  }
166 
167 
168 RESULT I2cInit(READBUF *pBuf, WRITEBUF *pWriteBuf, char *pBundleId, char *pBundleSeedId)
169 {
170  RESULT Result = FAIL;
171 
172  BtFile = open(BT_DEVICE_NAME, O_RDWR);
173 
174  if (BtFile >= 0)
175  {
176  Result = OK;
177  }
178 
179  pReadBuf = pBuf;
180  pMode2WriteBuf = pWriteBuf;
181  pBundleIdString = pBundleId;
182  pBundleSeedIdString = pBundleSeedId;
183 
184  return(Result);
185 }
186 
187 
188 void I2cExit(void)
189 {
190  I2cStop();
191  if (BtFile >= MIN_HANDLE)
192  {
193  close(BtFile);
194  }
195 }
196 
197 
198 void I2cStart(void)
199 {
200  pthread_t I2cFunc;
201  int I2cRet;
202  char *message = "I2c Func thread";
203 
204  Mode2InBuf.InPtr = 0;
205  Mode2InBuf.OutPtr = 0;
206  Status = MODE2_BOOTING;
207 
208  ThreadRunState = 1;
209  I2cRet = pthread_create(&I2cFunc, NULL, I2cCtrl, (void*) message);
210 }
211 
212 
213 void I2cStop(void)
214 {
215  ThreadRunState = 0;
216 }
217 
218 
219 void* I2cCtrl(void *ptr)
220 {
221  UWORD Size;
222  UBYTE Buf[200];
223  UWORD Check;
224 
225  I2cFile = -1;
226 
227  if (I2cFile >= MIN_HANDLE)
228  {
229  close (I2cFile);
230  I2cFile = -1;
231  }
232 
233  I2cClearPIC_EN();
234  I2cSetPIC_RST();
235  usleep(1000);
236  I2cClearPIC_RST();
237  usleep(1000);
238  I2cSetPIC_EN();
239 
240  Mode2InBuf.InPtr = 0;
241  Mode2InBuf.OutPtr = 0;
242 
243  I2cFile = open("/dev/i2c-1", O_RDWR);
244 
245  if (I2cFile < 0)
246  {
247  #ifdef DEBUG
248  printf("Can't open device file /dev/i2c-1\n");
249  #endif
250  }
251  else
252  {
253  ioctl(I2cFile,I2C_SLAVE, 0);
254  }
255 
256  // Check that CTS is going high within 500ms else error
257  Check = 1;
258  while (0 != Check)
259  {
260  if (I2cReadCts())
261  {
262  Check = 0;
263  }
264  else
265  {
266  if (Check < 500)
267  {
268  usleep(1000);
269  Check++;
270  }
271  else
272  {
273  // If 500ms passed without CTS going high
274  // set error
275  Check = 0;
276  Status = MODE2_FALIURE;
277  }
278  }
279  }
280 
281  Check = 0;
282  while(ThreadRunState)
283  {
284  if (Check++ > SEC_1)
285  {
286  // if CTS is low for 1 sec or more then it is an error
288  }
289  else
290  {
291  if (I2cReadCts())
292  {
293  Check = 0; // CTS = High -> reset timer
294 
295  // Read status when CTS is high
296  // Status returns byte 0 = Status
297  // byte 1 = Depending on status
298  // byte 2 = Depending on status
299  I2cReadStatus(Buf);
300 
301  switch(Buf[0])
302  {
303  case 'E':
304  {
305  switch(Buf[1])
306  {
307  case OVERRUN_ERROR:
308  {
309  // Occurs when having transferred to many bytes
310  // to mode2 decoding
311  Status = MODE2_FALIURE;
312  #ifdef DEBUG
313  printf("\r\nERROR - OVERRUN\r\n");
314  #endif
315  }
316  break;
317  case CRC_ERROR:
318  {
319  Status = MODE2_FALIURE;
320  #ifdef DEBUG
321  printf("\r\nERROR - CRC\r\n");
322  #endif
323  }
324  break;
325  case INCORRECT_ACTION:
326  {
327  Status = MODE2_FALIURE;
328  #ifdef DEBUG
329  printf("\r\nERROR - INCORRECT_ACTION\r\n");
330  #endif
331  }
332  break;
333  case UNEXPECTED_ERROR:
334  {
335  Status = MODE2_FALIURE;
336  #ifdef DEBUG
337  printf("\r\nERROR - UNEXPECTED\r\n");
338  #endif
339  }
340  break;
341  case RAW_OVERRUN_ERROR:
342  {
343  Status = MODE2_FALIURE;
344  #ifdef DEBUG
345  printf("\r\nERROR - RAW_OVERRUN\r\n");
346  #endif
347  }
348  break;
349  default:
350  {
351  // Unknown Error
352  Status = MODE2_FALIURE;
353  #ifdef DEBUG
354  printf("\r\nERROR - UNKNOWN\r\n");
355  #endif
356  }
357  break;
358  }
360  }
361  break;
362 
363  case 'A':
364  {
365  #ifdef DEBUG
366  UWORD Test;
367  #endif
368 
369  // Check if TX Bt buffers are ready to accept data
370  if (cBtI2cBufReady())
371  {
372  Size = Buf[1];
373 
374  if (0 < Size)
375  {
376  // Bytes for mode2 decoding are ready - read them
377  if (0 > I2cRead(I2cFile, READ_DATA, (char *)Buf, Size))
378  {
379  // Error
380  #ifdef DEBUG
381  printf("\r\n'A' Read error \r\n");
382  #endif
383  }
384 
385  #ifdef DEBUG
386  printf("\r\nA - Reading mode2 data from decoding to Tx on Bluetooth\r\n");
387  for(Test = 0; Test < Size; Test++)
388  {
389  printf("Buf[%d] = %02X\r\n",Test,Buf[Test]);
390  }
391  #endif
392 
393  // Send the bytes for mode2 decoding
394  cBtI2cToBtBuf(Buf, Size);
395  }
396  }
397  }
398  break;
399 
400  case 'W':
401  {
402  UWORD BytesToTx;
403  UWORD TmpCnt;
404 
405  // More data for mode2 decoding is needed at address 0x54
406  #ifdef DEBUG
407  printf("\r\nW - Waiting for more mode2 data\r\n");
408  #endif
409 
410  BytesToTx = BUFBytesAvail;
411  if (BytesToTx)
412  {
413  if (BytesToTx > (UWORD)(Buf[1]))
414  {
415  // Do not send more bytes than requested
416  BytesToTx = (UWORD)(Buf[1]);
417  }
418 
419  #ifdef DEBUG
420  printf("\r\n Remote data:");
421  #endif
422  for (TmpCnt = 0; TmpCnt < BytesToTx; TmpCnt++)
423  {
424  #ifdef DEBUG
425  printf("%02X, ",Mode2InBuf.Buf[Mode2InBuf.OutPtr]);
426  #endif
427  TmpBuf[TmpCnt] = Mode2InBuf.Buf[Mode2InBuf.OutPtr];
428  BUFAddOutPtr(1);
429  }
430 
431  if (0 > I2cWrite(I2cFile, WRITE_DATA, (char*)TmpBuf, BytesToTx))
432  {
433  // Error
434  #ifdef DEBUG
435  printf("\r\n'W' write error \r\n");
436  #endif
437  }
438  }
439  }
440  break;
441 
442  case 'I':
443  {
444 
445  UWORD TmpCnt;
446  UWORD BytesAvail;
447 
448  BytesAvail = BUFBytesAvail;
449 
450  if (MIN_MSG_LEN <= BytesAvail)
451  {
452  // Minimum msg length coming from remote device has been received
453  #ifdef DEBUG
454  printf("\r\nData to decoding from Bluetooth = %d, Inptr = %d, OutPtr = %d\r\n",BytesAvail,Mode2InBuf.InPtr,Mode2InBuf.OutPtr);
455  #endif
456 
457  // Send minimum msg length + 0xFF header
458  TmpBuf[0] = 0xFF;
459  for (TmpCnt = 0; TmpCnt < MIN_MSG_LEN; TmpCnt++)
460  {
461  TmpBuf[TmpCnt + 1] = Mode2InBuf.Buf[Mode2InBuf.OutPtr];
462  BUFAddOutPtr(1);
463  }
464 
465  if(0 > I2cWrite(I2cFile, WRITE_DATA, (char*)TmpBuf, (MIN_MSG_LEN + 1)))
466  {
468  }
469  else
470  {
471  #ifdef DEBUG
472  printf("\r\n.... Remote data to the Pic, Bytes transferred %d\r\n",ByteCnt);
473  #endif
474  }
475  }
476  else
477  {
478  UWORD ByteCnt;
479 
480  // Check for LEGO App data to the mode2 decoding
481  // ByteCnt can be bigger than i2c buffer size, if that is the case
482  // then ByteCnt has to be split up in I2CBUF_SIZE
483  ByteCnt = pMode2WriteBuf->InPtr - pMode2WriteBuf->OutPtr;
484 
485  if(ByteCnt)
486  {
487  if (ByteCnt > (I2CBUF_SIZE - 1))
488  {
489  // Only send max buffer size
490  ByteCnt = (I2CBUF_SIZE - 1);
491  }
492 
493  TmpBuf[0] = ByteCnt;
494  memcpy((char *)&(TmpBuf[1]), (char *)&(pMode2WriteBuf->Buf[pMode2WriteBuf->OutPtr]), ByteCnt);
495  pMode2WriteBuf->OutPtr += ByteCnt;
496 
497  if (pMode2WriteBuf->OutPtr == pMode2WriteBuf->InPtr)
498  {
499  // All bytes has been written - clear the buffer
500  pMode2WriteBuf->InPtr = 0;
501  pMode2WriteBuf->OutPtr = 0;
502  }
503 
504  if (0 > I2cWrite(I2cFile, WRITE_RAW, (char *)&(TmpBuf[0]), ByteCnt + 1))
505  {
507  }
508  else
509  {
510  #ifdef DEBUG
511  printf("\r\n.... Application data to the Pic, Bytes to send %d\r\n",ByteCnt);
512  #endif
513  }
514 
515  }
516  }
517  #ifdef DEBUG
518  printf("\r\nI - Idle state\r\n");
519  #endif
520  }
521  break;
522 
523  case 'R':
524  {
525  // Raw data ready for our application - send it to mode1 decoding
526  #ifdef DEBUG
527  UWORD Test;
528  #endif
529 
530  if (READ_BUF_EMPTY == pReadBuf->Status)
531  {
532  // Buf[1] contains the number of bytes ready to be read
533  Size = Buf[1];
534  if (0 <= I2cRead(I2cFile, READ_DATA, (char*)&(pReadBuf->Buf[0]), Size))
535  {
536  pReadBuf->OutPtr = 0;
537  pReadBuf->InPtr = Size;
538  pReadBuf->Status = READ_BUF_FULL;
539 
540  #ifdef DEBUG
541  printf("\r\nR - %d bytes of App data read \r\n",Size);
542  for(Test = 0; Test < Size; Test++)
543  {
544  printf("AppData[%d] = %02X\r\n",Test,pReadBuf->Buf[Test]);
545  }
546  #endif
547 
548  DecodeMode1(0);
549  }
550  }
551  else
552  {
553  DecodeMode1(0);
554  }
555  }
556  break;
557 
558  case 'B':
559  {
561 
562  strcpy(&IdString[1],(char*)pBundleSeedIdString);
563  strcat(&IdString[1],(char*)pBundleIdString);
564 
565  IdString[0] = (UBYTE)(strlen(&(IdString[1])));
566 
567  if (0 <= I2cWrite(I2cFile, WRITE_DATA, (char*)IdString, (IdString[0] + 1)))
568  {
569  if (MODE2_BOOTING == Status)
570  {
571  // When bundle strings transferred then everything is assumed to be ok
572  Status = MODE2_SUCCESS;
573  }
574  }
575  }
576  break;
577 
578  case 'S':
579  {
580  #ifdef DEBUG
581  printf("\r\nS - Reset source = %02X, Status = %02X\r\n",Buf[1], Buf[2]);
582  #endif
583 
584  if (0 == Buf[2])
585  {
586  Status = MODE2_FALIURE;
588  #ifdef DEBUG
589  printf("\r\nERROR - failure on reset\r\n");
590  #endif
591  }
592  }
593  break;
594 
595  default:
596  {
597  Status = MODE2_FALIURE;
598  #ifdef DEBUG
599  printf("\r\nStatus return not recognized....\r\n");
600  #endif
601  }
602  break;
603  }
604  }
605  }
606  usleep(SLEEPuS);
607  }
608 
609  if (I2cFile >= MIN_HANDLE)
610  {
611  close (I2cFile);
612  I2cFile = -1;
613  }
614  I2cClearPIC_EN();
615  pthread_exit((void *)RtnMsg);
616 }
617 
618 
620 {
621  UBYTE Buf[10];
622  UBYTE RtnVal;
623 
624  RtnVal = 0;
625  if (BtFile >= 0)
626  {
627  read(BtFile, Buf, 1);
628 
629  if (Buf[0])
630  {
631  RtnVal = 1;
632  }
633  }
634  return(RtnVal);
635 }
636 
637 
638 void I2cSetPIC_RST(void)
639 {
640  UBYTE Set[2];
641 
642  Set[0] = SET;
643  Set[1] = PIC_RST;
644 
645  if (BtFile >= 0)
646  {
647  write(BtFile, Set, sizeof(Set));
648  }
649 }
650 
651 
652 void I2cClearPIC_RST(void)
653 {
654  UBYTE Clr[2];
655 
656  Clr[0] = CLEAR;
657  Clr[1] = PIC_RST;
658 
659  if (BtFile >= 0)
660  {
661  write(BtFile, Clr, sizeof(Clr));
662  }
663 }
664 
665 
666 void I2cSetPIC_EN(void)
667 {
668  UBYTE Set[2];
669 
670  Set[0] = SET;
671  Set[1] = PIC_EN;
672 
673  if (BtFile >= 0)
674  {
675  write(BtFile, Set, sizeof(Set));
676  }
677 }
678 
679 
680 void I2cClearPIC_EN(void)
681 {
682  UBYTE Clr[2];
683 
684  Clr[0] = CLEAR;
685  Clr[1] = PIC_EN;
686 
687  if (BtFile >= 0)
688  {
689  write(BtFile, Clr, sizeof(Clr));
690  }
691 }
692 
693 
694 void I2cHiImpPIC_EN(void)
695 {
696  UBYTE HiImp[2];
697 
698  HiImp[0] = HIIMP;
699  HiImp[1] = PIC_EN;
700 
701  if (BtFile >= 0)
702  {
703  write(BtFile, HiImp, sizeof(HiImp));
704  }
705 }
706 
707 
709 {
710  return(I2cRead(I2cFile, READ_STATUS, (char*)pBuf, 3));
711 }
712 
713 
714 // read len bytes stored in the device at address addr in array buf
715 // return -1 on error, 0 on success
716 int I2cRead(int fd, unsigned int addr, char *buf, unsigned char len)
717 {
718  int i;
719 
720  if(len > I2CBUF_SIZE)
721  {
722  #ifdef DEBUG
723  fprintf(stderr,"I can only write I2CBUF_SIZE bytes at a time!\r\n");
724  #endif
725  Status = MODE2_FALIURE;
726  return -1;
727  }
728 
729  msg_rdwr.msgs = &i2cmsg;
730  msg_rdwr.nmsgs = 1;
731 
732  i2cmsg.addr = addr;
733  i2cmsg.flags = I2C_M_RD;
734  i2cmsg.len = len;
735  i2cmsg.buf = buf;
736 
737  if((i=ioctl(fd, I2C_RDWR, &msg_rdwr)) < 0)
738  {
739  #ifdef DEBUG
740  printf("\r\nIOCTL Read error, Len = %d, i2cmsg.len = %d \r\n",len, i2cmsg.len);
741  #endif
742 
743  Status = MODE2_FALIURE;
744  return -1;
745  }
746  return 0;
747 }
748 
749 
750 int I2cWrite(int fd, unsigned int addr, char *buf, unsigned char len)
751 {
752  int i;
753 
754  msg_rdwr.msgs = &i2cmsg;
755  msg_rdwr.nmsgs = 1;
756 
757  i2cmsg.addr = addr;
758  i2cmsg.flags = 0;
759  i2cmsg.len = len;
760  i2cmsg.buf = buf;
761 
762  if((i = ioctl(fd,I2C_RDWR,&msg_rdwr)) < 0)
763  {
764  #ifdef DEBUG
765  printf("\r\nIOCTL write error, Len = %d, i2cmsg.len = %d \r\n",len, i2cmsg.len);
766  #endif
767 
768  Status = MODE2_FALIURE;
769  return -1;
770  }
771  return(len);
772 }
773 
774 
775 // Fill in as many bytes as possible - return value is the number of bytes transferred
777 {
778  UWORD BytesAccepted;
779  UWORD BytesFreeInBuf;
780  UWORD BytesTransferred;
781  UWORD Cnt;
782 
783  BytesAccepted = 0;
784 
785  // If buffer is empty if can accept more bytes otherwise it will wait accepting bytes
786  BytesFreeInBuf = BUFBytesFree;
787  if (BytesFreeInBuf)
788  {
789  if (Length > BytesFreeInBuf)
790  {
791  BytesTransferred = BytesFreeInBuf;
792  }
793  else
794  {
795  BytesTransferred = Length;
796  }
797 
798  for(Cnt = 0; Cnt < BytesTransferred; Cnt++)
799  {
800  Mode2InBuf.Buf[Mode2InBuf.InPtr] = pBuf[Cnt];
801  BUFAddInPtr(1);
802  }
803  BytesAccepted = BytesTransferred;
804  }
805  return(BytesAccepted);
806 }
807 
808 
810 {
811  return(Status);
812 }
813 
814 
815 
816 
817 
818 
819 
820 
#define BUFAddOutPtr(Val)
Definition: c_i2c.c:160
UBYTE cBtI2cBufReady(void)
Definition: c_bt.c:2523
UWORD InPtr
Definition: c_bt.h:106
void I2cHiImpPIC_EN(void)
Definition: c_i2c.c:694
Definition: c_i2c.c:95
#define MODE2BUF_SIZE
Definition: c_i2c.c:112
UWORD OutPtr
Definition: c_bt.h:107
#define SEC_1
Definition: c_i2c.c:115
#define SLEEPuS
Definition: c_i2c.c:114
void DecodeMode1(UBYTE BufNo)
Definition: c_bt.c:920
#define BUFBytesAvail
Definition: c_i2c.c:158
UBYTE I2cGetBootStatus(void)
Definition: c_i2c.c:809
#define DISCONNDueToErr
Definition: c_i2c.c:162
Definition: c_i2c.c:88
UBYTE Buf[1024]
Definition: c_bt.h:105
char * RtnMsg
Definition: c_i2c.c:129
UWORD DataToMode2Decoding(UBYTE *pBuf, UWORD Length)
Definition: c_i2c.c:776
UBYTE Buf[MODE2BUF_SIZE]
Definition: c_i2c.c:119
Definition: c_i2c.c:89
void I2cStop(void)
Definition: c_i2c.c:213
void I2cClearPIC_EN(void)
Definition: c_i2c.c:680
Definition: c_i2c.c:97
Definition: c_bt.h:113
#define MAX_BUNDLE_ID_SIZE
Definition: c_bt.h:41
UWORD OutPtr
Definition: c_i2c.c:121
void * I2cCtrl(void *ptr)
Definition: c_i2c.c:219
#define BUFBytesFree
Definition: c_i2c.c:157
unsigned char UBYTE
Basic Type used to symbolise 8 bit unsigned values.
Definition: lmstypes.h:29
UWORD cBtI2cToBtBuf(UBYTE *pBuf, UWORD Size)
Definition: c_bt.c:2536
int I2cRead(int fd, unsigned int addr, char *buf, unsigned char len)
Definition: c_i2c.c:716
unsigned short UWORD
Basic Type used to symbolise 16 bit unsigned values.
Definition: lmstypes.h:30
void I2cExit(void)
Definition: c_i2c.c:188
UBYTE I2cReadStatus(UBYTE *pBuf)
Definition: c_i2c.c:708
Definition: c_bt.h:103
void I2cSetPIC_RST(void)
Definition: c_i2c.c:638
UWORD Status
Definition: c_bt.h:108
Definition: c_i2c.c:96
UBYTE I2cReadCts(void)
Definition: c_i2c.c:619
UWORD InPtr
Definition: c_bt.h:116
RESULT I2cInit(READBUF *pBuf, WRITEBUF *pWriteBuf, char *pBundleId, char *pBundleSeedId)
Definition: c_i2c.c:168
#define I2CBUF_SIZE
Definition: c_i2c.c:110
int I2cWrite(int fd, unsigned int addr, char *buf, unsigned char len)
Definition: c_i2c.c:750
void I2cStart(void)
Definition: c_i2c.c:198
UWORD OutPtr
Definition: c_bt.h:117
UWORD InPtr
Definition: c_i2c.c:120
UBYTE Buf[1024]
Definition: c_bt.h:115
void I2cSetPIC_EN(void)
Definition: c_i2c.c:666
Definition: c_i2c.c:87
#define MIN_MSG_LEN
Definition: c_i2c.c:113
#define BUFAddInPtr(Val)
Definition: c_i2c.c:159
void I2cClearPIC_RST(void)
Definition: c_i2c.c:652
#define MAX_BUNDLE_SEED_ID_SIZE
Definition: c_bt.h:42
#define NULL