DroneOS/Drivers/Source/drvHMC5883.c
///////////////////////////////////////////////////////////////////////////////
//! Reads HMC5883 device ID bytes
//! \return Device ID value
Reads HMC5883 device ID bytes
\return Device ID value
Reads HMC5883 device ID bytes \ return Device ID value
dosDWord drvHMC5883ReadID(void)
{
	dosWord i = 0;
	dosByte value;
	dosByte id_length = 3;
	dosDWord retval = 0;
	dosBool ack = HMC5883_I2C_Start(HMC5883_I2C, drvI2C_WRITE, drvHMC5883_BASE_ADDRESS);
  if( ack )
  {
		HMC5883_I2C_WriteByte(HMC5883_I2C, drvHMC5883_DATAOUT_IDA_REG);
		HMC5883_I2C_Restart(HMC5883_I2C, drvI2C_READ, drvHMC5883_BASE_ADDRESS);
		for(i = 0; i < id_length; i++)
		{
			value = HMC5883_I2C_ReadByte(HMC5883_I2C, (i==id_length-1)?drvI2C_NACK:drvI2C_ACK);
			retval |= (value << (i*8));
		}
	}
	HMC5883_I2C_Stop(HMC5883_I2C);
	return retval;
}
dosDWord drvHMC5883ReadID ( void ) { dosWord i = 0 ; dosByte value ; dosByte id_length = 3 ; dosDWord retval = 0 ; dosBool ack = HMC5883_I2C_Start ( HMC5883_I2C , drvI2C_WRITE , drvHMC5883_BASE_ADDRESS ) ; if ( ack ) { HMC5883_I2C_WriteByte ( HMC5883_I2C , drvHMC5883_DATAOUT_IDA_REG ) ; HMC5883_I2C_Restart ( HMC5883_I2C , drvI2C_READ , drvHMC5883_BASE_ADDRESS ) ; for ( i = 0 ; i < id_length ; i ++ ) { value = HMC5883_I2C_ReadByte ( HMC5883_I2C , ( i == id_length - 1 ) ? drvI2C_NACK : drvI2C_ACK ) ; retval |= ( value << ( i * 8 ) ) ; } } HMC5883_I2C_Stop ( HMC5883_I2C ) ; return retval ; }
Reads HMC5883 device ID bytes
\return Device ID value
Reads HMC5883 device ID bytes \ return Device ID value
// read block  