您好,欢迎来到华佗健康网。
搜索
您的当前位置:首页MPU6050 DMP官方使用手册

MPU6050 DMP官方使用手册

来源:华佗健康网
InvenSenseInc.

1197BorregasAve.,Sunnyvale,CA940U.S.A.Tel:+1(408)988-7339Fax:+1(408)988-8104

Website:www.invensense.com

Doc:SW-EMD-REL-5.1.1DocRev:1.0Date:12/14/2012

EmbeddedMotionDriverv5.1.1

APIsSpecification

A printed copy of this document is NOT UNDER REVISION CONTROLunless it is dated and stamped in red ink as,

“REVISION CONTROLLED COPY.”

This information furnished by InvenSense is believed to be accurate and reliable. However, no responsibility is assumed by InvenSense for its use, or for any infringements or patents or other rights of third parties that may result from its use. Specifications are subject to change without notice. Certain intellectual property owned by InvenSense and described in this document is patent protected. No license is granted by Implication or otherwise under any patent or patent rights of InvenSense. This isan unpublished work protected under the United States copyright laws. This work contains proprietary and confidential information of InvenSense Inc. Use, disclosure or reproduction without the express written authorization of InvenSense Inc. is prohibited.Trademarks that are registered trademarks are the property of their respective companies.

This publication supersedes and replaces all information previously supplied. InvenSense sensors should not be used or sold for the development, storing, production and utilization of any conventional or mass-destructive weapons or any other weapons or life threatening applications, as well as to be used in any other life critical applications such as medical, transportation, aerospace, nuclear, undersea, power, disaster and crime prevention equipment.

Copyright ©2010InvenSense Corporation.

CONFIDENTIAL&PROPRIETARYwww.invensense.com

eMDv5.1.1APIsSpecification

Doc:SW-EMD-REL-5.1.1DocRev:1.0Date:12/14/2012

CONFIDENTIAL&PROPRIETARYwww.invensense.com

eMDv5.1.1APIsSpecification

Doc:SW-EMD-REL-5.1.1DocRev:1.0Date:12/14/2012

Chapter1

PurposeandScope

ThisdocumentisaguidetoallofthefunctionsavailableintheInvenSenseEmbeddedMotionDriver(eMD),and

correspondswithEmbeddedMotionDriverReleasev5.1.1.

TheeMDcontainsthecodeforconfiguringtheInvenSensedevicesandusingtheDMPhardwarefeatures.AllofthesourcecodeisinANSICandcanbecompiledinCorC++environments.

AllfunctionsavailableintheeMDaredescribedinthisdocument,includingallparametersinvolvedinthefunctioncalls.

Formoreinformationonhowtousethesefunctionsinaspecificapplication,refertoInvenSenseApplicationNotes.

CONFIDENTIAL&PROPRIETARYwww.invensense.com

eMDv5.1.1APIsSpecification

Doc:SW-EMD-REL-5.1.1DocRev:1.0Date:12/14/2012

Chapter2

Aboutthisdocument

AThisdocumentisautomaticallygeneratedfromthesourcefilesusingDoxygen’soutputformatintheLTEX.Heading,

footer,andgeneraldocumentformatarecustomizedfromthestandardheadertemplateprovidedbyDoxygen.Thedocumentissubdividedinthevarioussections,eachdescribingthemainsourceModulescomposingtheeMDandimplementingspecificfeatures.

Everysectionstartswithabriefdescriptionandanoverviewofthefunctionscomposingthemodule.Eachofthosefunctionsisalsofullydocumentedintheanalogous\"FunctionDocumentation\"section.Clickingonthefunctionprototypewillleadtotheportionoftextfulldocumentatingit.

ThisEmbeddedMotionDriverFunctionalSpecificationisbestviewedinaPDFviewer,asitprovidestexthyper-linksandbookmarksontheleft-handsideforeaseofbrowsing.ThereisanAlphabeticalIndexofthemodulesandtheirfunctionsavailableatthebottomofthisdocument.

CONFIDENTIAL&PROPRIETARYwww.invensense.com

eMDv5.1.1APIsSpecification

Doc:SW-EMD-REL-5.1.1DocRev:1.0Date:12/14/2012

Chapter3

ModuleIndex

3.1

Modules

Hereisalistofallmodules:

SensorDriverLayer...............................

CONFIDENTIAL&PROPRIETARY3

www.invensense.com

eMDv5.1.1APIsSpecification

Doc:SW-EMD-REL-5.1.1DocRev:1.0Date:12/14/2012

2ModuleIndex

GeneratedonFriDec1411:17:092012forMotionDriverbyDoxygen

CONFIDENTIAL&PROPRIETARYwww.invensense.com

eMDv5.1.1APIsSpecification

Doc:SW-EMD-REL-5.1.1DocRev:1.0Date:12/14/2012

Chapter4

ModuleDocumentation

4.1

SensorDriverLayer

HardwaredriverstocommunicatewithsensorsviaI2C.

Files

•fileinv_mpu.c

AnI2C-baseddriverforInvensensegyroscopes.

•fileinv_mpu_dmp_android.c

DMPimageandinterfacefunctions.

Functions

•intdmp_enable_6x_lp_quat(unsignedcharenable)

Generate6-axisquaternionsfromtheDMP.

•intdmp_enable_feature(unsignedshortmask)

EnableDMPfeatures.

•intdmp_enable_gyro_cal(unsignedcharenable)

CalibratethegyrodataintheDMP.

•intdmp_enable_lp_quat(unsignedcharenable)

Generate3-axisquaternionsfromtheDMP.

CONFIDENTIAL&PROPRIETARYwww.invensense.com

eMDv5.1.1APIsSpecification

Doc:SW-EMD-REL-5.1.1DocRev:1.0Date:12/14/2012

4ModuleDocumentation

•intdmp_enable_no_motion_detection(unsignedcharenable)

Detectaccel-basednomotionevents.

•intdmp_get_fifo_rate(unsignedshort∗rate)

GetDMPoutputrate.

•intdmp_get_pedometer_step_count(unsignedlong∗count)

Getcurrentstepcount.

•intdmp_get_pedometer_walk_time(unsignedlong∗time)

Getdurationofwalkingtime.

•intdmp_load_android_firmware(void)

LoadtheDMPwiththisimage.

•intdmp_read_fifo(short∗gyro,short∗accel,long∗quat,unsignedlong

∗timestamp,short∗sensors,unsignedchar∗more)

GetonepacketfromtheFIFO.

•intdmp_register_android_orient_cb(void(∗func)(unsignedchar))

Registerafunctiontobeexecutedonaandroidorientationevent.

•intdmp_register_no_motion_cb(void(∗func)(void))

Registerafunctiontobeexecutedonanomotionevent.

•intdmp_register_tap_cb(void(∗func)(unsignedchar,unsignedchar))

Registerafunctiontobeexecutedonatapevent.

•intdmp_set_accel_bias(long∗bias)

PushaccelbiasestotheDMP.

•intdmp_set_fifo_rate(unsignedshortrate)

SetDMPoutputrate.

•intdmp_set_gyro_bias(long∗bias)

PushgyrobiasestotheDMP.

•intdmp_set_interrupt_mode(unsignedcharmode)

SpecifywhenaDMPinterruptshouldoccur.

•intdmp_set_no_motion_thresh(unsignedlongthresh_mg)

GeneratedonFriDec1411:17:092012forMotionDriverbyDoxygen

CONFIDENTIAL&PROPRIETARYwww.invensense.com

eMDv5.1.1APIsSpecification

Doc:SW-EMD-REL-5.1.1DocRev:1.0Date:12/14/2012

4.1SensorDriverLayer

5

Setnomotionthreshold.

•intdmp_set_no_motion_time(unsignedshorttime_ms)

Setnomotiondelay.

•intdmp_set_orientation(unsignedshortorient)

PushgyroandaccelorientationtotheDMP.

•intdmp_set_pedometer_step_count(unsignedlongcount)

Overwritecurrentstepcount.

•intdmp_set_pedometer_walk_time(unsignedlongtime)

Overwritecurrentwalktime.

•intdmp_set_shake_reject_thresh(longsf,unsignedshortthresh)

Setshakerejectionthreshold.

•intdmp_set_shake_reject_time(unsignedshorttime)

Setshakerejectiontime.

•intdmp_set_shake_reject_timeout(unsignedshorttime)

Setshakerejectiontimeout.

•intdmp_set_tap_axes(unsignedcharaxis)

Setwhichaxeswillregisteratap.

•intdmp_set_tap_count(unsignedcharmin_taps)

Setminimumnumberoftapsneededforaninterrupt.

•intdmp_set_tap_thresh(unsignedcharaxis,unsignedshortthresh)

Settapthresholdforaspecificaxis.

•intdmp_set_tap_time(unsignedshorttime)

Setlengthbetweenvalidtaps.

•intdmp_set_tap_time_multi(unsignedshorttime)

Setmaxtimebetweentapstoregisterasamulti-tap.

•intmpu_configure_fifo(unsignedcharsensors)

SelectwhichsensorsarepushedtoFIFO.

•intmpu_get_accel_fsr(unsignedchar∗fsr)

GeneratedonFriDec1411:17:092012forMotionDriverbyDoxygen

CONFIDENTIAL&PROPRIETARYwww.invensense.com

eMDv5.1.1APIsSpecification

Doc:SW-EMD-REL-5.1.1DocRev:1.0Date:12/14/2012

6

Gettheaccelfull-scalerange.

ModuleDocumentation

•intmpu_get_accel_reg(short∗data,unsignedlong∗timestamp)

Readrawacceldatadirectlyfromtheregisters.

•intmpu_get_accel_sens(unsignedshort∗sens)

Getaccelsensitivityscalefactor.

•intmpu_get_compass_fsr(unsignedshort∗fsr)

Getthecompassfull-scalerange.

•intmpu_get_compass_reg(short∗data,unsignedlong∗timestamp)

Readrawcompassdata.

•intmpu_get_compass_sample_rate(unsignedshort∗rate)

Getcompasssamplingrate.

•intmpu_get_dmp_state(unsignedchar∗enabled)

GetDMPstate.

•intmpu_get_fifo_config(unsignedchar∗sensors)

GetcurrentFIFOconfiguration.

•intmpu_get_gyro_fsr(unsignedshort∗fsr)

Getthegyrofull-scalerange.

•intmpu_get_gyro_reg(short∗data,unsignedlong∗timestamp)

Readrawgyrodatadirectlyfromtheregisters.

•intmpu_get_gyro_sens(float∗sens)

Getgyrosensitivityscalefactor.

•intmpu_get_int_status(short∗status)

ReadtheMPUinterruptstatusregisters.

•intmpu_get_lpf(unsignedshort∗lpf)

GetthecurrentDLPFsetting.

•intmpu_get_power_state(unsignedchar∗power_on)

Getcurrentpowerstate.

•intmpu_get_sample_rate(unsignedshort∗rate)

GeneratedonFriDec1411:17:092012forMotionDriverbyDoxygen

CONFIDENTIAL&PROPRIETARYwww.invensense.com

eMDv5.1.1APIsSpecification

Doc:SW-EMD-REL-5.1.1DocRev:1.0Date:12/14/2012

4.1SensorDriverLayer

7

Getsamplingrate.

•intmpu_get_temperature(long∗data,unsignedlong∗timestamp)

Readtemperaturedatadirectlyfromtheregisters.

•intmpu_init(structint_param_s∗int_param)

Initializehardware.

•intmpu_load_firmware(unsignedshortlength,constunsignedchar∗firmware,

unsignedshortstart_addr,unsignedshortsample_rate)

LoadandverifyDMPimage.

•intmpu_lp_accel_mode(unsignedcharrate)

Enterlow-poweraccel-onlymode.

•intmpu_lp_motion_interrupt(unsignedshortthresh,unsignedchartime,un-signedcharlpa_freq)

EntersLPaccelmotioninterruptmode.

•intmpu_read_fifo(short∗gyro,short∗accel,unsignedlong∗timestamp,un-signedchar∗sensors,unsignedchar∗more)

GetonepacketfromtheFIFO.

•intmpu_read_fifo_stream(unsignedshortlength,unsignedchar∗data,unsignedchar∗more)

GetoneunparsedpacketfromtheFIFO.

•intmpu_read_mem(unsignedshortmem_addr,unsignedshortlength,unsignedchar∗data)

ReadfromtheDMPmemory.

•intmpu_read_reg(unsignedcharreg,unsignedchar∗data)

Readfromasingleregister.

•intmpu_reg_dump(void)

Registerdumpfortesting.

•intmpu_reset_fifo(void)

ResetFIFOread/writepointers.

•intmpu_run_self_test(long∗gyro,long∗accel)

Triggergyro/accel/compassself-test.

GeneratedonFriDec1411:17:092012forMotionDriverbyDoxygen

CONFIDENTIAL&PROPRIETARYwww.invensense.com

eMDv5.1.1APIsSpecification

Doc:SW-EMD-REL-5.1.1DocRev:1.0Date:12/14/2012

8

•intmpu_set_accel_bias(constlong∗accel_bias)

Pushbiasestotheaccelbiasregisters.

ModuleDocumentation

•intmpu_set_accel_fsr(unsignedcharfsr)

Settheaccelfull-scalerange.

•intmpu_set_bypass(unsignedcharbypass_on)

Setdevicetobypassmode.

•intmpu_set_compass_sample_rate(unsignedshortrate)

Setcompasssamplingrate.

•intmpu_set_dmp_state(unsignedcharenable)

Enable/disableDMPsupport.

•intmpu_set_gyro_fsr(unsignedshortfsr)

Setthegyrofull-scalerange.

•intmpu_set_int_latched(unsignedcharenable)

Enablelatchedinterrupts.

•intmpu_set_int_level(unsignedcharactive_low)

Setinterruptlevel.

•intmpu_set_lpf(unsignedshortlpf)

Setdigitallowpassfilter.

•intmpu_set_sample_rate(unsignedshortrate)

Setsamplingrate.

•intmpu_set_sensors(unsignedcharsensors)

Turnspecificsensorson/off.

•intmpu_write_mem(unsignedshortmem_addr,unsignedshortlength,unsigned

char∗data)

WritetotheDMPmemory.

4.1.1DetailedDescription

HardwaredriverstocommunicatewithsensorsviaI2C.

GeneratedonFriDec1411:17:092012forMotionDriverbyDoxygen

CONFIDENTIAL&PROPRIETARYwww.invensense.com

eMDv5.1.1APIsSpecification

Doc:SW-EMD-REL-5.1.1DocRev:1.0Date:12/14/2012

4.1SensorDriverLayer9

4.1.2FunctionDocumentation

4.1.2.1

intdmp_enable_6x_lp_quat(unsignedcharenable)

Generate6-axisquaternionsfromtheDMP.

Inthisdriver,the3-axisand6-axisDMPquaternionfeaturesaremutuallyexclusive.Parameters:

enable1toenable6-axisquaternion.Returns:

0ifsuccessful.

4.1.2.2intdmp_enable_feature(unsignedshortmask)

EnableDMPfeatures.

Thefollowing#define’sareusedintheinputmask:DMP_FEATURE_TAP

DMP_FEATURE_ANDROID_ORIENTDMP_FEATURE_LP_QUATDMP_FEATURE_6X_LP_QUATDMP_FEATURE_GYRO_CALDMP_FEATURE_SEND_RAW_ACCELDMP_FEATURE_SEND_RAW_GYRO

NOTE:DMP_FEATURE_LP_QUATandDMP_FEATURE_6X_LP_QUATaremutu-allyexclusive.

NOTE:DMP_FEATURE_SEND_RAW_GYROandDMP_FEATURE_SEND_-CAL_GYROarealsomutuallyexclusive.Parameters:

maskMaskoffeaturestoenable.Returns:

0ifsuccessful.

GeneratedonFriDec1411:17:092012forMotionDriverbyDoxygen

CONFIDENTIAL&PROPRIETARYwww.invensense.com

eMDv5.1.1APIsSpecification

Doc:SW-EMD-REL-5.1.1DocRev:1.0Date:12/14/2012

104.1.2.3

ModuleDocumentation

intdmp_enable_gyro_cal(unsignedcharenable)

CalibratethegyrodataintheDMP.

Aftereightsecondsofnomotion,theDMPwillcomputegyrobiasesandsubtractthem

fromthequaternionoutput.Ifdmp_enable_featureiscalledwithDMP_FEATURE_-SEND_CAL_GYRO,thebiaseswillalsobesubtractedfromthegyrooutput.Parameters:

enable1toenablegyrocalibration.Returns:

0ifsuccessful.

4.1.2.4intdmp_enable_lp_quat(unsignedcharenable)

Generate3-axisquaternionsfromtheDMP.

Inthisdriver,the3-axisand6-axisDMPquaternionfeaturesaremutuallyexclusive.Parameters:

enable1toenable3-axisquaternion.Returns:

0ifsuccessful.

4.1.2.5intdmp_enable_no_motion_detection(unsignedcharenable)

Detectaccel-basednomotionevents.Parameters:

enable1toenableaccel-basednomotiondetection.Returns:

0ifsuccessful.

4.1.2.6intdmp_get_fifo_rate(unsignedshort∗rate)

GetDMPoutputrate.

GeneratedonFriDec1411:17:092012forMotionDriverbyDoxygen

CONFIDENTIAL&PROPRIETARYwww.invensense.com

eMDv5.1.1APIsSpecification

Doc:SW-EMD-REL-5.1.1DocRev:1.0Date:12/14/2012

4.1SensorDriverLayer11

Parameters:

rateCurrentfiforate(Hz).Returns:

0ifsuccessful.

4.1.2.7intdmp_get_pedometer_step_count(unsignedlong∗count)

Getcurrentstepcount.Parameters:

countNumberofstepsdetected.Returns:

0ifsuccessful.

4.1.2.8intdmp_get_pedometer_walk_time(unsignedlong∗time)

Getdurationofwalkingtime.Parameters:

timeWalktimeinmilliseconds.Returns:

0ifsuccessful.

4.1.2.9intdmp_load_android_firmware(void)

LoadtheDMPwiththisimage.Returns:

0ifsuccessful.

GeneratedonFriDec1411:17:092012forMotionDriverbyDoxygen

CONFIDENTIAL&PROPRIETARYwww.invensense.com

eMDv5.1.1APIsSpecification

Doc:SW-EMD-REL-5.1.1DocRev:1.0Date:12/14/2012

124.1.2.10

ModuleDocumentation

intdmp_read_fifo(short∗gyro,short∗accel,long∗quat,unsigned

long∗timestamp,short∗sensors,unsignedchar∗more)

GetonepacketfromtheFIFO.

Ifsensorsdoesnotcontainaparticularsensor,disregardthedatareturnedtothatpointer.

sensorscancontainacombinationofthefollowingflags:INV_X_GYRO,INV_Y_GYRO,INV_Z_GYROINV_XYZ_GYROINV_XYZ_ACCELINV_WXYZ_QUAT

IftheFIFOhasnonewdata,sensorswillbezero.

IftheFIFOisdisabled,sensorswillbezeroandthisfunctionwillreturnanon-zeroerrorcode.Parameters:

gyroGyrodatainhardwareunits.accelAcceldatainhardwareunits.

quat3-axisquaterniondatainhardwareunits.timestampTimestampinmilliseconds.sensorsMaskofsensorsreadfromFIFO.moreNumberofremainingpackets.Returns:

0ifsuccessful.

4.1.2.11intdmp_register_android_orient_cb(void(∗)(unsignedchar)func)

Registerafunctiontobeexecutedonaandroidorientationevent.Parameters:

funcCallbackfunction.Returns:

0ifsuccessful.

GeneratedonFriDec1411:17:092012forMotionDriverbyDoxygen

CONFIDENTIAL&PROPRIETARYwww.invensense.com

eMDv5.1.1APIsSpecification

Doc:SW-EMD-REL-5.1.1DocRev:1.0Date:12/14/2012

4.1SensorDriverLayer13

4.1.2.12

intdmp_register_no_motion_cb(void(∗)(void)func)

Registerafunctiontobeexecutedonanomotionevent.Parameters:

funcCallbackfunction.Returns:

0ifsuccessful.

4.1.2.13intdmp_register_tap_cb(void(∗)(unsignedchar,unsignedchar)func)

Registerafunctiontobeexecutedonatapevent.Thetapdirectionisrepresentedbyoneofthefollowing:TAP_X_UPTAP_X_DOWNTAP_Y_UPTAP_Y_DOWNTAP_Z_UPTAP_Z_DOWNParameters:

funcCallbackfunction.Returns:

0ifsuccessful.

4.1.2.14intdmp_set_accel_bias(long∗bias)

PushaccelbiasestotheDMP.

ThesebiaseswillberemovedfromtheDMP6-axisquaternion.Parameters:

biasAccelbiasesinq16.Returns:

0ifsuccessful.

GeneratedonFriDec1411:17:092012forMotionDriverbyDoxygen

CONFIDENTIAL&PROPRIETARYwww.invensense.com

eMDv5.1.1APIsSpecification

Doc:SW-EMD-REL-5.1.1DocRev:1.0Date:12/14/2012

144.1.2.15

intdmp_set_fifo_rate(unsignedshortrate)

ModuleDocumentation

SetDMPoutputrate.OnlyusedwhenDMPison.Parameters:

rateDesiredfiforate(Hz).Returns:

0ifsuccessful.

4.1.2.16intdmp_set_gyro_bias(long∗bias)

PushgyrobiasestotheDMP.

BecausethegyrointegrationishandledintheDMP,anygyrobiasescalculatedbythe

MPLshouldbepusheddowntoDMPmemorytoremove3-axisquaterniondrift.NOTE:IftheDMP-basedgyrocalibrationisenabled,theDMPwilloverwritethebiaseswrittentothislocationonceanewoneiscomputed.Parameters:

biasGyrobiasesinq16.Returns:

0ifsuccessful.

4.1.2.17intdmp_set_interrupt_mode(unsignedcharmode)

SpecifywhenaDMPinterruptshouldoccur.

ADMPinterruptcanbeconfiguredtotriggeroneitherofthetwoconditionsbelow:a.OneFIFOperiodhaselapsed(setbympu_set_sample_rate).b.Atapeventhasbeendetected.Parameters:

modeDMP_INT_GESTUREorDMP_INT_CONTINUOUS.Returns:

0ifsuccessful.

GeneratedonFriDec1411:17:092012forMotionDriverbyDoxygen

CONFIDENTIAL&PROPRIETARYwww.invensense.com

eMDv5.1.1APIsSpecification

Doc:SW-EMD-REL-5.1.1DocRev:1.0Date:12/14/2012

4.1SensorDriverLayer15

4.1.2.18

intdmp_set_no_motion_thresh(unsignedlongthresh_mg)

Setnomotionthreshold.

TheDMPdetectsnomotionwhenlinearaccelerationineachaccelaxisisbelowthis

threshold.Parameters:

thresh_mgThresholdinmilli-gs,q16.Returns:

0ifsuccessful.

4.1.2.19intdmp_set_no_motion_time(unsignedshorttime_ms)

Setnomotiondelay.

Thisfunctionsetshowlongthedevicemustbeinnomotionbeforeanomotioneventisreported.Parameters:

time_msDelayinmilliseconds.Returns:

0ifsuccessful.

4.1.2.20intdmp_set_orientation(unsignedshortorient)

PushgyroandaccelorientationtotheDMP.

Theorientationisrepresentedhereastheoutputofinv_orientation_matrix_to_-scalar.Parameters:

orientGyroandaccelorientationinbodyframe.Returns:

0ifsuccessful.

GeneratedonFriDec1411:17:092012forMotionDriverbyDoxygen

CONFIDENTIAL&PROPRIETARYwww.invensense.com

eMDv5.1.1APIsSpecification

Doc:SW-EMD-REL-5.1.1DocRev:1.0Date:12/14/2012

1.1.2.21

ModuleDocumentation

intdmp_set_pedometer_step_count(unsignedlongcount)

Overwritecurrentstepcount.

WARNING:ThisfunctionwritestoDMPmemoryandcouldpotentiallyencountera

raceconditionifcalledwhilethepedometerisenabled.Parameters:

countNewstepcount.Returns:

0ifsuccessful.

4.1.2.22intdmp_set_pedometer_walk_time(unsignedlongtime)

Overwritecurrentwalktime.

WARNING:ThisfunctionwritestoDMPmemoryandcouldpotentiallyencounteraraceconditionifcalledwhilethepedometerisenabled.Parameters:

timeNewwalktimeinmilliseconds.

4.1.2.23intdmp_set_shake_reject_thresh(longsf,unsignedshortthresh)

Setshakerejectionthreshold.

IftheDMPdetectsagyrosamplelargerthanthresh,tapsarerejected.Parameters:

sfGyroscalefactor.

threshGyrothresholdindps.Returns:

0ifsuccessful.

4.1.2.24intdmp_set_shake_reject_time(unsignedshorttime)

Setshakerejectiontime.

Setsthelengthoftimethatthegyromustbeoutsideofthethresholdsetbygyro_-set_shake_reject_threshbeforetapsarerejected.Amandatory60msisaddedtothisparameter.

GeneratedonFriDec1411:17:092012forMotionDriverbyDoxygen

CONFIDENTIAL&PROPRIETARYwww.invensense.com

eMDv5.1.1APIsSpecification

Doc:SW-EMD-REL-5.1.1DocRev:1.0Date:12/14/2012

4.1SensorDriverLayer17

Parameters:

timeTimeinmilliseconds.Returns:

0ifsuccessful.

4.1.2.25intdmp_set_shake_reject_timeout(unsignedshorttime)

Setshakerejectiontimeout.

Setsthelengthoftimeafterashakerejectionthatthegyromuststayinsideofthe

thresholdbeforetapscanbedetectedagain.Amandatory60msisaddedtothispa-rameter.Parameters:

timeTimeinmilliseconds.Returns:

0ifsuccessful.

4.1.2.26intdmp_set_tap_axes(unsignedcharaxis)

Setwhichaxeswillregisteratap.Parameters:

axis1,2,and4forXYZ,respectively.Returns:

0ifsuccessful.

4.1.2.27intdmp_set_tap_count(unsignedcharmin_taps)

Setminimumnumberoftapsneededforaninterrupt.Parameters:

min_tapsMinimumconsecutivetaps(1-4).Returns:

0ifsuccessful.

GeneratedonFriDec1411:17:092012forMotionDriverbyDoxygen

CONFIDENTIAL&PROPRIETARYwww.invensense.com

eMDv5.1.1APIsSpecification

Doc:SW-EMD-REL-5.1.1DocRev:1.0Date:12/14/2012

184.1.2.28

ModuleDocumentation

intdmp_set_tap_thresh(unsignedcharaxis,unsignedshortthresh)

Settapthresholdforaspecificaxis.Parameters:

axis1,2,and4forXYZaccel,respectively.

threshTapthreshold,inmg/ms.Returns:

0ifsuccessful.

4.1.2.29intdmp_set_tap_time(unsignedshorttime)

Setlengthbetweenvalidtaps.Parameters:

timeMillisecondsbetweentaps.Returns:

0ifsuccessful.

4.1.2.30intdmp_set_tap_time_multi(unsignedshorttime)

Setmaxtimebetweentapstoregisterasamulti-tap.Parameters:

timeMaxmillisecondsbetweentaps.Returns:

0ifsuccessful.

4.1.2.31intmpu_configure_fifo(unsignedcharsensors)

SelectwhichsensorsarepushedtoFIFO.

sensorscancontainacombinationofthefollowingflags:INV_X_GYRO,INV_Y_GYRO,INV_Z_GYROINV_XYZ_GYROINV_XYZ_ACCEL

GeneratedonFriDec1411:17:092012forMotionDriverbyDoxygen

CONFIDENTIAL&PROPRIETARYwww.invensense.com

eMDv5.1.1APIsSpecification

Doc:SW-EMD-REL-5.1.1DocRev:1.0Date:12/14/2012

4.1SensorDriverLayer19

Parameters:

sensorsMaskofsensorstopushtoFIFO.Returns:

0ifsuccessful.

4.1.2.32intmpu_get_accel_fsr(unsignedchar∗fsr)

Gettheaccelfull-scalerange.Parameters:

fsrCurrentfull-scalerange.Returns:

0ifsuccessful.

4.1.2.33intmpu_get_accel_reg(short∗data,unsignedlong∗timestamp)Readrawacceldatadirectlyfromtheregisters.Parameters:

dataRawdatainhardwareunits.

timestampTimestampinmilliseconds.Nullifnotneeded.Returns:

0ifsuccessful.

4.1.2.34intmpu_get_accel_sens(unsignedshort∗sens)Getaccelsensitivityscalefactor.Parameters:

sensConversionfromhardwareunitstog’s.Returns:

0ifsuccessful.

GeneratedonFriDec1411:17:092012forMotionDriverbyDoxygen

CONFIDENTIAL&PROPRIETARYwww.invensense.com

eMDv5.1.1APIsSpecification

Doc:SW-EMD-REL-5.1.1DocRev:1.0Date:12/14/2012

204.1.2.35

ModuleDocumentation

intmpu_get_compass_fsr(unsignedshort∗fsr)

Getthecompassfull-scalerange.Parameters:

fsrCurrentfull-scalerange.Returns:

0ifsuccessful.

4.1.2.36intmpu_get_compass_reg(short∗data,unsignedlong∗timestamp)

Readrawcompassdata.Parameters:

dataRawdatainhardwareunits.

timestampTimestampinmilliseconds.Nullifnotneeded.Returns:

0ifsuccessful.

4.1.2.37intmpu_get_compass_sample_rate(unsignedshort∗rate)

Getcompasssamplingrate.Parameters:

rateCurrentcompasssamplingrate(Hz).Returns:

0ifsuccessful.

4.1.2.38intmpu_get_dmp_state(unsignedchar∗enabled)

GetDMPstate.Parameters:

enabled1ifenabled.Returns:

0ifsuccessful.

GeneratedonFriDec1411:17:092012forMotionDriverbyDoxygen

CONFIDENTIAL&PROPRIETARYwww.invensense.com

eMDv5.1.1APIsSpecification

Doc:SW-EMD-REL-5.1.1DocRev:1.0Date:12/14/2012

4.1SensorDriverLayer21

4.1.2.39

intmpu_get_fifo_config(unsignedchar∗sensors)

GetcurrentFIFOconfiguration.

sensorscancontainacombinationofthefollowingflags:INV_X_GYRO,INV_Y_GYRO,INV_Z_GYROINV_XYZ_GYROINV_XYZ_ACCELParameters:

sensorsMaskofsensorsinFIFO.Returns:

0ifsuccessful.

4.1.2.40intmpu_get_gyro_fsr(unsignedshort∗fsr)

Getthegyrofull-scalerange.Parameters:

fsrCurrentfull-scalerange.Returns:

0ifsuccessful.

4.1.2.41intmpu_get_gyro_reg(short∗data,unsignedlong∗timestamp)

Readrawgyrodatadirectlyfromtheregisters.Parameters:

dataRawdatainhardwareunits.

timestampTimestampinmilliseconds.Nullifnotneeded.Returns:

0ifsuccessful.

GeneratedonFriDec1411:17:092012forMotionDriverbyDoxygen

CONFIDENTIAL&PROPRIETARYwww.invensense.com

eMDv5.1.1APIsSpecification

Doc:SW-EMD-REL-5.1.1DocRev:1.0Date:12/14/2012

224.1.2.42

intmpu_get_gyro_sens(float∗sens)

ModuleDocumentation

Getgyrosensitivityscalefactor.Parameters:

sensConversionfromhardwareunitstodps.Returns:

0ifsuccessful.

4.1.2.43intmpu_get_int_status(short∗status)

ReadtheMPUinterruptstatusregisters.Parameters:

statusMaskofinterruptbits.Returns:

0ifsuccessful.

4.1.2.44intmpu_get_lpf(unsignedshort∗lpf)

GetthecurrentDLPFsetting.Parameters:

lpfCurrentLPFsetting.0ifsuccessful.

4.1.2.45intmpu_get_power_state(unsignedchar∗power_on)

Getcurrentpowerstate.Parameters:

power_on1ifturnedon,0ifsuspended.Returns:

0ifsuccessful.

GeneratedonFriDec1411:17:092012forMotionDriverbyDoxygen

CONFIDENTIAL&PROPRIETARYwww.invensense.com

eMDv5.1.1APIsSpecification

Doc:SW-EMD-REL-5.1.1DocRev:1.0Date:12/14/2012

4.1SensorDriverLayer23

4.1.2.46

intmpu_get_sample_rate(unsignedshort∗rate)

Getsamplingrate.Parameters:

rateCurrentsamplingrate(Hz).Returns:

0ifsuccessful.

4.1.2.47intmpu_get_temperature(long∗data,unsignedlong∗timestamp)

Readtemperaturedatadirectlyfromtheregisters.Parameters:

dataDatainq16format.

timestampTimestampinmilliseconds.Nullifnotneeded.Returns:

0ifsuccessful.

4.1.2.48intmpu_init(structint_param_s∗int_param)Initializehardware.Initialconfiguration:GyroFSR:+/-2000DPSAccelFSR+/-2GDLPF:42HzFIFOrate:50HzClocksource:GyroPLLFIFO:Disabled.

Datareadyinterrupt:Disabled,activelow,unlatched.Parameters:

int_paramPlatform-specificparameterstointerruptAPI.Returns:

0ifsuccessful.

GeneratedonFriDec1411:17:092012forMotionDriverbyDoxygen

CONFIDENTIAL&PROPRIETARYwww.invensense.com

eMDv5.1.1APIsSpecification

Doc:SW-EMD-REL-5.1.1DocRev:1.0Date:12/14/2012

244.1.2.49

ModuleDocumentation

intmpu_load_firmware(unsignedshortlength,constunsignedchar∗

firmware,unsignedshortstart_addr,unsignedshortsample_rate)

LoadandverifyDMPimage.Parameters:

lengthLengthofDMPimage.firmwareDMPcode.

start_addrStartingaddressofDMPcodememory.

sample_rateFixedsamplingrateusedwhenDMPisenabled.Returns:

0ifsuccessful.

4.1.2.50intmpu_lp_accel_mode(unsignedcharrate)

Enterlow-poweraccel-onlymode.

Inlow-poweraccelmode,thechipgoestosleepandonlywakesuptosampletheaccelerometeratoneofthefollowingfrequencies:MPU6050:1.25Hz,5Hz,20Hz,40Hz

MPU6500:1.25Hz,2.5Hz,5Hz,10Hz,20Hz,40Hz,80Hz,160Hz,320Hz,0HzIftherequestedrateisnotonelistedabove,thedevicewillbesettothenexthighestrate.Requestingarateabovethemaximumsupportedfrequencywillresultinanerror.Toselectafractionalwake-upfrequency,rounddownthevaluepassedtorate.Parameters:

rateMinimumsamplingrate,orzerotodisableLPaccelmode.Returns:

0ifsuccessful.

4.1.2.51

intmpu_lp_motion_interrupt(unsignedshortthresh,unsignedchartime,unsignedcharlpa_freq)

EntersLPaccelmotioninterruptmode.

ThebehaviorofthisfeatureisverydifferentbetweentheMPU6050andtheMPU6500.Eachchip’sversionofthisfeatureisexplainedbelow.

GeneratedonFriDec1411:17:092012forMotionDriverbyDoxygen

CONFIDENTIAL&PROPRIETARYwww.invensense.com

eMDv5.1.1APIsSpecification

Doc:SW-EMD-REL-5.1.1DocRev:1.0Date:12/14/2012

4.1SensorDriverLayer25

MPU6050:

Whenthismodeisfirstenabled,thehardwarecapturesasingleaccelsample,and

subsequentsamplesarecomparedwiththisonetodetermineifthedeviceisinmotion.Therefore,wheneverthis\"locked\"sampleneedstobechanged,thisfunctionmustbecalledagain.

Thehardwaremotionthresholdcanbebetween32mgand8160mgin32mgincrements.Low-poweraccelmodesupportsthefollowingfrequencies:1.25Hz,5Hz,20Hz,40HzMPU6500:

UnliketheMPU6050version,thehardwaredoesnot\"lockin\"areferencesample.Thehardwaremonitorstheacceldataanddetectsanylargechangeoverashortperiodoftime.

Thehardwaremotionthresholdcanbebetween4mgand1020mgin4mgincrements.MPU6500Low-poweraccelmodesupportsthefollowingfrequencies:1.25Hz,2.5Hz,5Hz,10Hz,20Hz,40Hz,80Hz,160Hz,320Hz,0HzNOTES:

Thedriverwillrounddownthreshtothenearestsupportedvalueifanunsupportedthresholdisselected.

Toselectafractionalwake-upfrequency,rounddownthevaluepassedtolpa_freq.TheMPU6500doesnotsupportadelayparameter.IfthisfunctionisusedfortheMPU6500,thevaluepassedtotimewillbeignored.

Todisablethismode,setlpa_freqtozero.Thedriverwillrestorethepreviousconfig-uration.Parameters:

threshMotionthresholdinmg.

timeDurationinmillisecondsthattheacceldatamustexceedthreshbeforemo-tionisreported.

lpa_freqMinimumsamplingrate,orzerotodisable.Returns:

0ifsuccessful.

4.1.2.52intmpu_read_fifo(short∗gyro,short∗accel,unsignedlong∗

timestamp,unsignedchar∗sensors,unsignedchar∗more)GetonepacketfromtheFIFO.

GeneratedonFriDec1411:17:092012forMotionDriverbyDoxygen

CONFIDENTIAL&PROPRIETARYwww.invensense.com

eMDv5.1.1APIsSpecification

Doc:SW-EMD-REL-5.1.1DocRev:1.0Date:12/14/2012

26ModuleDocumentation

Ifsensorsdoesnotcontainaparticularsensor,disregardthedatareturnedtothat

pointer.

sensorscancontainacombinationofthefollowingflags:INV_X_GYRO,INV_Y_GYRO,INV_Z_GYROINV_XYZ_GYROINV_XYZ_ACCEL

IftheFIFOhasnonewdata,sensorswillbezero.

IftheFIFOisdisabled,sensorswillbezeroandthisfunctionwillreturnanon-zeroerrorcode.Parameters:

gyroGyrodatainhardwareunits.accelAcceldatainhardwareunits.timestampTimestampinmilliseconds.sensorsMaskofsensorsreadfromFIFO.moreNumberofremainingpackets.Returns:

0ifsuccessful.

4.1.2.53

intmpu_read_fifo_stream(unsignedshortlength,unsignedchar∗data,unsignedchar∗more)

GetoneunparsedpacketfromtheFIFO.

Thisfunctionshouldbeusedifthepacketistobeparsedelsewhere.Parameters:

lengthLengthofoneFIFOpacket.dataFIFOpacket.

moreNumberofremainingpackets.

4.1.2.

intmpu_read_mem(unsignedshortmem_addr,unsignedshortlength,unsignedchar∗data)

ReadfromtheDMPmemory.

ThisfunctionpreventsI2Creadspastthebankboundaries.TheDMPmemoryisonlyaccessiblewhenthechipisawake.

GeneratedonFriDec1411:17:092012forMotionDriverbyDoxygen

CONFIDENTIAL&PROPRIETARYwww.invensense.com

eMDv5.1.1APIsSpecification

Doc:SW-EMD-REL-5.1.1DocRev:1.0Date:12/14/2012

4.1SensorDriverLayer27

Parameters:

mem_addrMemorylocation(bank<<8|startaddress)lengthNumberofbytestoread.dataBytesreadfrommemory.Returns:

0ifsuccessful.

4.1.2.55intmpu_read_reg(unsignedcharreg,unsignedchar∗data)

Readfromasingleregister.

NOTE:ThememoryandFIFOread/writeregisterscannotbeaccessed.Parameters:

regRegisteraddress.dataRegisterdata.Returns:

0ifsuccessful.

4.1.2.56intmpu_reg_dump(void)Registerdumpfortesting.Returns:

0ifsuccessful.

4.1.2.57intmpu_reset_fifo(void)ResetFIFOread/writepointers.Returns:

0ifsuccessful.

GeneratedonFriDec1411:17:092012forMotionDriverbyDoxygen

CONFIDENTIAL&PROPRIETARYwww.invensense.com

eMDv5.1.1APIsSpecification

Doc:SW-EMD-REL-5.1.1DocRev:1.0Date:12/14/2012

284.1.2.58

ModuleDocumentation

intmpu_run_self_test(long∗gyro,long∗accel)

Triggergyro/accel/compassself-test.

Onsuccess/error,theself-testreturnsamaskrepresentingthesensor(s)thatfailed.For

eachbit,aone(1)representsa\"pass\"case;conversely,azero(0)indicatesafailure.Themaskisdefinedasfollows:Bit0:Gyro.Bit1:Accel.Bit2:Compass.

Currently,thehardwareself-testisunsupportedforMPU6500.However,thisfunctioncanstillbeusedtoobtaintheaccelandgyrobiases.

Thisfunctionmustbecalledwiththedeviceeitherface-uporface-down(z-axisisparalleltogravity).Parameters:

gyroGyrobiasesinq16format.

accelAccelbiases(ifapplicable)inq16format.Returns:

Resultmask(seeabove).

4.1.2.59intmpu_set_accel_bias(constlong∗accel_bias)

Pushbiasestotheaccelbiasregisters.

Thisfunctionexpectsbiasesrelativetothecurrentsensoroutput,andthesebiaseswillbeaddedtothefactory-suppliedvalues.Parameters:

accel_biasNewbiases.Returns:

0ifsuccessful.

4.1.2.60intmpu_set_accel_fsr(unsignedcharfsr)

Settheaccelfull-scalerange.

GeneratedonFriDec1411:17:092012forMotionDriverbyDoxygen

CONFIDENTIAL&PROPRIETARYwww.invensense.com

eMDv5.1.1APIsSpecification

Doc:SW-EMD-REL-5.1.1DocRev:1.0Date:12/14/2012

4.1SensorDriverLayer29

Parameters:

fsrDesiredfull-scalerange.Returns:

0ifsuccessful.

4.1.2.61intmpu_set_bypass(unsignedcharbypass_on)

Setdevicetobypassmode.Parameters:

bypass_on1toenablebypassmode.Returns:

0ifsuccessful.

4.1.2.62intmpu_set_compass_sample_rate(unsignedshortrate)

Setcompasssamplingrate.

ThecompassontheauxiliaryI2CbusisreadbytheMPUhardwareatamaximumof

100Hz.Theactualratecanbesettoafractionofthegyrosamplingrate.

WARNING:Thenewratemaybedifferentthanwhatwasrequested.Callmpu_get_-compass_sample_ratetochecktheactualsetting.Parameters:

rateDesiredcompasssamplingrate(Hz).Returns:

0ifsuccessful.

4.1.2.63intmpu_set_dmp_state(unsignedcharenable)

Enable/disableDMPsupport.Parameters:

enable1toturnontheDMP.Returns:

0ifsuccessful.

GeneratedonFriDec1411:17:092012forMotionDriverbyDoxygen

CONFIDENTIAL&PROPRIETARYwww.invensense.com

eMDv5.1.1APIsSpecification

Doc:SW-EMD-REL-5.1.1DocRev:1.0Date:12/14/2012

304.1.2.

intmpu_set_gyro_fsr(unsignedshortfsr)

ModuleDocumentation

Setthegyrofull-scalerange.Parameters:

fsrDesiredfull-scalerange.Returns:

0ifsuccessful.

4.1.2.65intmpu_set_int_latched(unsignedcharenable)

Enablelatchedinterrupts.

AnyMPUregisterwillcleartheinterrupt.Parameters:

enable1toenable,0todisable.Returns:

0ifsuccessful.

4.1.2.66intmpu_set_int_level(unsignedcharactive_low)

Setinterruptlevel.Parameters:

active_low1foractivelow,0foractivehigh.Returns:

0ifsuccessful.

4.1.2.67intmpu_set_lpf(unsignedshortlpf)

Setdigitallowpassfilter.

ThefollowingLPFsettingsaresupported:188,98,42,20,10,5.Parameters:

lpfDesiredLPFsetting.

GeneratedonFriDec1411:17:092012forMotionDriverbyDoxygen

CONFIDENTIAL&PROPRIETARYwww.invensense.com

eMDv5.1.1APIsSpecification

Doc:SW-EMD-REL-5.1.1DocRev:1.0Date:12/14/2012

4.1SensorDriverLayer31

Returns:

0ifsuccessful.

4.1.2.68intmpu_set_sample_rate(unsignedshortrate)

Setsamplingrate.

Samplingratemustbebetween4Hzand1kHz.Parameters:

rateDesiredsamplingrate(Hz).Returns:

0ifsuccessful.

4.1.2.69intmpu_set_sensors(unsignedcharsensors)

Turnspecificsensorson/off.

sensorscancontainacombinationofthefollowingflags:INV_X_GYRO,INV_Y_GYRO,INV_Z_GYROINV_XYZ_GYROINV_XYZ_ACCELINV_XYZ_COMPASSParameters:

sensorsMaskofsensorstowake.Returns:

0ifsuccessful.

4.1.2.70

intmpu_write_mem(unsignedshortmem_addr,unsignedshort

length,unsignedchar∗data)

WritetotheDMPmemory.

ThisfunctionpreventsI2Cwritespastthebankboundaries.TheDMPmemoryisonlyaccessiblewhenthechipisawake.

GeneratedonFriDec1411:17:092012forMotionDriverbyDoxygen

CONFIDENTIAL&PROPRIETARYwww.invensense.com

eMDv5.1.1APIsSpecification

Doc:SW-EMD-REL-5.1.1DocRev:1.0Date:12/14/2012

32

Parameters:

ModuleDocumentation

mem_addrMemorylocation(bank<<8|startaddress)lengthNumberofbytestowrite.dataBytestowritetomemory.Returns:

0ifsuccessful.

GeneratedonFriDec1411:17:092012forMotionDriverbyDoxygen

CONFIDENTIAL&PROPRIETARYwww.invensense.com

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- huatuo0.com 版权所有 湘ICP备2023021991号-1

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务