Paparazzi UAS
v5.10_stable-5-g83a0da5-dirty
Paparazzi is a free software Unmanned Aircraft System.
|
Driver for Honeywell HMC5843 and HMC5883 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_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 and HMC5883 magnetometers.
Definition in file hmc58xx.c.
#define HMC58XX_DEFAULT_DO 0x6 |
Definition at line 37 of file hmc58xx.c.
Referenced by hmc58xx_set_default_config().
#define HMC58XX_DEFAULT_GN 0x1 |
Definition at line 43 of file hmc58xx.c.
Referenced by hmc58xx_set_default_config().
#define HMC58XX_DEFAULT_MD 0x0 |
Definition at line 46 of file hmc58xx.c.
Referenced by hmc58xx_set_default_config().
#define HMC58XX_DEFAULT_MS 0x0 |
Definition at line 40 of file hmc58xx.c.
Referenced by hmc58xx_set_default_config().
#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.
Definition at line 58 of file hmc58xx.c.
Referenced by hmc58xx_start_configure().
#define Int16FromBuf | ( | _buf, | |
_idx | |||
) | ((int16_t)((_buf[_idx]<<8) | _buf[_idx+1])) |
Definition at line 150 of file hmc58xx.c.
Referenced by hmc58xx_event().
void hmc58xx_event | ( | struct Hmc58xx * | hmc | ) |
Definition at line 152 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_drotek2_event(), imu_gl1_event(), imu_hbmini_event(), imu_krooz_event(), imu_mpu_hmc_event(), imu_navgo_event(), imu_navstik_event(), imu_ppzuav_event(), imu_px4fmu_event(), and mag_hmc58xx_module_event().
Definition at line 90 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 75 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_b2_init(), imu_drotek2_init(), imu_gl1_init(), imu_hbmini_init(), imu_krooz_init(), imu_mpu_hmc_init(), imu_navgo_init(), imu_navstik_init(), imu_ppzuav_init(), imu_px4fmu_init(), and mag_hmc58xx_module_init().
void hmc58xx_read | ( | struct Hmc58xx * | hmc | ) |
Definition at line 139 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(), imu_drotek2_periodic(), and imu_krooz_event().
|
static |
Configuration function called once before normal use.
Definition at line 101 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, and i2c_transaction::status.
Referenced by hmc58xx_event(), and hmc58xx_start_configure().
|
static |
Definition at line 61 of file hmc58xx.c.
References Hmc58xxConfig::gain, HMC58XX_DEFAULT_DO, HMC58XX_DEFAULT_GN, HMC58XX_DEFAULT_MD, HMC58XX_DEFAULT_MS, Hmc58xxConfig::meas, Hmc58xxConfig::mode, and Hmc58xxConfig::rate.
Referenced by hmc58xx_init().
void hmc58xx_start_configure | ( | struct Hmc58xx * | hmc | ) |
Definition at line 126 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(), imu_drotek2_configure_mag_slave(), and imu_krooz_periodic().