Paparazzi UAS  v5.12_stable-4-g9b43e9b
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ak8975.c File Reference

Driver for the AKM AK8975 magnetometer. More...

+ Include dependency graph for ak8975.c:

Go to the source code of this file.

Macros

#define AK8975_MEAS_TIME_MS   9
 
#define RawFromBuf(_buf, _idx)   ((int16_t)(_buf[_idx] | (_buf[_idx+1] << 8)))
 
#define Int16FromRaw(_raw)   ( (_raw & 0x1FFF) > 0xFFF ? (_raw & 0x1FFF) - 0x2000 : (_raw & 0x0FFF) )
 

Functions

static float get_ajusted_value (const int16_t val, const uint8_t axis)
 
void ak8975_init (struct Ak8975 *ak, struct i2c_periph *i2c_p, uint8_t addr)
 
void ak8975_configure (struct Ak8975 *ak)
 
void ak8975_read (struct Ak8975 *ak)
 
void ak8975_event (struct Ak8975 *ak)
 

Variables

static float calibration_values [3] = { 0, 0, 0 }
 

Detailed Description

Driver for the AKM AK8975 magnetometer.

Definition in file ak8975.c.

Macro Definition Documentation

#define AK8975_MEAS_TIME_MS   9

Definition at line 31 of file ak8975.c.

Referenced by ak8975_event().

#define Int16FromRaw (   _raw)    ( (_raw & 0x1FFF) > 0xFFF ? (_raw & 0x1FFF) - 0x2000 : (_raw & 0x0FFF) )

Definition at line 130 of file ak8975.c.

Referenced by ak8975_event().

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

Definition at line 128 of file ak8975.c.

Referenced by ak8975_event().

Function Documentation

void ak8975_init ( struct Ak8975 ak,
struct i2c_periph i2c_p,
uint8_t  addr 
)
void ak8975_read ( struct Ak8975 ak)

Definition at line 113 of file ak8975.c.

References AK8975_MODE_SINGLE_MEAS, AK8975_REG_CNTL_ADDR, AK_STATUS_IDLE, AK_STATUS_MEAS, i2c_transaction::buf, get_sys_time_msec(), Ak8975::i2c_p, Ak8975::i2c_trans, i2c_transmit(), Ak8975::last_meas_time, i2c_transaction::slave_addr, and Ak8975::status.

Referenced by ak8975_periodic().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static float get_ajusted_value ( const int16_t  val,
const uint8_t  axis 
)
static

Definition at line 38 of file ak8975.c.

References calibration_values, and H.

Variable Documentation

float calibration_values[3] = { 0, 0, 0 }
static

Definition at line 36 of file ak8975.c.

Referenced by ak8975_configure(), and get_ajusted_value().