Paparazzi UAS  v5.15_devel-47-g0391b4d
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ak8975.h File Reference

Driver for the AKM AK8975 magnetometer. More...

#include "std.h"
#include "mcu_periph/i2c.h"
#include "math/pprz_algebra_int.h"
+ Include dependency graph for ak8975.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Ak8975
 
union  Ak8975.data
 

Macros

#define AK8975_I2C_SLV_ADDR   (0x0C<<1)
 
#define AK8975_REG_ST1_ADDR   0x02
 
#define AK8975_REG_CNTL_ADDR   0x0A
 
#define AK8975_REG_ASASX   0x10
 
#define AK8975_MODE_FUSE_ACCESS   0b00001111
 
#define AK8975_MODE_POWER_DOWN   0b00000000
 
#define AK8975_MODE_SINGLE_MEAS   0b00000001
 

Enumerations

enum  Ak8975ConfStatus { AK_CONF_UNINIT, AK_REQ_CALIBRATION, AK_DISABLE_ACCESS_CALIBRATION, AK_CONF_REQUESTED }
 config status states More...
 
enum  Ak8975Status { AK_STATUS_IDLE, AK_STATUS_MEAS, AK_STATUS_READ, AK_STATUS_DONE }
 Normal status states. More...
 

Functions

void ak8975_init (struct Ak8975 *ak, struct i2c_periph *i2c_p, uint8_t addr)
 
void ak8975_configure (struct Ak8975 *ak)
 
void ak8975_event (struct Ak8975 *ak)
 
void ak8975_read (struct Ak8975 *ak)
 
static void ak8975_periodic (struct Ak8975 *ak)
 convenience function: read or start configuration if not already initialized More...
 

Detailed Description

Driver for the AKM AK8975 magnetometer.

Definition in file ak8975.h.


Data Structure Documentation

struct Ak8975

Definition at line 59 of file ak8975.h.

+ Collaboration diagram for Ak8975:
Data Fields
union Ak8975 data
volatile bool data_available data ready flag
struct i2c_periph * i2c_p peripheral used for communcation
struct i2c_transaction i2c_trans i2c transaction used for communication with the ak8936
enum Ak8975ConfStatus init_status init status
bool initialized config done flag
uint32_t last_meas_time last measurement time in ms
enum Ak8975Status status main status
union Ak8975.data

Definition at line 69 of file ak8975.h.

Data Fields
int16_t value[3] data values accessible by channel index
struct Int16Vect3 vect data vector in mag coordinate system

Macro Definition Documentation

#define AK8975_I2C_SLV_ADDR   (0x0C<<1)

Definition at line 35 of file ak8975.h.

Referenced by imu_apogee_init().

#define AK8975_MODE_FUSE_ACCESS   0b00001111

Definition at line 39 of file ak8975.h.

Referenced by ak8975_configure().

#define AK8975_MODE_POWER_DOWN   0b00000000

Definition at line 40 of file ak8975.h.

Referenced by ak8975_configure().

#define AK8975_MODE_SINGLE_MEAS   0b00000001

Definition at line 41 of file ak8975.h.

Referenced by ak8975_read().

#define AK8975_REG_ASASX   0x10

Definition at line 38 of file ak8975.h.

Referenced by ak8975_configure().

#define AK8975_REG_CNTL_ADDR   0x0A

Definition at line 37 of file ak8975.h.

Referenced by ak8975_configure(), and ak8975_read().

#define AK8975_REG_ST1_ADDR   0x02

Definition at line 36 of file ak8975.h.

Referenced by ak8975_event().

Enumeration Type Documentation

config status states

Enumerator
AK_CONF_UNINIT 
AK_REQ_CALIBRATION 
AK_DISABLE_ACCESS_CALIBRATION 
AK_CONF_REQUESTED 

Definition at line 44 of file ak8975.h.

Normal status states.

Enumerator
AK_STATUS_IDLE 
AK_STATUS_MEAS 
AK_STATUS_READ 
AK_STATUS_DONE 

Definition at line 52 of file ak8975.h.

Function Documentation

void ak8975_init ( struct Ak8975 ak,
struct i2c_periph i2c_p,
uint8_t  addr 
)
static void ak8975_periodic ( struct Ak8975 ak)
inlinestatic

convenience function: read or start configuration if not already initialized

Definition at line 83 of file ak8975.h.

References ak8975_configure(), ak8975_read(), and Ak8975::initialized.

Referenced by imu_apogee_periodic().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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: