Paparazzi UAS  v5.10_stable-5-g83a0da5-dirty
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
hmc58xx.c File Reference

Driver for Honeywell HMC5843 and HMC5883 magnetometers. More...

#include "peripherals/hmc58xx.h"
#include "mcu_periph/sys_time.h"
#include "std.h"
+ Include dependency graph for hmc58xx.c:

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)
 

Detailed Description

Driver for Honeywell HMC5843 and HMC5883 magnetometers.

Todo:
DRDY/IRQ handling

Definition in file hmc58xx.c.

Macro Definition Documentation

#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().

Function Documentation

static void hmc58xx_i2c_tx_reg ( struct Hmc58xx hmc,
uint8_t  reg,
uint8_t  val 
)
static

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().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void hmc58xx_init ( struct Hmc58xx hmc,
struct i2c_periph i2c_p,
uint8_t  addr 
)
void hmc58xx_read ( struct Hmc58xx hmc)
static void hmc58xx_send_config ( struct Hmc58xx hmc)
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().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void hmc58xx_set_default_config ( struct Hmc58xxConfig c)
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().

+ Here is the caller graph for this function:

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().

+ Here is the call graph for this function:

+ Here is the caller graph for this function: