mag3110

package
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 7, 2020 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Overview

Package mag3110 implements a driver for the MAG3110 3-axis magnetometer by Freescale/NXP.

Datasheet: https://www.nxp.com/docs/en/data-sheet/MAG3110.pdf

Index

Constants

View Source
const (
	DR_STATUS = 0x00 // Data ready status per axis
	OUT_X_MSB = 0x01 // Bits [15:8] of X measurement
	OUT_X_LSB = 0x02 // Bits [7:0] of X measurement
	OUT_Y_MSB = 0x03 // Bits [15:8] of Y measurement
	OUT_Y_LSB = 0x04 // Bits [7:0] of Y measurement
	OUT_Z_MSB = 0x05 // Bits [15:8] of Z measurement
	OUT_Z_LSB = 0x06 // Bits [7:0] of Z measurement
	WHO_AM_I  = 0x07 // Device ID Number
	SYSMOD    = 0x08 // Current System Mode
	OFF_X_MSB = 0x09 // Bits [14:7] of user X offset
	OFF_X_LSB = 0x0A // Bits [6:0] of user X offset
	OFF_Y_MSB = 0x0B // Bits [14:7] of user Y offset
	OFF_Y_LSB = 0x0C // Bits [6:0] of user Y offset
	OFF_Z_MSB = 0x0D // Bits [14:7] of user Z offset
	OFF_Z_LSB = 0x0E // Bits [6:0] of user Z offset
	DIE_TEMP  = 0x0F // Temperature, signed 8 bits in °C
	CTRL_REG1 = 0x10 // Operation modes
	CTRL_REG2 = 0x11 // Operation modes
)

Registers. Names, addresses and comments are copied from the datasheet.

View Source
const Address = 0x0E

The I2C address which this device listens to.

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device struct {
	Address uint16
	// contains filtered or unexported fields
}

Device wraps an I2C connection to a MAG3110 device.

func New

func New(bus machine.I2C) Device

New creates a new MAG3110 connection. The I2C bus must already be configured.

This function only creates the Device object, it does not touch the device.

func (Device) Configure

func (d Device) Configure()

Configure sets up the device for communication.

func (Device) Connected

func (d Device) Connected() bool

Connected returns whether a MAG3110 has been found. It does a "who am I" request and checks the response.

func (Device) ReadMagnetic

func (d Device) ReadMagnetic() (x int16, y int16, z int16)

ReadMagnetic reads the vectors of the magnetic field of the device and returns it.

func (Device) ReadTemperature

func (d Device) ReadTemperature() (int32, error)

ReadTemperature reads and returns the current die temperature in celsius milli degrees (°C/1000).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL