Exemple #1
0
void MAG3110_Test(void)
{
    uint8_t ret;
    MAG3110_XYZDataTypeDef MAG3110_XYZDataStruct1;
    ret = MAG3110_Init();
    if(ret == TRUE)
    {
        UART_printf("MAG3110 Succ\r\n");
    }
    else
    {
        UART_printf("MAG3110 Err\r\n");
    }
    ret = 0;
    while(ret < 30)
        if(MAG3110_GetXYZData(&MAG3110_XYZDataStruct1) == TRUE)
        {
            UART_printf("x:%d\r\n",abs(MAG3110_XYZDataStruct1.m_XData));
            ret++;
        }
}
// function initializes the sensors and the sensor data structures
void RdSensData_Init(void)
{
	int8 i;							// loop counter

	// zero sums of sensor data (typically 200Hz) on first execution
	for (i = X; i <= Z; i++)
	{
#if defined USE_FXOS8700 || defined USE_MMA8652
		thisAccel.iSumGpFast[i] = 0;
#endif
#if defined USE_FXOS8700 || defined USE_MAG3110
		thisMag.iSumBpFast[i] = 0;
#endif
#if defined USE_FXAS21000 || defined USE_FXAS21002
		thisGyro.iSumYpFast[i] = 0;
#endif
	}

	// initialize the physical sensors over I2C
#if defined USE_MPL3115
	globals.iMPL3115Found = MPL3115_Init(I2C_DeviceData, &thisPressure);
#endif
#if defined USE_FXOS8700
	FXOS8700_Init(I2C_DeviceData, &thisAccel, &thisMag);
#endif
#if defined USE_FXAS21000
	FXAS21000_Init(I2C_DeviceData, &thisGyro);
#endif
#if defined USE_FXAS21002
	FXAS21002_Init(I2C_DeviceData, &thisGyro);
#endif
#if defined USE_MMA8652
	MMA8652_Init(I2C_DeviceData, &thisAccel);
#endif
#if defined USE_MAG3110
	MAG3110_Init(I2C_DeviceData, &thisMag);
#endif

	return;
}