mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-11 19:24:10 +01:00
2119067722
Conflicts: Makefile flight/Modules/Attitude/revolution/attitude.c flight/Modules/Battery/battery.c flight/Modules/FixedWingPathFollower/fixedwingpathfollower.c flight/Modules/GPS/GPS.c flight/Modules/ManualControl/inc/manualcontrol.h flight/Modules/ManualControl/manualcontrol.c flight/Modules/OveroSync/overosync.c flight/Modules/PathPlanner/inc/pathplanner.h flight/Modules/PathPlanner/pathplanner.c flight/Modules/Sensors/sensors.c flight/Modules/VtolPathFollower/vtolpathfollower.c flight/PiOS/Boards/STM32F4xx_Revolution.h flight/PiOS/Boards/pios_board.h flight/PiOS/STM32F4xx/library.mk flight/PiOS/inc/pios_hmc5883.h flight/PiOS/inc/pios_l3gd20.h flight/PiOS/inc/pios_rfm22b_priv.h flight/Revolution/Makefile flight/Revolution/Makefile.osx flight/Revolution/System/inc/pios_config.h flight/Revolution/UAVObjects.inc ground/openpilotgcs/src/libs/utils/coordinateconversions.cpp ground/openpilotgcs/src/libs/utils/homelocationutil.cpp ground/openpilotgcs/src/libs/utils/homelocationutil.h ground/openpilotgcs/src/plugins/config/configrevowidget.cpp ground/openpilotgcs/src/plugins/hitlnew/il2simulator.cpp ground/openpilotgcs/src/plugins/opmap/opmapgadgetwidget.cpp ground/openpilotgcs/src/plugins/plugins.pro ground/openpilotgcs/src/plugins/uavobjects/uavobjects.pro package/Makefile shared/uavobjectdefinition/fixedwingpathfollowersettings.xml shared/uavobjectdefinition/fixedwingpathfollowerstatus.xml shared/uavobjectdefinition/flightstatus.xml shared/uavobjectdefinition/hwsettings.xml shared/uavobjectdefinition/manualcontrolsettings.xml shared/uavobjectdefinition/pathdesired.xml shared/uavobjectdefinition/vtolpathfollowersettings.xml shared/uavobjectdefinition/waypoint.xml
119 lines
4.3 KiB
C
119 lines
4.3 KiB
C
/**
|
|
******************************************************************************
|
|
* @addtogroup PIOS PIOS Core hardware abstraction layer
|
|
* @{
|
|
* @addtogroup PIOS_HMC5883 HMC5883 Functions
|
|
* @brief Deals with the hardware interface to the magnetometers
|
|
* @{
|
|
*
|
|
* @file pios_hmc5883.h
|
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
|
* @brief HMC5883 functions header.
|
|
* @see The GNU Public License (GPL) Version 3
|
|
*
|
|
*****************************************************************************/
|
|
/*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful, but
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
* for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
*/
|
|
|
|
#ifndef PIOS_HMC5883_H
|
|
#define PIOS_HMC5883_H
|
|
|
|
#include <pios.h>
|
|
|
|
/* HMC5883 Addresses */
|
|
#define PIOS_HMC5883_I2C_ADDR 0x1E
|
|
#define PIOS_HMC5883_I2C_READ_ADDR 0x3D
|
|
#define PIOS_HMC5883_I2C_WRITE_ADDR 0x3C
|
|
#define PIOS_HMC5883_CONFIG_REG_A (uint8_t)0x00
|
|
#define PIOS_HMC5883_CONFIG_REG_B (uint8_t)0x01
|
|
#define PIOS_HMC5883_MODE_REG (uint8_t)0x02
|
|
#define PIOS_HMC5883_DATAOUT_XMSB_REG 0x03
|
|
#define PIOS_HMC5883_DATAOUT_XLSB_REG 0x04
|
|
#define PIOS_HMC5883_DATAOUT_ZMSB_REG 0x05
|
|
#define PIOS_HMC5883_DATAOUT_ZLSB_REG 0x06
|
|
#define PIOS_HMC5883_DATAOUT_YMSB_REG 0x07
|
|
#define PIOS_HMC5883_DATAOUT_YLSB_REG 0x08
|
|
#define PIOS_HMC5883_DATAOUT_STATUS_REG 0x09
|
|
#define PIOS_HMC5883_DATAOUT_IDA_REG 0x0A
|
|
#define PIOS_HMC5883_DATAOUT_IDB_REG 0x0B
|
|
#define PIOS_HMC5883_DATAOUT_IDC_REG 0x0C
|
|
|
|
/* Output Data Rate */
|
|
#define PIOS_HMC5883_ODR_0_75 0x00
|
|
#define PIOS_HMC5883_ODR_1_5 0x04
|
|
#define PIOS_HMC5883_ODR_3 0x08
|
|
#define PIOS_HMC5883_ODR_7_5 0x0C
|
|
#define PIOS_HMC5883_ODR_15 0x10
|
|
#define PIOS_HMC5883_ODR_30 0x14
|
|
#define PIOS_HMC5883_ODR_75 0x18
|
|
|
|
/* Measure configuration */
|
|
#define PIOS_HMC5883_MEASCONF_NORMAL 0x00
|
|
#define PIOS_HMC5883_MEASCONF_BIAS_POS 0x01
|
|
#define PIOS_HMC5883_MEASCONF_BIAS_NEG 0x02
|
|
|
|
/* Gain settings */
|
|
#define PIOS_HMC5883_GAIN_0_88 0x00
|
|
#define PIOS_HMC5883_GAIN_1_3 0x20
|
|
#define PIOS_HMC5883_GAIN_1_9 0x40
|
|
#define PIOS_HMC5883_GAIN_2_5 0x60
|
|
#define PIOS_HMC5883_GAIN_4_0 0x80
|
|
#define PIOS_HMC5883_GAIN_4_7 0xA0
|
|
#define PIOS_HMC5883_GAIN_5_6 0xC0
|
|
#define PIOS_HMC5883_GAIN_8_1 0xE0
|
|
|
|
/* Modes */
|
|
#define PIOS_HMC5883_MODE_CONTINUOUS 0x00
|
|
#define PIOS_HMC5883_MODE_SINGLE 0x01
|
|
#define PIOS_HMC5883_MODE_IDLE 0x02
|
|
#define PIOS_HMC5883_MODE_SLEEP 0x03
|
|
|
|
/* Sensitivity Conversion Values */
|
|
#define PIOS_HMC5883_Sensitivity_0_88Ga 1370 // LSB/Ga
|
|
#define PIOS_HMC5883_Sensitivity_1_3Ga 1090 // LSB/Ga
|
|
#define PIOS_HMC5883_Sensitivity_1_9Ga 820 // LSB/Ga
|
|
#define PIOS_HMC5883_Sensitivity_2_5Ga 660 // LSB/Ga
|
|
#define PIOS_HMC5883_Sensitivity_4_0Ga 440 // LSB/Ga
|
|
#define PIOS_HMC5883_Sensitivity_4_7Ga 390 // LSB/Ga
|
|
#define PIOS_HMC5883_Sensitivity_5_6Ga 330 // LSB/Ga
|
|
#define PIOS_HMC5883_Sensitivity_8_1Ga 230 // LSB/Ga --> NOT RECOMMENDED
|
|
|
|
|
|
struct pios_hmc5883_cfg {
|
|
#ifdef PIOS_HMC5883_HAS_GPIOS
|
|
const struct pios_exti_cfg * exti_cfg; /* Pointer to the EXTI configuration */
|
|
#endif
|
|
uint8_t M_ODR; /* OUTPUT DATA RATE --> here below the relative define (See datasheet page 11 for more details) */
|
|
uint8_t Meas_Conf; /* Measurement Configuration,: Normal, positive bias, or negative bias --> here below the relative define */
|
|
uint8_t Gain; /* Gain Configuration, select the full scale --> here below the relative define (See datasheet page 11 for more details) */
|
|
uint8_t Mode;
|
|
|
|
};
|
|
|
|
/* Public Functions */
|
|
extern void PIOS_HMC5883_Init(const struct pios_hmc5883_cfg * cfg);
|
|
extern bool PIOS_HMC5883_NewDataAvailable(void);
|
|
extern int32_t PIOS_HMC5883_ReadMag(int16_t out[3]);
|
|
extern uint8_t PIOS_HMC5883_ReadID(uint8_t out[4]);
|
|
extern int32_t PIOS_HMC5883_Test(void);
|
|
extern bool PIOS_HMC5883_IRQHandler();
|
|
#endif /* PIOS_HMC5883_H */
|
|
|
|
/**
|
|
* @}
|
|
* @}
|
|
*/
|