Module for standalone operation/logging of a HMC58xx magnetometer. An arbitrary rotation between the sensor frame and the IMU frame can be compensated with a MAG_TO_IMU rotation (defined by three euler angles). The three angles must be defined to enable this correction. Otherwise it is assumed that the axis are aligned.
Add to your firmware section: This example contains all possible configuration options, not all of them are mandatory!
<module name="mag_hmc58xx">
b'<define name="MODULE_HMC58XX_SYNC_SEND" value="TRUE|FALSE" />\n '
b'<define name="MODULE_HMC58XX_UPDATE_AHRS" value="TRUE|FALSE" />\n '
b'<define name="HMC58XX_CHAN_X_SIGN" value="+|-" />\n '
b'<define name="HMC58XX_CHAN_Y_SIGN" value="+|-" />\n '
b'<define name="HMC58XX_CHAN_Z_SIGN" value="+|-" />\n '
b'<define name="HMC58XX_CHAN_X" value="0|1|2" />\n '
b'<define name="HMC58XX_CHAN_Y" value="0|1|2" />\n '
b'<define name="HMC58XX_CHAN_Z" value="0|1|2" />\n '
b'<configure name="MAG_HMC58XX_I2C_DEV" value="i2c1" />\n '
b'<configure name="MAG_HMC58XX_SA" value="00|01|10|11" />\n '
b'<configure name="MAG_HMC58XX_TC" value="0|1" />\n '
</module>
These initialization functions are called once on startup.
These event functions are called in each cycle of the module event loop.
These functions are called periodically at the specified frequency from the module periodic loop.
<!DOCTYPE module SYSTEM "module.dtd">
<module name="mag_hmc58xx" dir="sensors" task="sensors">
<doc>
<description>
HMC58xx magnetometer.
Module for standalone operation/logging of a HMC58xx magnetometer.
An arbitrary rotation between the sensor frame and the IMU frame can be compensated with a MAG_TO_IMU rotation (defined by three euler angles). The three angles must be defined to enable this correction. Otherwise it is assumed that the axis are aligned.
</description>
<configure name="MAG_HMC58XX_I2C_DEV" value="i2c1" description="I2C device to use (e.g. i2c1)"/>
<define name="MODULE_HMC58XX_SYNC_SEND" value="TRUE|FALSE" description="Send IMU_RAW message with each new measurement (default: FALSE)"/>
<define name="MODULE_HMC58XX_UPDATE_AHRS" value="TRUE|FALSE" description="Copy measurements to imu and send as ABI message (default: FALSE)"/>
<define name="HMC58XX_CHAN_X_SIGN" value="+|-" description="Reverse polarity of x axis (default: +)"/>
<define name="HMC58XX_CHAN_Y_SIGN" value="+|-" description="Reverse polarity of y axis (default: +)"/>
<define name="HMC58XX_CHAN_Z_SIGN" value="+|-" description="Reverse polarity of z axis (default: +)"/>
<define name="HMC58XX_CHAN_X" value="0|1|2" description="Channel id of x axis (default: 0)"/>
<define name="HMC58XX_CHAN_Y" value="0|1|2" description="Channel id of y axis (default: 1)"/>
<define name="HMC58XX_CHAN_Z" value="0|1|2" description="Channel id of z axis (default: 2)"/>
<section name="MAG_HMC" prefix="HMC58XX_">
<define name="MAG_TO_IMU_PHI" value="0.0" description="Rotation between sensor frame and IMU frame (phi angle)"/>
<define name="MAG_TO_IMU_THETA" value="0.0" description="Rotation between sensor frame and IMU frame (theta angle)"/>
<define name="MAG_TO_IMU_PSI" value="0.0" description="Rotation between sensor frame and IMU frame (psi angle)"/>
</section>
<configure name="MAG_HMC58XX_SA" value="00|01|10|11" description="Number of samples averaged (default HMC5843 and HMC5983: 00, HMC5883: 11)"/>
<configure name="MAG_HMC58XX_TC" value="0|1" description="Automatic compensation of sensitivity over temperature (default 0)"/>
</doc>
<dep>
<depends>i2c,@imu</depends>
<provides>mag</provides>
</dep>
<header>
<file name="mag_hmc58xx.h"/>
</header>
<init fun="mag_hmc58xx_module_init()"/>
<periodic fun="mag_hmc58xx_module_periodic()" freq="60"/>
<periodic fun="mag_hmc58xx_report()" freq="10" autorun="FALSE"/>
<event fun="mag_hmc58xx_module_event()"/>
<makefile target="ap">
<file name="mag_hmc58xx.c"/>
<file name="hmc58xx.c" dir="peripherals"/>
<raw>
ifeq ($(MAG_HMC58XX_I2C_DEV),)
$(error mag_hmc58xx module error: please configure MAG_HMC58XX_I2C_DEV)
endif
</raw>
<configure name="MAG_HMC58XX_I2C_DEV" default="TRUE" case="upper|lower"/>
<define name="USE_$(MAG_HMC58XX_I2C_DEV_UPPER)"/>
<define name="MAG_HMC58XX_I2C_DEV" value="$(MAG_HMC58XX_I2C_DEV_LOWER)"/>
<configure name="MAG_HMC58XX_SA" default="0"/>
<configure name="MAG_HMC58XX_TC" default="0"/>
<define name="HMC58XX_DEFAULT_SA" value="$(MAG_HMC58XX_SA)"/>
<define name="HMC58XX_DEFAULT_TC" value="$(MAG_HMC58XX_SA)"/>
<test>
<define name="MAG_HMC58XX_I2C_DEV" value="i2c1"/>
<define name="USE_I2C1"/>
<define name="DOWNLINK_TRANSPORT" value="pprz_tp"/>
<define name="DOWNLINK_DEVICE" value="uart0"/>
<define name="USE_UART0"/>
</test>
</makefile>
</module>