bmi160

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2021 License: BSD-3-Clause Imports: 3 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DeviceSPI

type DeviceSPI struct {
	// Chip select pin
	CSB machine.Pin

	// SPI bus (requires chip select to be usable).
	Bus drivers.SPI
	// contains filtered or unexported fields
}

DeviceSPI is the SPI interface to a BMI160 accelerometer/gyroscope. There is also an I2C interface, but it is not yet supported.

func NewSPI

func NewSPI(csb machine.Pin, spi drivers.SPI) *DeviceSPI

NewSPI returns a new device driver. The pin and SPI interface are not touched, provide a fully configured SPI object and call Configure to start using this device.

func (*DeviceSPI) Configure

func (d *DeviceSPI) Configure() error

Configure configures the BMI160 for use. It configures the CSB pin and configures the BMI160, but it does not configure the SPI interface (it is assumed to be up and running).

func (*DeviceSPI) Connected

func (d *DeviceSPI) Connected() bool

Connected check whether the device appears to be properly connected. It reads the CHIPID, which must be 0xD1 for the BMI160.

func (*DeviceSPI) ReadAcceleration

func (d *DeviceSPI) ReadAcceleration() (x int32, y int32, z int32, err error)

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 (*DeviceSPI) ReadRotation

func (d *DeviceSPI) ReadRotation() (x int32, y int32, z int32, err error)

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 (*DeviceSPI) ReadTemperature

func (d *DeviceSPI) ReadTemperature() (temperature int32, err error)

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

func (*DeviceSPI) Reset

func (d *DeviceSPI) Reset() error

Reset restores the device to the state after power up. This can be useful to easily disable the accelerometer and gyroscope to reduce current consumption.

Jump to

Keyboard shortcuts

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