NinjaFlight
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
compass_ak8963.c File Reference
#include <stdbool.h>
#include <stdint.h>
#include <math.h>
#include "build_config.h"
#include "platform.h"
#include "debug.h"
#include "common/axis.h"
#include "common/maths.h"
#include "config/parameter_group.h"
#include "system.h"
#include "gpio.h"
#include "exti.h"
#include "bus_i2c.h"
#include "bus_spi.h"
#include "sensor.h"
#include "compass.h"
#include "accgyro.h"
#include "accgyro_mpu.h"
#include "accgyro_mpu6500.h"
#include "accgyro_spi_mpu6500.h"
#include "compass_ak8963.h"
Include dependency graph for compass_ak8963.c:

Macros

#define AK8963_I2C_INSTANCE   I2C_DEVICE
 
#define AK8963_MAG_I2C_ADDRESS   0x0C
 
#define AK8963_Device_ID   0x48
 
#define AK8963_MAG_REG_WHO_AM_I   0x00
 
#define AK8963_MAG_REG_INFO   0x01
 
#define AK8963_MAG_REG_STATUS1   0x02
 
#define AK8963_MAG_REG_HXL   0x03
 
#define AK8963_MAG_REG_HXH   0x04
 
#define AK8963_MAG_REG_HYL   0x05
 
#define AK8963_MAG_REG_HYH   0x06
 
#define AK8963_MAG_REG_HZL   0x07
 
#define AK8963_MAG_REG_HZH   0x08
 
#define AK8963_MAG_REG_STATUS2   0x09
 
#define AK8963_MAG_REG_CNTL   0x0a
 
#define AK8963_MAG_REG_ASCT   0x0c
 
#define AK8963_MAG_REG_ASAX   0x10
 
#define AK8963_MAG_REG_ASAY   0x11
 
#define AK8963_MAG_REG_ASAZ   0x12
 
#define READ_FLAG   0x80
 
#define STATUS1_DATA_READY   0x01
 
#define STATUS1_DATA_OVERRUN   0x02
 
#define STATUS2_DATA_ERROR   0x02
 
#define STATUS2_MAG_SENSOR_OVERFLOW   0x03
 
#define CNTL_MODE_POWER_DOWN   0x00
 
#define CNTL_MODE_ONCE   0x01
 
#define CNTL_MODE_CONT1   0x02
 
#define CNTL_MODE_CONT2   0x06
 
#define CNTL_MODE_SELF_TEST   0x08
 
#define CNTL_MODE_FUSE_ROM   0x0F
 

Functions

bool ak8963Detect (mag_t *mag)
 
void ak8963Init (void)
 
bool ak8963Read (int16_t *magData)
 

Macro Definition Documentation

#define AK8963_Device_ID   0x48
#define AK8963_I2C_INSTANCE   I2C_DEVICE
#define AK8963_MAG_I2C_ADDRESS   0x0C
#define AK8963_MAG_REG_ASAX   0x10
#define AK8963_MAG_REG_ASAY   0x11
#define AK8963_MAG_REG_ASAZ   0x12
#define AK8963_MAG_REG_ASCT   0x0c
#define AK8963_MAG_REG_CNTL   0x0a
#define AK8963_MAG_REG_HXH   0x04
#define AK8963_MAG_REG_HXL   0x03
#define AK8963_MAG_REG_HYH   0x06
#define AK8963_MAG_REG_HYL   0x05
#define AK8963_MAG_REG_HZH   0x08
#define AK8963_MAG_REG_HZL   0x07
#define AK8963_MAG_REG_INFO   0x01
#define AK8963_MAG_REG_STATUS1   0x02
#define AK8963_MAG_REG_STATUS2   0x09
#define AK8963_MAG_REG_WHO_AM_I   0x00
#define CNTL_MODE_CONT1   0x02
#define CNTL_MODE_CONT2   0x06
#define CNTL_MODE_FUSE_ROM   0x0F
#define CNTL_MODE_ONCE   0x01
#define CNTL_MODE_POWER_DOWN   0x00
#define CNTL_MODE_SELF_TEST   0x08
#define READ_FLAG   0x80
#define STATUS1_DATA_OVERRUN   0x02
#define STATUS1_DATA_READY   0x01
#define STATUS2_DATA_ERROR   0x02
#define STATUS2_MAG_SENSOR_OVERFLOW   0x03

Function Documentation

bool ak8963Detect ( mag_t mag)

Here is the call graph for this function:

void ak8963Init ( void  )

Here is the call graph for this function:

bool ak8963Read ( int16_t *  magData)