NinjaFlight
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
compass_ak8975.c File Reference
#include <stdbool.h>
#include <stdint.h>
#include <math.h>
#include "build_config.h"
#include <platform.h>
#include "common/axis.h"
#include "common/maths.h"
#include "system.h"
#include "gpio.h"
#include "bus_i2c.h"
#include "sensor.h"
#include "compass.h"
#include "compass_ak8975.h"
Include dependency graph for compass_ak8975.c:

Macros

#define AK8975_MAG_I2C_ADDRESS   0x0C
 
#define AK8975_MAG_REG_WHO_AM_I   0x00
 
#define AK8975_MAG_REG_INFO   0x01
 
#define AK8975_MAG_REG_STATUS1   0x02
 
#define AK8975_MAG_REG_HXL   0x03
 
#define AK8975_MAG_REG_HXH   0x04
 
#define AK8975_MAG_REG_HYL   0x05
 
#define AK8975_MAG_REG_HYH   0x06
 
#define AK8975_MAG_REG_HZL   0x07
 
#define AK8975_MAG_REG_HZH   0x08
 
#define AK8975_MAG_REG_STATUS2   0x09
 
#define AK8975_MAG_REG_CNTL   0x0a
 
#define AK8975_MAG_REG_ASCT   0x0c
 
#define AK8975A_ASAX   0x10
 
#define AK8975A_ASAY   0x11
 
#define AK8975A_ASAZ   0x12
 
#define BIT_STATUS1_REG_DATA_READY   (1 << 0)
 
#define BIT_STATUS2_REG_DATA_ERROR   (1 << 2)
 
#define BIT_STATUS2_REG_MAG_SENSOR_OVERFLOW   (1 << 3)
 

Functions

bool ak8975Detect (mag_t *mag)
 
void ak8975Init (void)
 
bool ak8975Read (int16_t *magData)
 

Macro Definition Documentation

#define AK8975_MAG_I2C_ADDRESS   0x0C
#define AK8975_MAG_REG_ASCT   0x0c
#define AK8975_MAG_REG_CNTL   0x0a
#define AK8975_MAG_REG_HXH   0x04
#define AK8975_MAG_REG_HXL   0x03
#define AK8975_MAG_REG_HYH   0x06
#define AK8975_MAG_REG_HYL   0x05
#define AK8975_MAG_REG_HZH   0x08
#define AK8975_MAG_REG_HZL   0x07
#define AK8975_MAG_REG_INFO   0x01
#define AK8975_MAG_REG_STATUS1   0x02
#define AK8975_MAG_REG_STATUS2   0x09
#define AK8975_MAG_REG_WHO_AM_I   0x00
#define AK8975A_ASAX   0x10
#define AK8975A_ASAY   0x11
#define AK8975A_ASAZ   0x12
#define BIT_STATUS1_REG_DATA_READY   (1 << 0)
#define BIT_STATUS2_REG_DATA_ERROR   (1 << 2)
#define BIT_STATUS2_REG_MAG_SENSOR_OVERFLOW   (1 << 3)

Function Documentation

bool ak8975Detect ( mag_t mag)

Here is the call graph for this function:

void ak8975Init ( void  )

Here is the call graph for this function:

bool ak8975Read ( int16_t *  magData)

Here is the call graph for this function: