Paparazzi UAS  v5.0.5_stable-7-g4b8bbb7
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures 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 "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 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 36 of file hmc58xx.c.

Referenced by hmc58xx_set_default_config().

#define HMC58XX_DEFAULT_GN   0x1

Definition at line 42 of file hmc58xx.c.

Referenced by hmc58xx_set_default_config().

#define HMC58XX_DEFAULT_MD   0x0

Definition at line 45 of file hmc58xx.c.

Referenced by hmc58xx_set_default_config().

#define HMC58XX_DEFAULT_MS   0x0

Definition at line 39 of file hmc58xx.c.

Referenced by hmc58xx_set_default_config().

#define Int16FromBuf (   _buf,
  _idx 
)    ((int16_t)((_buf[_idx]<<8) | _buf[_idx+1]))

Definition at line 134 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 76 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 
)

Initialize Hmc58xx struct and set default config options.

Parameters
hmcHmc58xx struct
i2c_pI2C periperal to use
addrI2C address of HMC58xx

Definition at line 62 of file hmc58xx.c.

References Hmc58xx::config, FALSE, 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_impl_init(), and mag_hmc58xx_module_init().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void hmc58xx_read ( struct Hmc58xx hmc)

Definition at line 123 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(), and imu_periodic().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void hmc58xx_send_config ( struct Hmc58xx hmc)
static

Configuration function called once before normal use.

Definition at line 87 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, i2c_transaction::status, and TRUE.

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 48 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 112 of file hmc58xx.c.

References hmc58xx_send_config(), HMC_CONF_UNINIT, Hmc58xx::i2c_trans, I2CTransDone, I2CTransSuccess, Hmc58xx::init_status, and i2c_transaction::status.

Referenced by hmc58xx_periodic(), and imu_drotek2_configure_mag_slave().

+ Here is the call graph for this function:

+ Here is the caller graph for this function: