lsm6ds3

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2021 License: BSD-3-Clause Imports: 1 Imported by: 17

Documentation

Overview

Package lsm6ds3 implements a driver for the LSM6DS3 a 6 axis Inertial Measurement Unit (IMU)

Datasheet: https://www.st.com/resource/en/datasheet/lsm6ds3.pdf

Index

Constants

View Source
const (
	WHO_AM_I             = 0x0F
	STATUS               = 0x1E
	CTRL1_XL             = 0x10
	CTRL2_G              = 0x11
	CTRL3_C              = 0x12
	CTRL4_C              = 0x13
	CTRL5_C              = 0x14
	CTRL6_C              = 0x15
	CTRL7_G              = 0x16
	CTRL8_XL             = 0x17
	CTRL9_XL             = 0x18
	CTRL10_C             = 0x19
	OUTX_L_G             = 0x22
	OUTX_H_G             = 0x23
	OUTY_L_G             = 0x24
	OUTY_H_G             = 0x25
	OUTZ_L_G             = 0x26
	OUTZ_H_G             = 0x27
	OUTX_L_XL            = 0x28
	OUTX_H_XL            = 0x29
	OUTY_L_XL            = 0x2A
	OUTY_H_XL            = 0x2B
	OUTZ_L_XL            = 0x2C
	OUTZ_H_XL            = 0x2D
	OUT_TEMP_L           = 0x20
	OUT_TEMP_H           = 0x21
	BW_SCAL_ODR_DISABLED = 0x00
	BW_SCAL_ODR_ENABLED  = 0x80
	STEP_TIMESTAMP_L     = 0x49
	STEP_TIMESTAMP_H     = 0x4A
	STEP_COUNTER_L       = 0x4B
	STEP_COUNTER_H       = 0x4C
	STEP_COUNT_DELTA     = 0x15
	TAP_CFG              = 0x58
	INT1_CTRL            = 0x0D

	ACCEL_2G  AccelRange = 0x00
	ACCEL_4G  AccelRange = 0x08
	ACCEL_8G  AccelRange = 0x0C
	ACCEL_16G AccelRange = 0x04

	ACCEL_SR_OFF   AccelSampleRate = 0x00
	ACCEL_SR_13    AccelSampleRate = 0x10
	ACCEL_SR_26    AccelSampleRate = 0x20
	ACCEL_SR_52    AccelSampleRate = 0x30
	ACCEL_SR_104   AccelSampleRate = 0x40
	ACCEL_SR_208   AccelSampleRate = 0x50
	ACCEL_SR_416   AccelSampleRate = 0x60
	ACCEL_SR_833   AccelSampleRate = 0x70
	ACCEL_SR_1666  AccelSampleRate = 0x80
	ACCEL_SR_3332  AccelSampleRate = 0x90
	ACCEL_SR_6664  AccelSampleRate = 0xA0
	ACCEL_SR_13330 AccelSampleRate = 0xB0

	ACCEL_BW_50  AccelBandwidth = 0x03
	ACCEL_BW_100 AccelBandwidth = 0x02
	ACCEL_BW_200 AccelBandwidth = 0x01
	ACCEL_BW_400 AccelBandwidth = 0x00

	//GYRO_125DPS  GyroRange = 0x01
	GYRO_250DPS  GyroRange = 0x00
	GYRO_500DPS  GyroRange = 0x04
	GYRO_1000DPS GyroRange = 0x08
	GYRO_2000DPS GyroRange = 0x0C

	GYRO_SR_OFF  GyroSampleRate = 0x00
	GYRO_SR_13   GyroSampleRate = 0x10
	GYRO_SR_26   GyroSampleRate = 0x20
	GYRO_SR_52   GyroSampleRate = 0x30
	GYRO_SR_104  GyroSampleRate = 0x40
	GYRO_SR_208  GyroSampleRate = 0x50
	GYRO_SR_416  GyroSampleRate = 0x60
	GYRO_SR_833  GyroSampleRate = 0x70
	GYRO_SR_1666 GyroSampleRate = 0x80
)
View Source
const Address = 0x6A

The I2C address which this device listens to.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccelBandwidth

type AccelBandwidth uint8

type AccelRange

type AccelRange uint8

type AccelSampleRate

type AccelSampleRate uint8

type Configuration

type Configuration struct {
	AccelRange       AccelRange
	AccelSampleRate  AccelSampleRate
	AccelBandWidth   AccelBandwidth
	GyroRange        GyroRange
	GyroSampleRate   GyroSampleRate
	IsPedometer      bool
	ResetStepCounter bool
}

Configuration for LSM6DS3 device.

type Device

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

Device wraps an I2C connection to a LSM6DS3 device.

func New

func New(bus drivers.I2C) Device

New creates a new LSM6DS3 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(cfg Configuration)

Configure sets up the device for communication.

func (*Device) Connected

func (d *Device) Connected() bool

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

func (*Device) ReadAcceleration

func (d *Device) ReadAcceleration() (x int32, y int32, z int32)

ReadAcceleration reads the current acceleration from the device and returns it in µg (micro-gravity). When one of the axes is pointing straight to Earth and the sensor is not moving the returned value will be around 1000000 or -1000000.

func (*Device) ReadRotation

func (d *Device) ReadRotation() (x int32, y int32, z int32)

ReadRotation reads the current rotation from the device and returns it in µ°/s (micro-degrees/sec). This means that if you were to do a complete rotation along one axis and while doing so integrate all values over time, you would get a value close to 360000000.

func (*Device) ReadSteps

func (d *Device) ReadSteps() int32

ReadSteps returns the steps of the pedometer

func (*Device) ReadTemperature

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

ReadTemperature returns the temperature in celsius milli degrees (°C/1000)

type GyroRange

type GyroRange uint8

type GyroSampleRate

type GyroSampleRate uint8

Jump to

Keyboard shortcuts

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