Estoy tratando de hacer una brújula usando un LSM303DLHC incrustado en STM32F3Discovery. He preparado tal código.
void LSM303DLHCMag_Config(void)
{
LSM303DLHCMag_InitStructure.Temperature_Sensor = LSM303DLHC_TEMPSENSOR_DISABLE;
LSM303DLHCMag_InitStructure.MagFull_Scale = LSM303DLHC_FS_1_9_GA;
LSM303DLHCMag_InitStructure.MagOutput_DataRate = LSM303DLHC_ODR_200_HZ;
LSM303DLHCMag_InitStructure.Working_Mode = LSM303DLHC_CONTINUOS_CONVERSION;
LSM303DLHC_MagInit(&LSM303DLHCMag_InitStructure);
}
void LSM303DLHCMag_Read(float *convertedData)
{
static uint8_t XYZ[6] = {0};
LSM303DLHC_Read(MAG_I2C_ADDRESS,LSM303DLHC_OUT_X_H_M, XYZ, 6);
convertedData[0] = (float) ((XYZ[1] << 8) | (XYZ[0]))/LSM303DLHC_M_SENSITIVITY_XY_1_9Ga;
convertedData[1] = (float) ((XYZ[3] << 8) | (XYZ[2]))/LSM303DLHC_M_SENSITIVITY_Z_1_9Ga ;
convertedData[2] = (float) ((XYZ[5] << 8) | (XYZ[4]))/LSM303DLHC_M_SENSITIVITY_XY_1_9Ga;
}
uint32_t LSM303DLHC_TIMEOUT_UserCallback(void)
{
/* Block communication and all processes */
while (1)
{
}
}
int main()
{
LSM303DLHCMag_Config();
float azimuth = 0;
float convertedData[3] = {0};
while(1)
{
LSM303DLHCMag_Read(*convertedData);
azimuth = atan2(convertedData[2],convertedData[0])*180.0/M_PI;
}
}
Mi problema es que el código se ejecuta solo una vez. ¿Qué debo agregar a la función UserCallback, si es que debo?