upm  0.4.1
Sensor/Actuator repository for libmraa (v0.8.0)
Classes | Public Member Functions | List of all members

API for the MPU60X0 3-axis Gyroscope and 3-axis Accelerometer. More...

Detailed Description

The MPU60X0 devices provide the world’s first integrated 6-axis motion processor solution that eliminates the package-level gyroscope and accelerometer cross-axis misalignment associated with discrete solutions. The devices combine a 3-axis gyroscope and a 3-axis accelerometer on the same silicon die.

While not all of the functionality of this device is supported initially, methods and register definitions are provided that should allow an end user to implement whatever features are required.

Classes

class  ACCEL_CONFIG_BITS_T
 
class  ACCEL_ON_DELAY_T
 
class  AFS_SEL_T
 
class  CLKSEL_T
 
class  CONFIG_BITS_T
 
class  DLPF_CFG_T
 
class  EXT_SYNC_SET_T
 
class  FIFO_EN_BITS_T
 
class  FS_SEL_T
 
class  GRYO_CONFIG_BITS_T
 
class  I2C_MST_CLK_T
 
class  I2C_MST_CTRL_BITS_T
 
class  I2C_MST_STATUS_BITS_T
 
class  I2C_SLV4_CTRL_BITS_T
 
class  I2C_SLV_ADDR_BITS_T
 
class  I2C_SLV_CTRL_BITS_T
 
class  INT_ENABLE_BITS_T
 
class  INT_PIN_CFG_BITS_T
 
class  INT_STATUS_BITS_T
 
class  LP_WAKE_CRTL_T
 
class  MOT_DETECT_CTRL_BITS_T
 
class  MOT_DETECT_STATUS_BITS_T
 
class  MOT_FF_COUNT_T
 
class  MPU60X0_REG_T
 
class  MST_DELAY_CTRL_BITS_T
 
class  PWR_MGMT_1_BITS_T
 
class  PWR_MGMT_2_BITS_T
 
class  SIGNAL_PATH_RESET_BITS_T
 
class  USER_CTRL_BITS_T
 

Public Member Functions

synchronized void delete ()
 
 MPU60X0 (int bus, short address)
 
 MPU60X0 (int bus)
 
boolean init ()
 
void update ()
 
short readReg (short reg)
 
void readRegs (short reg, byte[] buffer)
 
boolean writeReg (short reg, short val)
 
boolean setSleep (boolean enable)
 
boolean setClockSource (MPU60X0.CLKSEL_T clk)
 
boolean setGyroscopeScale (MPU60X0.FS_SEL_T scale)
 
boolean setAccelerometerScale (MPU60X0.AFS_SEL_T scale)
 
boolean setDigitalLowPassFilter (MPU60X0.DLPF_CFG_T dlp)
 
boolean setSampleRateDivider (short div)
 
short getSampleRateDivider ()
 
float[] getAccelerometer ()
 
float[] getGyroscope ()
 
float getTemperature ()
 
boolean enableTemperatureSensor (boolean enable)
 
boolean setExternalSync (MPU60X0.EXT_SYNC_SET_T val)
 
boolean enableI2CBypass (boolean enable)
 
boolean setMotionDetectionThreshold (short thr)
 
short getInterruptStatus ()
 
boolean setInterruptEnables (short enables)
 
short getInterruptEnables ()
 
boolean setInterruptPinConfig (short cfg)
 
short getInterruptPinConfig ()
 
void installISR (int gpio, int level, IsrCallback cb)
 
void uninstallISR ()
 

Constructor & Destructor Documentation

MPU60X0 ( int  bus,
short  address 
)

mpu60x0 constructor

Parameters
busi2c bus to use
addressthe address for this device

Member Function Documentation

boolean enableI2CBypass ( boolean  enable)

enable I2C Bypass. Enabling this feature allows devices on the MPU60X0 auxillary I2C bus to be visible on the MCU's I2C bus.

Parameters
enabletrue to I2C bypass
Returns
true if successful, false otherwise
boolean enableTemperatureSensor ( boolean  enable)

enable onboard temperature measurement sensor

Parameters
enabletrue to enable temperature sensor, false to disable
Returns
true if successful, false otherwise
float [] getAccelerometer ( )

get the accelerometer values

Returns
Array containing X, Y, Z accelerometer values
float [] getGyroscope ( )

get the gyroscope values

Returns
Array containing X, Y, Z gyroscope values
short getInterruptEnables ( )

get the current interrupt enables register

Returns
bitmask of INT_ENABLE_BITS_T values
short getInterruptPinConfig ( )

get the current interrupt pin configuration

Returns
bitmask of INT_PIN_CFG_BITS_T values
short getInterruptStatus ( )

return the interrupt status register.

Returns
the interrupt status word (see INT_STATUS_BITS_T)
short getSampleRateDivider ( )

get the current Sample Rate divider

Returns
the current sample rate divider
float getTemperature ( )

get the temperature value

Returns
the temperature value in degrees Celcius
boolean init ( )

set up initial values and start operation

Returns
true if successful
void installISR ( int  gpio,
int  level,
IsrCallback  cb 
)

install an interrupt handler.

Parameters
gpiogpio pin to use as interrupt pin
levelthe interrupt trigger level (one of mraa::Edge values). Make sure that you have configured the interrupt pin (setInterruptPinConfig()) properly for whatever level you choose.
isrthe interrupt handler, accepting a void * argument
argthe argument to pass the the interrupt handler
short readReg ( short  reg)

read a register

Parameters
regthe register to read
Returns
the value of the register
boolean setAccelerometerScale ( MPU60X0.AFS_SEL_T  scale)

set the scaling mode of the accelerometer

Parameters
scaleone of the AFS_SEL_T values
Returns
true if successful, false otherwise
boolean setClockSource ( MPU60X0.CLKSEL_T  clk)

specify the clock source for the device to use

Parameters
clkone of the CLKSEL_T values
Returns
true if successful, false otherwise
boolean setDigitalLowPassFilter ( MPU60X0.DLPF_CFG_T  dlp)

set the Low Pass Digital filter. This enables filtering (if non-0) of the accelerometer and gyro outputs.

Parameters
scaleone of the DLPF_CFG_T values
Returns
true if successful, false otherwise
boolean setExternalSync ( MPU60X0.EXT_SYNC_SET_T  val)

configure external sync. An external signal connected to the FSYNC pin can be sampled by configuring EXT_SYNC_SET. Signal changes to the FSYNC pin are latched so that short strobes may be captured. The latched FSYNC signal will be sampled at the Sampling Rate, as defined in register 25. After sampling, the latch will reset to the current FSYNC signal state.

The sampled value will be reported in place of the least significant bit in a sensor data register determined by the value of EXT_SYNC_SET

Parameters
valone of the EXT_SYNC_SET_T values
Returns
true if successful, false otherwise
boolean setGyroscopeScale ( MPU60X0.FS_SEL_T  scale)

set the scaling mode of the gyroscope

Parameters
scaleone of the FS_SEL_T values
Returns
true if successful, false otherwise
boolean setInterruptEnables ( short  enables)

set the interrupt enables

Parameters
enablesbitmask of INT_ENABLE_BITS_T values to enable
Returns
true if successful, false otherwise
boolean setInterruptPinConfig ( short  cfg)

set the interrupt pin configuration

Parameters
cfgbitmask of INT_PIN_CFG_BITS_T values
Returns
true if successful, false otherwise
boolean setMotionDetectionThreshold ( short  thr)

set the motion detection threshold for interrupt generation. Motion is detected when the absolute value of any of the accelerometer measurements exceeds this Motion detection threshold.

Parameters
thrthreshold
Returns
true if successful, false otherwise
boolean setSampleRateDivider ( short  div)

set the sample rate divider. This register specifies the divider from the gyro output rate used to generate the Sample Rate. The sensor registor output, FIFO output, DMP sampling and motion detection are all based on the Sample Rate.

The Sample Rate is generated by dividing the gyro output rate by this register:

Sample Rate = Gyro output rate / (1 + sample rate divider).

The Gyro output rate is 8Khz when the Digital Low Pass Filter (DLPF) is 0 or 7 (DLPF_260_256 or DLPF_RESERVED), and 1Khz otherwise.

Parameters
scaleone of the DLPF_CFG_T values
Returns
true if successful, false otherwise
boolean setSleep ( boolean  enable)

enable or disable device sleep

Parameters
enabletrue to put device to sleep, false to wake up
Returns
true if successful, false otherwise
void uninstallISR ( )

uninstall a previously installed interrupt handler

void update ( )

take a measurement and store the current sensor values internally. Note, these user facing registers are only updated from the internal device sensor values when the i2c serial traffic is 'idle'. So, if you are reading the values too fast, the bus may never be idle, and you will just end up reading the same values over and over.

Unfortunately, it is is not clear how long 'idle' actually means, so if you see this behavior, reduce the rate at which you are calling update().

boolean writeReg ( short  reg,
short  val 
)

write to a register

Parameters
regthe register to write to
valthe value to write
Returns
true if successful, false otherwise
Inheritance diagram for MPU60X0:
Inheritance graph
[legend]

The documentation for this class was generated from the following file: