Imported Upstream version 2.9.0
[debian/cc1111] / device / lib / pic16 / libio / i2c / i2creads.c
1
2 #include <pic18fregs.h>
3
4 #include <i2c.h>
5
6
7 char i2c_readstr(_I2CPARAM_SPEC unsigned char *ptr, unsigned char len)
8 {
9   unsigned char count=0;
10   
11   while( len-- ) {
12     *ptr++ = i2c_readchar();
13     
14     while(SSPCON2bits.RCEN) {
15       if(PIR2bits.BCLIF)return (-1);
16       count++;
17     
18       if(len) {
19         I2C_ACK();
20         while(SSPCON2bits.ACKEN);
21       }
22     }
23   }
24   
25   return count;
26 }