Exemplo n.º 1
0
// Receive one byte via I2C. 
BYTE I2C_ReadByte(BYTE I2cDevice)
{
	BYTE i = 8;
	BYTE Dat = 0;

	SetInputSDA(I2cDevice);
	while(i--)
	{	
		Dat <<= 1;
		if(GetSDA(I2cDevice))
		{
		  	Dat |= 0x01;
		}
		SetSCL(I2cDevice);
		KtIICDelay();
		ClrSCL(I2cDevice);	 
	}
	SetOutputSDA(I2cDevice);
	return Dat;
}
Exemplo n.º 2
0
/**
  * @brief  This function recieve one byte from I2C slave.
  * @param  none
  * @return Data received from I2C slave
  */
uint8_t I2cReadByte(void* I2cMasterHandle)
{
	uint8_t i = 8;
	uint8_t Dat = 0;

	SetInputSDA(I2cMasterHandle);
	while(i--)
	{
		SetSCL(I2cMasterHandle);
		Dat <<= 1;
		if(GetSDA(I2cMasterHandle))
		{
			Dat |= 0x01;
		}
		ClrSCL(I2cMasterHandle);
	}
	SetOutputSDA(I2cMasterHandle);

	return Dat;
}