36 #ifndef HMC58XX_DEFAULT_DO
37 #define HMC58XX_DEFAULT_DO 0x6 // Data Output Rate (6 -> 50Hz with HMC5843, 75Hz with HMC5883)
39 #ifndef HMC58XX_DEFAULT_MS
40 #define HMC58XX_DEFAULT_MS 0x0 // Measurement configuration
42 #ifndef HMC58XX_DEFAULT_GN
43 #define HMC58XX_DEFAULT_GN 0x1 // Gain configuration (1 -> +- 1 Gauss)
45 #ifndef HMC58XX_DEFAULT_MD
46 #define HMC58XX_DEFAULT_MD 0x0 // Continious measurement mode
57 #ifndef HMC58XX_STARTUP_DELAY
58 #define HMC58XX_STARTUP_DELAY 1.5
150 #define Int16FromBuf(_buf,_idx) ((int16_t)((_buf[_idx]<<8) | _buf[_idx+1]))
170 if (hmc->
data.vect.x != -4096 && hmc->
data.vect.y != -4096 &&
171 hmc->
data.vect.z != -4096) {
#define HMC58XX_DEFAULT_MD
struct i2c_periph * i2c_p
bool_t i2c_submit(struct i2c_periph *p, struct i2c_transaction *t)
Submit a I2C transaction.
volatile uint8_t buf[I2C_BUF_LEN]
Transaction buffer With I2C_BUF_LEN number of bytes.
enum Hmc58xxConfStatus init_status
init status
uint8_t mode
Measurement mode.
uint16_t len_r
Number of bytes to read/receive.
transaction successfully finished by I2C driver
void hmc58xx_start_configure(struct Hmc58xx *hmc)
transmit and receive transaction
#define HMC58XX_STARTUP_DELAY
HMC58XX startup delay.
struct i2c_transaction i2c_trans
uint8_t gain
Gain configuration (1 -> +- 1 Gauss)
static float get_sys_time_float(void)
Get the time in seconds since startup.
uint8_t meas
Measurement configuration.
bool_t initialized
config done flag
uint8_t len_w
Number of bytes to write/transmit.
static void hmc58xx_send_config(struct Hmc58xx *hmc)
Configuration function called once before normal use.
void hmc58xx_read(struct Hmc58xx *hmc)
transaction set to done by user level
Architecture independent timing functions.
#define HMC58XX_DEFAULT_MS
static void hmc58xx_i2c_tx_reg(struct Hmc58xx *hmc, uint8_t reg, uint8_t val)
#define HMC58XX_REG_DATXM
uint8_t rate
Data Output Rate Bits(6 -> 50Hz with HMC5843, 75Hz with HMC5883)
volatile bool_t data_available
data ready flag
enum I2CTransactionStatus status
Transaction status.
uint8_t slave_addr
Slave address.
#define HMC58XX_DEFAULT_GN
I2C peripheral structure.
uint16_t adc_overflow_cnt
counts number of ADC measurement under/overflows
struct Hmc58xxConfig config
static void hmc58xx_set_default_config(struct Hmc58xxConfig *c)
transmit only transaction
void hmc58xx_init(struct Hmc58xx *hmc, struct i2c_periph *i2c_p, uint8_t addr)
Initialize Hmc58xx struct and set default config options.
#define Int16FromBuf(_buf, _idx)
enum I2CTransactionType type
Transaction type.
#define HMC58XX_DEFAULT_DO
void hmc58xx_event(struct Hmc58xx *hmc)