User manual
392
mikoC PRO for dsPIC
MikroElektronika
I2Cx_Is_Idle
I2Cx_Read
Prototype
unsigned I2Cx_Is_Idle();
Description Waits for the I²C bus to become free. This is a blocking function.
Parameters None.
Returns - 0 if I²C bus is free. 
- 1 if I²C bus is not free. 
Requires MCU with at least one I²C module.
Used I²C module must be initialized before using this function. See I2Cx_Init routine.
Example
unsigned char data_;
...
if !(I2C1_Is_Idle)
 I2C1_Write(data_);
...
Notes I²C  library  routines  require  you  to  specify  the  module  you  want  to  use.  To  select  the  desired  I²C 
module, simply change the letter x in the routine prototype for a number from 1 to 3.
Number of I²C  modules per MCU differs from chip to chip. Please,  read the appropriate datasheet 
before utilizing this library.
Prototype
unsigned char I2Cx_Read(unsigned ack);
Description Reads a byte from the I²C bus.
Parameters - ack: acknowledge signal parameter. If the ack = 0, acknowledge signal will be sent after reading, 
otherwise the not acknowledge signal will be sent. 
Returns Received data.
Requires MCU with at least one I²C module.
Used I²C module must be initialized before using this function. See I2Cx_Init routine.
Also, START signal needs to be issued in order to use this function. See I2Cx_Start.
Example
unsigned char take;
...
// Read data and send the not_acknowledge signal
take = I2C1_Read(1);
Notes I²C  library  routines  require  you  to  specify  the  module  you  want  to  use.  To  select  the  desired  I²C 
module, simply change the letter x in the routine prototype for a number from 1 to 3.
Number of I²C  modules per MCU differs from chip to chip. Please,  read the appropriate datasheet 
before utilizing this library.










