Paparazzi UAS
v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
|
Driver for Honeywell HMC5843, HMC5883 and HMC5983 magnetometers. More...
Go to the source code of this file.
Macros | |
#define | HMC58XX_DEFAULT_DO 0x6 |
#define | HMC58XX_DEFAULT_MS 0x0 |
#define | HMC58XX_DEFAULT_GN 0x1 |
#define | HMC58XX_DEFAULT_MD 0x0 |
#define | HMC58XX_DEFAULT_SA 0x0 |
#define | HMC58XX_DEFAULT_TC 0x0 |
#define | HMC58XX_STARTUP_DELAY 1.5 |
HMC58XX startup delay. More... | |
#define | Int16FromBuf(_buf, _idx) ((int16_t)((_buf[_idx]<<8) | _buf[_idx+1])) |
Functions | |
static void | hmc58xx_set_default_config (struct Hmc58xxConfig *c) |
void | hmc58xx_init (struct Hmc58xx *hmc, struct i2c_periph *i2c_p, uint8_t addr) |
Initialize Hmc58xx struct and set default config options. More... | |
static void | hmc58xx_i2c_tx_reg (struct Hmc58xx *hmc, uint8_t reg, uint8_t val) |
static void | hmc58xx_send_config (struct Hmc58xx *hmc) |
Configuration function called once before normal use. More... | |
void | hmc58xx_start_configure (struct Hmc58xx *hmc) |
void | hmc58xx_read (struct Hmc58xx *hmc) |
void | hmc58xx_event (struct Hmc58xx *hmc) |
Driver for Honeywell HMC5843, HMC5883 and HMC5983 magnetometers.
Definition in file hmc58xx.c.
#define HMC58XX_STARTUP_DELAY 1.5 |
HMC58XX startup delay.
On startup, the hmc is making a first conversion in single mode. Trying to configure the mode register before the end of this conversion seems to void the configuration. Default conversion rate is 15 Hz (66ms) and worst case is O.75Hz (1.3s). Let set the default delay to 1.5s afer boot time.
#define Int16FromBuf | ( | _buf, | |
_idx | |||
) | ((int16_t)((_buf[_idx]<<8) | _buf[_idx+1])) |
void hmc58xx_event | ( | struct Hmc58xx * | hmc | ) |
Definition at line 160 of file hmc58xx.c.
References Hmc58xx::adc_overflow_cnt, i2c_transaction::buf, Hmc58xx::data, Hmc58xx::data_available, hmc58xx_send_config(), HMC_CONF_UNINIT, HMC_TYPE_5843, Hmc58xx::i2c_trans, I2CTransDone, I2CTransFailed, I2CTransSuccess, Hmc58xx::init_status, Hmc58xx::initialized, Int16FromBuf, i2c_transaction::status, and Hmc58xx::type.
Referenced by imu_aspirin_event(), imu_aspirin_i2c_event(), imu_mpu_hmc_event(), imu_px4fmu_event(), and mag_hmc58xx_module_event().
Definition at line 98 of file hmc58xx.c.
References i2c_transaction::buf, Hmc58xx::i2c_p, i2c_submit(), Hmc58xx::i2c_trans, I2CTransTx, i2c_transaction::len_r, i2c_transaction::len_w, i2c_transaction::type, and val.
Referenced by hmc58xx_send_config().
void hmc58xx_init | ( | struct Hmc58xx * | hmc, |
struct i2c_periph * | i2c_p, | ||
uint8_t | addr | ||
) |
Initialize Hmc58xx struct and set default config options.
hmc | Hmc58xx struct |
i2c_p | I2C periperal to use |
addr | I2C address of HMC58xx |
Definition at line 83 of file hmc58xx.c.
References Hmc58xx::adc_overflow_cnt, Hmc58xx::config, hmc58xx_set_default_config(), HMC_CONF_UNINIT, HMC_TYPE_5883, Hmc58xx::i2c_p, Hmc58xx::i2c_trans, I2CTransDone, Hmc58xx::init_status, Hmc58xx::initialized, i2c_transaction::slave_addr, i2c_transaction::status, and Hmc58xx::type.
Referenced by imu_aspirin_i2c_init(), imu_aspirin_init(), imu_mpu_hmc_init(), imu_px4fmu_init(), and mag_hmc58xx_module_init().
void hmc58xx_read | ( | struct Hmc58xx * | hmc | ) |
Definition at line 147 of file hmc58xx.c.
References i2c_transaction::buf, HMC58XX_REG_DATXM, Hmc58xx::i2c_p, i2c_submit(), Hmc58xx::i2c_trans, I2CTransDone, I2CTransTxRx, Hmc58xx::initialized, i2c_transaction::len_r, i2c_transaction::len_w, i2c_transaction::status, and i2c_transaction::type.
Referenced by hmc58xx_periodic().
|
static |
Configuration function called once before normal use.
Definition at line 109 of file hmc58xx.c.
References Hmc58xx::config, Hmc58xxConfig::gain, hmc58xx_i2c_tx_reg(), HMC58XX_REG_CFGA, HMC58XX_REG_CFGB, HMC58XX_REG_MODE, HMC_CONF_CRA, HMC_CONF_CRB, HMC_CONF_DONE, HMC_CONF_MODE, Hmc58xx::i2c_trans, I2CTransDone, Hmc58xx::init_status, Hmc58xx::initialized, Hmc58xxConfig::meas, Hmc58xxConfig::mode, Hmc58xxConfig::rate, Hmc58xxConfig::samples_averaged, i2c_transaction::status, and Hmc58xxConfig::temp_comp.
Referenced by hmc58xx_event(), and hmc58xx_start_configure().
|
static |
Definition at line 67 of file hmc58xx.c.
References Hmc58xxConfig::gain, HMC58XX_DEFAULT_DO, HMC58XX_DEFAULT_GN, HMC58XX_DEFAULT_MD, HMC58XX_DEFAULT_MS, HMC58XX_DEFAULT_SA, HMC58XX_DEFAULT_TC, Hmc58xxConfig::meas, Hmc58xxConfig::mode, Hmc58xxConfig::rate, Hmc58xxConfig::samples_averaged, and Hmc58xxConfig::temp_comp.
Referenced by hmc58xx_init().
void hmc58xx_start_configure | ( | struct Hmc58xx * | hmc | ) |
Definition at line 134 of file hmc58xx.c.
References get_sys_time_float(), hmc58xx_send_config(), HMC58XX_STARTUP_DELAY, HMC_CONF_UNINIT, Hmc58xx::i2c_trans, I2CTransDone, I2CTransSuccess, Hmc58xx::init_status, and i2c_transaction::status.
Referenced by hmc58xx_periodic().