uint8_t I2C_SingleByteRead(uint8_t register_address)
{
uint8_t mask=0;
while(I2C_GetFlagStatus(I2C1,I2C_FLAG_BUSY)==SET);
I2C_GenerateSTART(I2C1,ENABLE);
while(I2C_CheckEvent(I2C1,I2C_EVENT_MASTER_MODE_SELECT)==ERROR);
I2C_Send7bitAddress(I2C1,MPU6050_Default_Address,I2C_Direction_Transmitter);
while(I2C_CheckEvent(I2C1,I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED)==ERROR);
I2C_SendData(I2C1,register_address);
while(I2C_CheckEvent(I2C1,I2C_EVENT_MASTER_BYTE_TRANSMITTED)==ERROR);
I2C_GenerateSTART(I2C1,ENABLE);
while(I2C_CheckEvent(I2C1,I2C_EVENT_MASTER_MODE_SELECT)==ERROR);
I2C_Send7bitAddress(I2C1,MPU6050_Default_Address,I2C_Direction_Receiver);
while(I2C_CheckEvent(I2C1,I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED)==ERROR);
I2C_AcknowledgeConfig(I2C1,DISABLE);
I2C_ReceiveData(I2C1);
while(I2C_CheckEvent(I2C1,I2C_EVENT_MASTER_BYTE_RECEIVED)==ERROR);
mask= I2C_ReadRegister(I2C1,I2C_Register_DR);
I2C_GenerateSTOP(I2C1,ENABLE);
I2C_AcknowledgeConfig(I2C1,ENABLE);
return mask;
}