36 #ifndef HMC58XX_DEFAULT_DO
37 #define HMC58XX_DEFAULT_DO 0x6
39 #ifndef HMC58XX_DEFAULT_MS
40 #define HMC58XX_DEFAULT_MS 0x0
42 #ifndef HMC58XX_DEFAULT_GN
43 #define HMC58XX_DEFAULT_GN 0x1
45 #ifndef HMC58XX_DEFAULT_MD
46 #define HMC58XX_DEFAULT_MD 0x0
48 #ifndef HMC58XX_DEFAULT_SA
49 #define HMC58XX_DEFAULT_SA 0x0
51 #ifndef HMC58XX_DEFAULT_TC
52 #define HMC58XX_DEFAULT_TC 0x0
63 #ifndef HMC58XX_STARTUP_DELAY
64 #define HMC58XX_STARTUP_DELAY 1.5
158 #define Int16FromBuf(_buf,_idx) ((int16_t)((_buf[_idx]<<8) | _buf[_idx+1]))
178 if (hmc->
data.vect.x != -4096 && hmc->
data.vect.y != -4096 &&
179 hmc->
data.vect.z != -4096) {
volatile uint8_t buf[I2C_BUF_LEN]
Transaction buffer With I2C_BUF_LEN number of bytes.
uint16_t len_r
Number of bytes to read/receive.
enum I2CTransactionType type
Transaction type.
enum I2CTransactionStatus status
Transaction status.
uint8_t slave_addr
Slave address.
uint8_t len_w
Number of bytes to write/transmit.
static bool i2c_submit(struct i2c_periph *p, struct i2c_transaction *t)
Submit a I2C transaction.
@ I2CTransSuccess
transaction successfully finished by I2C driver
@ I2CTransFailed
transaction failed
@ I2CTransDone
transaction set to done by user level
@ I2CTransTx
transmit only transaction
@ I2CTransTxRx
transmit and receive transaction
#define HMC58XX_DEFAULT_GN
#define HMC58XX_DEFAULT_SA
#define HMC58XX_DEFAULT_TC
void hmc58xx_init(struct Hmc58xx *hmc, struct i2c_periph *i2c_p, uint8_t addr)
Initialize Hmc58xx struct and set default config options.
static void hmc58xx_set_default_config(struct Hmc58xxConfig *c)
static void hmc58xx_send_config(struct Hmc58xx *hmc)
Configuration function called once before normal use.
#define HMC58XX_DEFAULT_MS
#define HMC58XX_STARTUP_DELAY
HMC58XX startup delay.
void hmc58xx_event(struct Hmc58xx *hmc)
#define HMC58XX_DEFAULT_DO
void hmc58xx_read(struct Hmc58xx *hmc)
void hmc58xx_start_configure(struct Hmc58xx *hmc)
#define HMC58XX_DEFAULT_MD
#define Int16FromBuf(_buf, _idx)
static void hmc58xx_i2c_tx_reg(struct Hmc58xx *hmc, uint8_t reg, uint8_t val)
uint8_t mode
Measurement mode.
bool initialized
config done flag
struct i2c_periph * i2c_p
struct i2c_transaction i2c_trans
uint8_t samples_averaged
Number of samples averaged per measurement output.
uint8_t temp_comp
Enable temperature sensor (only on HMC5983)
uint8_t meas
Measurement configuration.
uint8_t gain
Gain configuration (1 -> +- 1 Gauss)
struct Hmc58xxConfig config
enum Hmc58xxConfStatus init_status
init status
volatile bool data_available
data ready flag
uint8_t rate
Data Output Rate Bits(6 -> 50Hz with HMC5843, 75Hz with HMC5883)
uint16_t adc_overflow_cnt
counts number of ADC measurement under/overflows
#define HMC58XX_REG_DATXM
Architecture independent timing functions.
static float get_sys_time_float(void)
Get the time in seconds since startup.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.