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) )
void ak8975_read(struct Ak8975 *ak)
void ak8975_configure(struct Ak8975 *ak)
void ak8975_init(struct Ak8975 *ak, struct i2c_periph *i2c_p, uint8_t addr)
#define RawFromBuf(_buf, _idx)
#define Int16FromRaw(_raw)
void ak8975_event(struct Ak8975 *ak)
#define AK8975_MEAS_TIME_MS
static float calibration_values[3]
static float get_ajusted_value(const int16_t val, const uint8_t axis)
Driver for the AKM AK8975 magnetometer.
enum Ak8975Status status
main status
#define AK8975_MODE_FUSE_ACCESS
@ AK_DISABLE_ACCESS_CALIBRATION
struct i2c_transaction i2c_trans
i2c transaction used for communication with the ak8936
enum Ak8975ConfStatus init_status
init status
uint32_t last_meas_time
last measurement time in ms
#define AK8975_REG_CNTL_ADDR
volatile bool data_available
data ready flag
bool initialized
config done flag
struct i2c_periph * i2c_p
peripheral used for communcation
#define AK8975_MODE_SINGLE_MEAS
#define AK8975_REG_ST1_ADDR
#define AK8975_MODE_POWER_DOWN
uint32_t get_sys_time_msec(void)
Get the time in milliseconds since startup.
volatile uint8_t buf[I2C_BUF_LEN]
Transaction buffer With I2C_BUF_LEN number of bytes.
enum I2CTransactionStatus status
Transaction status.
uint8_t slave_addr
Slave address.
bool i2c_transmit(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint8_t len)
Submit a write only transaction.
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.
@ I2CTransSuccess
transaction successfully finished by I2C driver
@ I2CTransFailed
transaction failed
@ I2CTransDone
transaction set to done by user level
static struct FloatVect3 H
Architecture independent timing functions.
short int16_t
Typedef defining 16 bit short type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.