code/WPILib/ADXL345_SPI.cpp
/**
 * Get the acceleration of one axis in Gs.
 * 
 * @param axis The axis to read from.
 * @return Acceleration of the ADXL345 in Gs.
 */
Get the acceleration of one axis in Gs.

@param axis The axis to read from.
@return Acceleration of the ADXL345 in Gs.
Get the acceleration of one axis in Gs . @param axis The axis to read from . @return Acceleration of the ADXL345 in Gs .
double ADXL345_SPI::GetAcceleration(ADXL345_SPI::Axes axis)
{
	INT16 rawAccel = 0;
	if(m_spi)
	{
		m_spi->Write(((kAddress_Read | kAddress_MultiByte | kDataRegister) + (UINT8)axis) << 16);
		rawAccel = (UINT16)m_spi->Read();
		rawAccel = ((rawAccel >> 8) & 0xFF) | (rawAccel << 8);
	}
	return rawAccel * kGsPerLSB;
}
double ADXL345_SPI :: GetAcceleration ( ADXL345_SPI :: Axes axis ) { INT16 rawAccel = 0 ; if ( m_spi ) { m_spi -> Write ( ( ( kAddress_Read | kAddress_MultiByte | kDataRegister ) + ( UINT8 ) axis ) << 16 ) ; rawAccel = ( UINT16 ) m_spi -> Read ( ) ; rawAccel = ( ( rawAccel >> 8 ) & 0xFF ) | ( rawAccel << 8 ) ; } return rawAccel * kGsPerLSB ; }
Get the acceleration of one axis in Gs.
Get the acceleration of one axis in Gs .
// Sensor is little endian... swap bytes