cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_I2C_Master_Receive ?

antonius
Senior

Dear Members,

Is this function :

void max30100_FIFO_ReadBytes(uint8_t* Data)
 
{
 
 
//================READ FIFO DATA REGISTER======
	
	buffer_tx[0] = 0x05;//FIFO DATA REGISTER  //page 16 datasheet
	//write one byte to MAX30100, 0xAE = Write to MAX30100, 0xAF = Read to MAX30100
	HAL_I2C_Master_Transmit(&hi2c2, 0xAE, buffer_tx ,1, 100);
	
	//HAL_Delay(5);	
 
    
		//Read from FIFO DATA Register
	  HAL_I2C_Master_Receive(&hi2c2, 0xAF, Data ,6, 10); //receive 6 bytes from MAX30100
 
		
 
		
    					
}//end function	 

Equal to :

void max30102_FIFO_ReadBytes(u8 Register_Address,u8* Data)
{	
	
	
	IIC_Start();
 
	
	IIC_Send_Byte(max30102_WR_address | I2C_WR);	
 
	
	if (IIC_Wait_Ack() != 0)
	{
		goto cmd_fail;	
	}
 
	
	IIC_Send_Byte((uint8_t)Register_Address);
	if (IIC_Wait_Ack() != 0)
	{
		goto cmd_fail;	
	}
	
 
	
	IIC_Start();
 
	
	IIC_Send_Byte(max30102_WR_address | I2C_RD);	
 
	
	if (IIC_Wait_Ack() != 0)
	{
		goto cmd_fail;	
	}
 
	
	Data[0] = IIC_Read_Byte(1);	
	Data[1] = IIC_Read_Byte(1);	
	Data[2] = IIC_Read_Byte(1);	
	Data[3] = IIC_Read_Byte(1);
	Data[4] = IIC_Read_Byte(1);	
	Data[5] = IIC_Read_Byte(0);
	
	IIC_Stop();
 
cmd_fail
	IIC_Stop();

?

Thanks

0 REPLIES 0