/* Reads the sensor and returns the data as a sensors_event_t.  */
err_t lsm303magGetSensorEvent(sensors_event_t *event)
/* Reads the sensor and returns the data as a sensors_event_t.  */
err_t lsm303magGetSensorEvent(sensors_event_t *event)
{
  memset(event, 0, sizeof(sensors_event_t));
  event->version   = sizeof(sensors_event_t);
  event->sensor_id = _lsm303magSensorID;
  event->type      = SENSOR_TYPE_MAGNETIC_FIELD;
  event->timestamp = delayGetTicks();
  ASSERT_STATUS(lsm303magRead());
  event->magnetic.x = _lsm303magData.x / _lsm303mag_Gauss_LSB_XY * SENSORS_GAUSS_TO_MICROTESLA;
  event->magnetic.y = _lsm303magData.y / _lsm303mag_Gauss_LSB_XY * SENSORS_GAUSS_TO_MICROTESLA;
  event->magnetic.z = _lsm303magData.z / _lsm303mag_Gauss_LSB_Z * SENSORS_GAUSS_TO_MICROTESLA;
  return ERROR_NONE;
}