31 #define AK8975_MEAS_TIME_MS 9
40 const float H = (float) val;
42 const float Hadj = corr_factor * H;
96 ((((
float)(ak->
i2c_trans.
buf[i]) - 128.0f)*0.5f)/128.0f)+1.0f;
128 #define RawFromBuf(_buf,_idx) ((int16_t)(_buf[_idx] | (_buf[_idx+1] << 8)))
130 #define Int16FromRaw(_raw) ( (_raw & 0x1FFF) > 0xFFF ? (_raw & 0x1FFF) - 0x2000 : (_raw & 0x0FFF) )
volatile uint8_t buf[I2C_BUF_LEN]
Transaction buffer With I2C_BUF_LEN number of bytes.
transaction successfully finished by I2C driver
uint32_t get_sys_time_msec(void)
void ak8975_event(struct Ak8975 *ak)
volatile bool data_available
data ready flag
uint32_t last_meas_time
last measurement time in ms
enum Ak8975ConfStatus init_status
init status
void ak8975_init(struct Ak8975 *ak, struct i2c_periph *i2c_p, uint8_t addr)
static float calibration_values[3]
#define AK8975_REG_ST1_ADDR
void ak8975_read(struct Ak8975 *ak)
#define Int16FromRaw(_raw)
#define RawFromBuf(_buf, _idx)
transaction set to done by user level
Architecture independent timing functions.
#define AK8975_MODE_POWER_DOWN
enum Ak8975Status status
main status
static float get_ajusted_value(const int16_t val, const uint8_t axis)
#define AK8975_MODE_FUSE_ACCESS
bool i2c_transceive(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint8_t len_w, uint16_t len_r)
Submit a write/read transaction.
enum I2CTransactionStatus status
Transaction status.
bool i2c_transmit(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint8_t len)
Submit a write only transaction.
bool initialized
config done flag
uint8_t slave_addr
Slave address.
#define AK8975_REG_CNTL_ADDR
I2C peripheral structure.
Driver for the AKM AK8975 magnetometer.
#define AK8975_MEAS_TIME_MS
#define AK8975_MODE_SINGLE_MEAS
void ak8975_configure(struct Ak8975 *ak)
struct i2c_transaction i2c_trans
i2c transaction used for communication with the ak8936
struct i2c_periph * i2c_p
peripheral used for communcation