Mikroelektronika MIKROE-724 データシート

ページ / 726
452
mikoBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
Soft_I2C_Read
Soft_I2C_Write
Prototype
sub function Soft_I2C_Read(dim ack as word) as byte
Description Reads one byte from the slave.
Parameters 
ack
: acknowledge signal parameter. If the 
ack==0
 not acknowledge signal will be sent after reading, 
otherwise the acknowledge signal will be sent. 
Returns
One byte from the Slave.
Requires
Soft I²C must be configured before using this function. See Soft_I2C_Init routine.
Also, START signal needs to be issued in order to use this function. See Soft_I2C_Start routine.
Example
dim take as byte
...
‘ Read data and send the not_acknowledge signal
take = Soft_I2C_Read(0)
Notes
None
Prototype
sub function Soft_I2C_Write(dim data_ as byte) as byte
Description Sends data byte via the I²C bus.
Parameters 
data_
: data to be sent 
Returns
0
 if there were no errors. 
1
 if write collision was detected on the I²C bus. 
Requires
Soft I²C must be configured before using this function. See Soft_I2C_Init routine.
Also, START signal needs to be issued in order to use this function. See Soft_I2C_Start routine.
Example
dim data_, error as byte
...
error = Soft_I2C_Write(data_)
error = Soft_I2C_Write($A3)
Notes
None
Soft_I2C_Stop
Prototype
sub procedure Soft_I2C_Stop()
Description Issues STOP signal.
Parameters None.
Returns
Nothing.
Requires
Soft I²C must be configured before using this function. See Soft_I2C_Init routine.
Example
‘ Issue STOP signal
Soft_I2C_Stop()
Notes
None