Atmel Software Framework

ak8975.h File Reference

AKM AK8975 3-axis magnetometer.

This file contains functions for initializing and reading data from a AKM AK8975 3-axis magnetometer.

Copyright (c) 2012 Atmel Corporation. All rights reserved.

#include <asf.h>

Macros

#define AK8975_DATA_RESOLUTION   (13)
 Signed axis data sample resolution (bits) More...
 
#define AK8975_REG_ASAX   (0x10) /* x-axis sensitivity adjust */
 
#define AK8975_REG_ASAY   (0x11) /* y-axis sensitivity adjust */
 
#define AK8975_REG_ASAZ   (0x12) /* z-axis sensitivity adjust */
 
#define AK8975_TWI_ADDR   (0x0c) /* TWI/I2C slave address */
 
#define MICRO_TESLA_PER_COUNT   (0.3) /* from AK8975 data sheet */
 Device sensitivity (scaling) More...
 
#define AK8975_TEST_X_MIN   (-100) /* min X */
 Self-test Definitions. More...
 
#define AK8975_TEST_X_MAX   (100) /* max X */
 
#define AK8975_TEST_Y_MIN   (-100) /* min Y */
 
#define AK8975_TEST_Y_MAX   (100) /* max Y */
 
#define AK8975_TEST_Z_MIN   (-1000) /* min Z */
 
#define AK8975_TEST_Z_MAX   (-300) /* max Z */
 
#define AK8975_REG_WIA   (0x00) /* device ID */
 AK8975 Register Addresses. More...
 
#define AK8975_REG_INFO   (0x01) /* information */
 
#define AK8975_REG_ST1   (0x02) /* data status 1 */
 
#define AK8975_REG_HXL   (0x03) /* x-axis data (low) */
 
#define AK8975_REG_HXH   (0x04) /* x-axis data (high) */
 
#define AK8975_REG_HYL   (0x05) /* y-axis data (low) */
 
#define AK8975_REG_HYH   (0x06) /* y-axis data (high) */
 
#define AK8975_REG_HZL   (0x07) /* z-axis data (low) */
 
#define AK8975_REG_HZH   (0x08) /* z-axis data (high) */
 
#define AK8975_REG_ST2   (0x09) /* data status 2 */
 
#define AK8975_REG_CNTL1   (0x0a) /* control 1 */
 
#define AK8975_REG_CNTL2   (0x0b) /* reserved (do not access) */
 
#define AK8975_REG_ASTC   (0x0c) /* self-test */
 
#define AK8975_REG_TS1   (0x0d) /* test 1 (do not access) */
 
#define AK8975_REG_TS2   (0x0e) /* test 2 (do not access) */
 
#define AK8975_REG_I2CDIS   (0x0f) /* I2C disable */
 
#define AK8975_WIA_VALUE   (0x48) /* AK8975 device ID value */
 AK8975 Register Bit Definitions. More...
 
#define AK8975_DATA_READY   (0x01) /* data ready in single mode */
 
#define AK8975_DERR   (0x04) /* data read error event */
 
#define AK8975_HOFL   (0x08) /* magnetic sensor overflow event */
 
#define AK8975_POWER_DOWN_MODE   (0x00) /* set power down mode */
 
#define AK8975_SINGLE_MODE   (0x01) /* set single measurement mode */
 
#define AK8975_SELF_TEST_MODE   (0x08) /* set self-test mode */
 
#define AK8975_FUSE_READ_MODE   (0x0f) /* set fuse ROM access mode */
 
#define AK8975_ASTC_SELF   (0x40) /* enable self-test mode */
 

Enumerations

enum  LAYOUT {
  OBVERSE_0DEG,
  OBVERSE_90DEG,
  OBVERSE_180DEG,
  OBVERSE_270DEG,
  REVERSE_0DEG,
  REVERSE_90DEG,
  REVERSE_180DEG,
  REVERSE_270DEG
}
 Sensor Layout Type Constants. More...
 

Functions

bool ak8975_init (sensor_t *, int)
 AKM AK8975 magnetometer driver initialization. More...
 

#define AK8975_ASTC_SELF   (0x40) /* enable self-test mode */

Referenced by ak8975_selftest().

#define AK8975_DATA_READY   (0x01) /* data ready in single mode */
#define AK8975_DATA_RESOLUTION   (13)

Signed axis data sample resolution (bits)

Referenced by ak8975_check_overflow(), and ak8975_init().

#define AK8975_DERR   (0x04) /* data read error event */
#define AK8975_FUSE_READ_MODE   (0x0f) /* set fuse ROM access mode */
#define AK8975_HOFL   (0x08) /* magnetic sensor overflow event */
#define AK8975_POWER_DOWN_MODE   (0x00) /* set power down mode */
#define AK8975_REG_ASAX   (0x10) /* x-axis sensitivity adjust */
#define AK8975_REG_ASAY   (0x11) /* y-axis sensitivity adjust */
#define AK8975_REG_ASAZ   (0x12) /* z-axis sensitivity adjust */
#define AK8975_REG_ASTC   (0x0c) /* self-test */

Referenced by ak8975_selftest().

#define AK8975_REG_CNTL1   (0x0a) /* control 1 */
#define AK8975_REG_CNTL2   (0x0b) /* reserved (do not access) */
#define AK8975_REG_HXH   (0x04) /* x-axis data (high) */
#define AK8975_REG_HXL   (0x03) /* x-axis data (low) */

Referenced by ak8975_get_data().

#define AK8975_REG_HYH   (0x06) /* y-axis data (high) */
#define AK8975_REG_HYL   (0x05) /* y-axis data (low) */
#define AK8975_REG_HZH   (0x08) /* z-axis data (high) */
#define AK8975_REG_HZL   (0x07) /* z-axis data (low) */
#define AK8975_REG_I2CDIS   (0x0f) /* I2C disable */
#define AK8975_REG_INFO   (0x01) /* information */
#define AK8975_REG_ST1   (0x02) /* data status 1 */
#define AK8975_REG_ST2   (0x09) /* data status 2 */
#define AK8975_REG_TS1   (0x0d) /* test 1 (do not access) */
#define AK8975_REG_TS2   (0x0e) /* test 2 (do not access) */
#define AK8975_REG_WIA   (0x00) /* device ID */

AK8975 Register Addresses.

Referenced by ak8975_device_id(), and ak8975_init().

#define AK8975_SELF_TEST_MODE   (0x08) /* set self-test mode */

Referenced by ak8975_selftest().

#define AK8975_SINGLE_MODE   (0x01) /* set single measurement mode */
#define AK8975_TEST_X_MAX   (100) /* max X */

Referenced by ak8975_selftest().

#define AK8975_TEST_X_MIN   (-100) /* min X */

Self-test Definitions.

Referenced by ak8975_selftest().

#define AK8975_TEST_Y_MAX   (100) /* max Y */

Referenced by ak8975_selftest().

#define AK8975_TEST_Y_MIN   (-100) /* min Y */

Referenced by ak8975_selftest().

#define AK8975_TEST_Z_MAX   (-300) /* max Z */

Referenced by ak8975_selftest().

#define AK8975_TEST_Z_MIN   (-1000) /* min Z */

Referenced by ak8975_selftest().

#define AK8975_TWI_ADDR   (0x0c) /* TWI/I2C slave address */
#define AK8975_WIA_VALUE   (0x48) /* AK8975 device ID value */

AK8975 Register Bit Definitions.

Referenced by ak8975_init().

#define MICRO_TESLA_PER_COUNT   (0.3) /* from AK8975 data sheet */

Device sensitivity (scaling)

Referenced by ak8975_check_overflow(), ak8975_get_field(), and ak8975_get_heading().

enum LAYOUT

Sensor Layout Type Constants.

Enumerator
OBVERSE_0DEG 

Obverse / standard position.

OBVERSE_90DEG 

Obverse / rotates counterclockwise by 90 deg.

OBVERSE_180DEG 

Obverse / rotates counterclockwise by 180 deg.

OBVERSE_270DEG 

Obverse / rotates counterclockwise by 270 deg.

REVERSE_0DEG 

Reverse / standard position.

REVERSE_90DEG 

Reverse / rotates counterclockwise by 90 deg.

REVERSE_180DEG 

Reverse / rotates counterclockwise by 180 deg.

REVERSE_270DEG 

Reverse / rotates counterclockwise by 270 deg.

bool ak8975_init ( sensor_t sensor,
int  resvd 
)

AKM AK8975 magnetometer driver initialization.

This is the main initialization function for the AK8975 device.

Parameters
sensorAddress of a sensor device descriptor.
resvdReserved value.
Returns
bool true if the call succeeds, else false is returned.