初始化提交
This commit is contained in:
201
arduino-cli/libraries/MPU9250/LICENSE
Normal file
201
arduino-cli/libraries/MPU9250/LICENSE
Normal file
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright {yyyy} {name of copyright owner}
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
25
arduino-cli/libraries/MPU9250/README.md
Normal file
25
arduino-cli/libraries/MPU9250/README.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# FaBo9AXIS-MPU9250-Library
|
||||
|
||||
This is a library for FaBo #202 9Axis I2C Brick.
|
||||
|
||||
## FaBo 9Axis I2C Brick
|
||||
|
||||
[#202 9Axis I2C Brick](http://fabo.io/202.html)
|
||||
|
||||
## MPU-9250
|
||||
|
||||
MPU9250 is 9-Axis sensor.
|
||||
|
||||
### MPU-9250 Datasheet
|
||||
|
||||
[MPU9250 Datasheet](http://43zrtwysvxb2gf29r5o0athu.wpengine.netdna-cdn.com/wp-content/uploads/2015/02/MPU-9250-Datasheet.pdf)
|
||||
[MPU9250 Register map](http://43zrtwysvxb2gf29r5o0athu.wpengine.netdna-cdn.com/wp-content/uploads/2015/02/MPU-9250-Register-Map.pdf)
|
||||
|
||||
## Releases
|
||||
|
||||
- 1.0.0 Initial release.
|
||||
- 1.0.1 minimal fix
|
||||
|
||||
## How to install.
|
||||
|
||||
[Installing Additional Arduino Libraries](https://www.arduino.cc/en/Guide/Libraries)
|
||||
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
@file read9axis.ino
|
||||
@brief This is an Example for the FaBo 9Axis I2C Brick.
|
||||
|
||||
http://fabo.io/202.html
|
||||
|
||||
Released under APACHE LICENSE, VERSION 2.0
|
||||
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
@author FaBo<info@fabo.io>
|
||||
*/
|
||||
|
||||
#include <Wire.h>
|
||||
#include <FaBo9Axis_MPU9250.h>
|
||||
|
||||
FaBo9Axis fabo_9axis;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
Serial.println("RESET");
|
||||
Serial.println();
|
||||
|
||||
Serial.println("configuring device.");
|
||||
|
||||
if (fabo_9axis.begin()) {
|
||||
Serial.println("configured FaBo 9Axis I2C Brick");
|
||||
} else {
|
||||
Serial.println("device error");
|
||||
while (1);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
Serial.print("ax:");
|
||||
Serial.println(fabo_9axis.readAccelX());
|
||||
Serial.print("ay:");
|
||||
Serial.println(fabo_9axis.readAccelY());
|
||||
Serial.print("az:");
|
||||
Serial.println(fabo_9axis.readAccelZ());
|
||||
Serial.print("gx:");
|
||||
Serial.println(fabo_9axis.readGyroX());
|
||||
Serial.print("gy:");
|
||||
Serial.println(fabo_9axis.readGyroY());
|
||||
Serial.print("gz:");
|
||||
Serial.println(fabo_9axis.readGyroZ());
|
||||
Serial.print("mx:");
|
||||
Serial.println(fabo_9axis.readMagnetX());
|
||||
Serial.print("my:");
|
||||
Serial.println(fabo_9axis.readMagnetY());
|
||||
Serial.print("mz:");
|
||||
Serial.println(fabo_9axis.readMagnetZ());
|
||||
delay(1000);
|
||||
}
|
||||
167
arduino-cli/libraries/MPU9250/keywords.txt
Normal file
167
arduino-cli/libraries/MPU9250/keywords.txt
Normal file
@@ -0,0 +1,167 @@
|
||||
#######################################
|
||||
# Syntax Coloring Map For FaBo9AXIS-MPU9250-Library
|
||||
#######################################
|
||||
|
||||
#######################################
|
||||
# Class (KEYWORD1)
|
||||
#######################################
|
||||
|
||||
FaBo9Axis KEYWORD1
|
||||
|
||||
#######################################
|
||||
# Methods and Functions (KEYWORD2)
|
||||
#######################################
|
||||
|
||||
begin KEYWORD2
|
||||
searchDevice KEYWORD2
|
||||
configMPU9250 KEYWORD2
|
||||
configAK8963 KEYWORD2
|
||||
checkDataReady KEYWORD2
|
||||
readAccelXYZ KEYWORD2
|
||||
readGyroXYZ KEYWORD2
|
||||
readMagnetXYZ KEYWORD2
|
||||
readTemperature KEYWORD2
|
||||
|
||||
#######################################
|
||||
# Constants (LITERAL1)
|
||||
#######################################
|
||||
|
||||
MPU9250_SLAVE_ADDRESS LITERAL1
|
||||
AK8963_SLAVE_ADDRESS LITERAL1
|
||||
MPU9250_SELF_TEST_X_GYRO LITERAL1
|
||||
MPU9250_SELF_TEST_Y_GYRO LITERAL1
|
||||
MPU9250_SELF_TEST_Z_GYRO LITERAL1
|
||||
MPU9250_SELF_TEST_X_ACCEL LITERAL1
|
||||
MPU9250_SELF_TEST_Y_ACCEL LITERAL1
|
||||
MPU9250_SELF_TEST_Z_ACCEL LITERAL1
|
||||
MPU9250_XG_OFFSET_H LITERAL1
|
||||
MPU9250_XG_OFFSET_L LITERAL1
|
||||
MPU9250_YG_OFFSET_H LITERAL1
|
||||
MPU9250_YG_OFFSET_L LITERAL1
|
||||
MPU9250_ZG_OFFSET_H LITERAL1
|
||||
MPU9250_ZG_OFFSET_L LITERAL1
|
||||
MPU9250_SMPLRT_DIV LITERAL1
|
||||
MPU9250_CONFIG LITERAL1
|
||||
MPU9250_GYRO_CONFIG LITERAL1
|
||||
MPU9250_ACCEL_CONFIG LITERAL1
|
||||
MPU9250_ACCEL_CONFIG_2 LITERAL1
|
||||
MPU9250_LP_ACCEL_ODR LITERAL1
|
||||
MPU9250_WOM_THR LITERAL1
|
||||
MPU9250_FIFO_EN LITERAL1
|
||||
MPU9250_I2C_MST_CTRL LITERAL1
|
||||
MPU9250_I2C_SLV0_ADDR LITERAL1
|
||||
MPU9250_I2C_SLV0_REG LITERAL1
|
||||
MPU9250_I2C_SLV0_CTRL LITERAL1
|
||||
MPU9250_I2C_SLV1_ADDR LITERAL1
|
||||
MPU9250_I2C_SLV1_REG LITERAL1
|
||||
MPU9250_I2C_SLV1_CTRL LITERAL1
|
||||
MPU9250_I2C_SLV2_ADDR LITERAL1
|
||||
MPU9250_I2C_SLV2_REG LITERAL1
|
||||
MPU9250_I2C_SLV2_CTRL LITERAL1
|
||||
MPU9250_I2C_SLV3_ADDR LITERAL1
|
||||
MPU9250_I2C_SLV3_REG LITERAL1
|
||||
MPU9250_I2C_SLV3_CTRL LITERAL1
|
||||
MPU9250_I2C_SLV4_ADDR LITERAL1
|
||||
MPU9250_I2C_SLV4_REG LITERAL1
|
||||
MPU9250_I2C_SLV4_DO LITERAL1
|
||||
MPU9250_I2C_SLV4_CTRL LITERAL1
|
||||
MPU9250_I2C_SLV4_DI LITERAL1
|
||||
MPU9250_I2C_MST_STATUS LITERAL1
|
||||
MPU9250_INT_PIN_CFG LITERAL1
|
||||
MPU9250_INT_ENABLE LITERAL1
|
||||
MPU9250_INT_STATUS LITERAL1
|
||||
MPU9250_ACCEL_XOUT_H LITERAL1
|
||||
MPU9250_ACCEL_XOUT_L LITERAL1
|
||||
MPU9250_ACCEL_YOUT_H LITERAL1
|
||||
MPU9250_ACCEL_YOUT_L LITERAL1
|
||||
MPU9250_ACCEL_ZOUT_H LITERAL1
|
||||
MPU9250_ACCEL_ZOUT_L LITERAL1
|
||||
MPU9250_TEMP_OUT_H LITERAL1
|
||||
MPU9250_TEMP_OUT_L LITERAL1
|
||||
MPU9250_GYRO_XOUT_H LITERAL1
|
||||
MPU9250_GYRO_XOUT_L LITERAL1
|
||||
MPU9250_GYRO_YOUT_H LITERAL1
|
||||
MPU9250_GYRO_YOUT_L LITERAL1
|
||||
MPU9250_GYRO_ZOUT_H LITERAL1
|
||||
MPU9250_GYRO_ZOUT_L LITERAL1
|
||||
MPU9250_EXT_SENS_DATA_00 LITERAL1
|
||||
MPU9250_EXT_SENS_DATA_01 LITERAL1
|
||||
MPU9250_EXT_SENS_DATA_02 LITERAL1
|
||||
MPU9250_EXT_SENS_DATA_03 LITERAL1
|
||||
MPU9250_EXT_SENS_DATA_04 LITERAL1
|
||||
MPU9250_EXT_SENS_DATA_05 LITERAL1
|
||||
MPU9250_EXT_SENS_DATA_06 LITERAL1
|
||||
MPU9250_EXT_SENS_DATA_07 LITERAL1
|
||||
MPU9250_EXT_SENS_DATA_08 LITERAL1
|
||||
MPU9250_EXT_SENS_DATA_09 LITERAL1
|
||||
MPU9250_EXT_SENS_DATA_10 LITERAL1
|
||||
MPU9250_EXT_SENS_DATA_11 LITERAL1
|
||||
MPU9250_EXT_SENS_DATA_12 LITERAL1
|
||||
MPU9250_EXT_SENS_DATA_13 LITERAL1
|
||||
MPU9250_EXT_SENS_DATA_14 LITERAL1
|
||||
MPU9250_EXT_SENS_DATA_15 LITERAL1
|
||||
MPU9250_EXT_SENS_DATA_16 LITERAL1
|
||||
MPU9250_EXT_SENS_DATA_17 LITERAL1
|
||||
MPU9250_EXT_SENS_DATA_18 LITERAL1
|
||||
MPU9250_EXT_SENS_DATA_19 LITERAL1
|
||||
MPU9250_EXT_SENS_DATA_20 LITERAL1
|
||||
MPU9250_EXT_SENS_DATA_21 LITERAL1
|
||||
MPU9250_EXT_SENS_DATA_22 LITERAL1
|
||||
MPU9250_EXT_SENS_DATA_23 LITERAL1
|
||||
MPU9250_I2C_SLV0_DO LITERAL1
|
||||
MPU9250_I2C_SLV1_DO LITERAL1
|
||||
MPU9250_I2C_SLV2_DO LITERAL1
|
||||
MPU9250_I2C_SLV3_DO LITERAL1
|
||||
MPU9250_I2C_MST_DELAY_CTRL LITERAL1
|
||||
MPU9250_SIGNAL_PATH_RESET LITERAL1
|
||||
MPU9250_MOT_DETECT_CTRL LITERAL1
|
||||
MPU9250_USER_CTRL LITERAL1
|
||||
MPU9250_PWR_MGMT_1 LITERAL1
|
||||
MPU9250_PWR_MGMT_2 LITERAL1
|
||||
MPU9250_FIFO_COUNTH LITERAL1
|
||||
MPU9250_FIFO_COUNTL LITERAL1
|
||||
MPU9250_FIFO_R_W LITERAL1
|
||||
MPU9250_WHO_AM_I LITERAL1
|
||||
MPU9250_XA_OFFSET_H LITERAL1
|
||||
MPU9250_XA_OFFSET_L LITERAL1
|
||||
MPU9250_YA_OFFSET_H LITERAL1
|
||||
MPU9250_YA_OFFSET_L LITERAL1
|
||||
MPU9250_ZA_OFFSET_H LITERAL1
|
||||
MPU9250_ZA_OFFSET_L LITERAL1
|
||||
MPU9250_GFS_250 LITERAL1
|
||||
MPU9250_GFS_500 LITERAL1
|
||||
MPU9250_GFS_1000 LITERAL1
|
||||
MPU9250_GFS_2000 LITERAL1
|
||||
MPU9250_AFS_2G LITERAL1
|
||||
MPU9250_AFS_4G LITERAL1
|
||||
MPU9250_AFS_8G LITERAL1
|
||||
MPU9250_AFS_16G LITERAL1
|
||||
AK8963_WIA LITERAL1
|
||||
AK8963_INFO LITERAL1
|
||||
AK8963_ST1 LITERAL1
|
||||
AK8963_HXL LITERAL1
|
||||
AK8963_HXH LITERAL1
|
||||
AK8963_HYL LITERAL1
|
||||
AK8963_HYH LITERAL1
|
||||
AK8963_HZL LITERAL1
|
||||
AK8963_HZH LITERAL1
|
||||
AK8963_ST2 LITERAL1
|
||||
AK8963_CNTL1 LITERAL1
|
||||
AK8963_CNTL2 LITERAL1
|
||||
AK8963_ASTC LITERAL1
|
||||
AK8963_TS1 LITERAL1
|
||||
AK8963_TS2 LITERAL1
|
||||
AK8963_I2CDIS LITERAL1
|
||||
AK8963_ASAX LITERAL1
|
||||
AK8963_ASAY LITERAL1
|
||||
AK8963_ASAZ LITERAL1
|
||||
AK8963_RSV LITERAL1
|
||||
AK8963_MODE_DOWN LITERAL1
|
||||
AK8963_MODE_ONE LITERAL1
|
||||
AK8963_MODE_C8HZ LITERAL1
|
||||
AK8963_MODE_C100HZ LITERAL1
|
||||
AK8963_MODE_TRIG LITERAL1
|
||||
AK8963_MODE_TEST LITERAL1
|
||||
AK8963_MODE_FUSE LITERAL1
|
||||
AK8963_BIT_14 LITERAL1
|
||||
AK8963_BIT_16 LITERAL1
|
||||
9
arduino-cli/libraries/MPU9250/library.properties
Normal file
9
arduino-cli/libraries/MPU9250/library.properties
Normal file
@@ -0,0 +1,9 @@
|
||||
name=FaBo 202 9Axis MPU9250
|
||||
version=1.0.1
|
||||
author=FaBo<info@fabo.io>
|
||||
maintainer=Akira Sasaki<akira@fabo.io>
|
||||
sentence=A library for FaBo 9Axis I2C Brick
|
||||
paragraph=MPU9250 is 9-Axis sensor.
|
||||
category=Sensors
|
||||
url=https://github.com/FaBoPlatform/FaBo9AXIS-MPU9250-Library
|
||||
architectures=avr,esp32
|
||||
371
arduino-cli/libraries/MPU9250/src/FaBo9Axis_MPU9250.cpp
Normal file
371
arduino-cli/libraries/MPU9250/src/FaBo9Axis_MPU9250.cpp
Normal file
@@ -0,0 +1,371 @@
|
||||
/**
|
||||
@file FaBo9Axis_MPU9250.cpp
|
||||
@brief This is a library for the FaBo 9Axis I2C Brick.
|
||||
|
||||
http://fabo.io/202.html
|
||||
|
||||
Released under APACHE LICENSE, VERSION 2.0
|
||||
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
@author FaBo<info@fabo.io>
|
||||
*/
|
||||
|
||||
#include "FaBo9Axis_MPU9250.h"
|
||||
|
||||
/**
|
||||
@brief Constructor
|
||||
@param [in] addr MPU-9250 I2C slave address
|
||||
*/
|
||||
FaBo9Axis::FaBo9Axis(uint8_t addr) {
|
||||
_mpu9250addr = addr;
|
||||
Wire.begin();
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Begin Device
|
||||
@retval true normaly done
|
||||
@retval false device error
|
||||
*/
|
||||
bool FaBo9Axis::begin() {
|
||||
if (searchDevice()) {
|
||||
configMPU9250();
|
||||
configAK8963();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Search Device
|
||||
@retval true device connected
|
||||
@retval false device error
|
||||
*/
|
||||
bool FaBo9Axis::searchDevice() {
|
||||
uint8_t whoami;
|
||||
readI2c(_mpu9250addr, MPU9250_WHO_AM_I, 1, &whoami);
|
||||
if(whoami == 0x71){
|
||||
return true;
|
||||
} else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Configure MPU-9250
|
||||
@param [in] gfs Gyro Full Scale Select(default:MPU9250_GFS_250[+250dps])
|
||||
@param [in] afs Accel Full Scale Select(default:MPU9250_AFS_2G[2g])
|
||||
*/
|
||||
void FaBo9Axis::configMPU9250(uint8_t gfs, uint8_t afs) {
|
||||
switch(gfs) {
|
||||
case MPU9250_GFS_250:
|
||||
_gres = 250.0/32768.0;
|
||||
break;
|
||||
case MPU9250_GFS_500:
|
||||
_gres = 500.0/32768.0;
|
||||
break;
|
||||
case MPU9250_GFS_1000:
|
||||
_gres = 1000.0/32768.0;
|
||||
break;
|
||||
case MPU9250_GFS_2000:
|
||||
_gres = 2000.0/32768.0;
|
||||
break;
|
||||
}
|
||||
switch(afs) {
|
||||
case MPU9250_AFS_2G:
|
||||
_ares = 2.0/32768.0;
|
||||
break;
|
||||
case MPU9250_AFS_4G:
|
||||
_ares = 4.0/32768.0;
|
||||
break;
|
||||
case MPU9250_AFS_8G:
|
||||
_ares = 8.0/32768.0;
|
||||
break;
|
||||
case MPU9250_AFS_16G:
|
||||
_ares = 16.0/32768.0;
|
||||
break;
|
||||
}
|
||||
// sleep off
|
||||
writeI2c(_mpu9250addr, MPU9250_PWR_MGMT_1, 0x00);
|
||||
delay(100);
|
||||
// auto select clock source
|
||||
writeI2c(_mpu9250addr, MPU9250_PWR_MGMT_1, 0x01);
|
||||
delay(200);
|
||||
// DLPF_CFG
|
||||
writeI2c(_mpu9250addr, MPU9250_CONFIG, 0x03);
|
||||
// sample rate divider
|
||||
writeI2c(_mpu9250addr, MPU9250_SMPLRT_DIV, 0x04);
|
||||
// gyro full scale select
|
||||
writeI2c(_mpu9250addr, MPU9250_GYRO_CONFIG, gfs << 3);
|
||||
// accel full scale select
|
||||
writeI2c(_mpu9250addr, MPU9250_ACCEL_CONFIG, afs << 3);
|
||||
// A_DLPFCFG
|
||||
writeI2c(_mpu9250addr, MPU9250_ACCEL_CONFIG_2, 0x03);
|
||||
// BYPASS_EN
|
||||
writeI2c(_mpu9250addr, MPU9250_INT_PIN_CFG, 0x02);
|
||||
delay(100);
|
||||
}
|
||||
|
||||
void FaBo9Axis::dumpConfig() {
|
||||
uint8_t c;
|
||||
readI2c(_mpu9250addr, MPU9250_GYRO_CONFIG, 1, &c);
|
||||
Serial.println(c,HEX);
|
||||
readI2c(_mpu9250addr, MPU9250_ACCEL_CONFIG, 1, &c);
|
||||
Serial.println(c,HEX);
|
||||
readI2c(_mpu9250addr, MPU9250_ACCEL_CONFIG_2, 1, &c);
|
||||
Serial.println(c,HEX);
|
||||
readI2c(AK8963_SLAVE_ADDRESS, AK8963_CNTL1, 1, &c);
|
||||
Serial.println(c,HEX);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Configure AK8963
|
||||
@param [in] mode Magneto Mode Select(default:AK8963_MODE_C8HZ[Continous 8Hz])
|
||||
@param [in] mfs Magneto Scale Select(default:AK8963_BIT_16[16bit])
|
||||
*/
|
||||
void FaBo9Axis::configAK8963(uint8_t mode, uint8_t mfs) {
|
||||
uint8_t data[3];
|
||||
|
||||
switch(mfs) {
|
||||
case AK8963_BIT_14:
|
||||
_mres = 4912.0/8190.0;
|
||||
break;
|
||||
case AK8963_BIT_16:
|
||||
_mres = 4912.0/32760.0;
|
||||
break;
|
||||
}
|
||||
|
||||
// set software reset
|
||||
// writeI2c(AK8963_SLAVE_ADDRESS, AK8963_CNTL2, 0x01);
|
||||
// delay(100);
|
||||
// set power down mode
|
||||
writeI2c(AK8963_SLAVE_ADDRESS, AK8963_CNTL1, 0x00);
|
||||
delay(1);
|
||||
// set read FuseROM mode
|
||||
writeI2c(AK8963_SLAVE_ADDRESS, AK8963_CNTL1, 0x0F);
|
||||
delay(1);
|
||||
// read coef data
|
||||
readI2c(AK8963_SLAVE_ADDRESS, AK8963_ASAX, 3, data);
|
||||
_magXcoef = (float)(data[0] - 128) / 256.0 + 1.0;
|
||||
_magYcoef = (float)(data[1] - 128) / 256.0 + 1.0;
|
||||
_magZcoef = (float)(data[2] - 128) / 256.0 + 1.0;
|
||||
// set power down mode
|
||||
writeI2c(AK8963_SLAVE_ADDRESS, AK8963_CNTL1, 0x00);
|
||||
delay(1);
|
||||
// set scale&continous mode
|
||||
writeI2c(AK8963_SLAVE_ADDRESS, AK8963_CNTL1, (mfs<<4|mode));
|
||||
delay(1);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Check data ready
|
||||
@retval true data is ready
|
||||
@retval false data is not ready
|
||||
*/
|
||||
bool FaBo9Axis::checkDataReady() {
|
||||
uint8_t drdy;
|
||||
readI2c(_mpu9250addr, MPU9250_INT_STATUS, 1, &drdy);
|
||||
if ( drdy & 0x01 ) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Read accelerometer
|
||||
@param [out] ax X-accel(g)
|
||||
@param [out] ay Y-accel(g)
|
||||
@param [out] az Z-accel(g)
|
||||
*/
|
||||
void FaBo9Axis::readAccelXYZ(float * ax, float * ay, float * az) {
|
||||
uint8_t data[6];
|
||||
int16_t axc, ayc, azc;
|
||||
readI2c(_mpu9250addr, MPU9250_ACCEL_XOUT_H, 6, data);
|
||||
axc = ((int16_t)data[0] << 8) | data[1];
|
||||
ayc = ((int16_t)data[2] << 8) | data[3];
|
||||
azc = ((int16_t)data[4] << 8) | data[5];
|
||||
*ax = (float)axc * _ares;
|
||||
*ay = (float)ayc * _ares;
|
||||
*az = (float)azc * _ares;
|
||||
}
|
||||
float FaBo9Axis::readAccelX() {
|
||||
uint8_t data[6];
|
||||
int16_t axc, ayc, azc;
|
||||
readI2c(_mpu9250addr, MPU9250_ACCEL_XOUT_H, 6, data);
|
||||
axc = ((int16_t)data[0] << 8) | data[1];
|
||||
float ax = (float)axc * _ares;
|
||||
return ax;
|
||||
}
|
||||
float FaBo9Axis::readAccelY() {
|
||||
uint8_t data[6];
|
||||
int16_t axc, ayc, azc;
|
||||
readI2c(_mpu9250addr, MPU9250_ACCEL_XOUT_H, 6, data);
|
||||
ayc = ((int16_t)data[2] << 8) | data[3];
|
||||
float ay = (float)ayc * _ares;
|
||||
return ay;
|
||||
}
|
||||
float FaBo9Axis::readAccelZ() {
|
||||
uint8_t data[6];
|
||||
int16_t axc, ayc, azc;
|
||||
readI2c(_mpu9250addr, MPU9250_ACCEL_XOUT_H, 6, data);
|
||||
azc = ((int16_t)data[4] << 8) | data[5];
|
||||
float az = (float)azc * _ares;
|
||||
return az;
|
||||
}
|
||||
/**
|
||||
@brief Read gyro
|
||||
@param [out] gx X-gyro(degrees/sec)
|
||||
@param [out] gy Y-gyro(degrees/sec)
|
||||
@param [out] gz Z-gyro(degrees/sec)
|
||||
*/
|
||||
void FaBo9Axis::readGyroXYZ(float * gx, float * gy, float * gz) {
|
||||
uint8_t data[6];
|
||||
int16_t gxc, gyc, gzc;
|
||||
readI2c(_mpu9250addr, MPU9250_GYRO_XOUT_H, 6, data);
|
||||
gxc = ((int16_t)data[0] << 8) | data[1];
|
||||
gyc = ((int16_t)data[2] << 8) | data[3];
|
||||
gzc = ((int16_t)data[4] << 8) | data[5];
|
||||
*gx = (float)gxc * _gres;
|
||||
*gy = (float)gyc * _gres;
|
||||
*gz = (float)gzc * _gres;
|
||||
}
|
||||
float FaBo9Axis::readGyroX() {
|
||||
uint8_t data[6];
|
||||
int16_t gxc, gyc, gzc;
|
||||
readI2c(_mpu9250addr, MPU9250_GYRO_XOUT_H, 6, data);
|
||||
gxc = ((int16_t)data[0] << 8) | data[1];
|
||||
float gx = (float)gxc * _gres;
|
||||
return gx;
|
||||
}
|
||||
float FaBo9Axis::readGyroY() {
|
||||
uint8_t data[6];
|
||||
int16_t gxc, gyc, gzc;
|
||||
readI2c(_mpu9250addr, MPU9250_GYRO_XOUT_H, 6, data);
|
||||
gyc = ((int16_t)data[2] << 8) | data[3];
|
||||
float gy = (float)gyc * _gres;
|
||||
return gy;
|
||||
}
|
||||
float FaBo9Axis::readGyroZ() {
|
||||
uint8_t data[6];
|
||||
int16_t gxc, gyc, gzc;
|
||||
readI2c(_mpu9250addr, MPU9250_GYRO_XOUT_H, 6, data);
|
||||
gzc = ((int16_t)data[4] << 8) | data[5];
|
||||
float gz = (float)gzc * _gres;
|
||||
return gz;
|
||||
}
|
||||
/**
|
||||
@brief Read magneto
|
||||
@param [out] mx X-magneto(uT)
|
||||
@param [out] my Y-magneto(uT)
|
||||
@param [out] mz Z-magneto(uT)
|
||||
*/
|
||||
void FaBo9Axis::readMagnetXYZ(float * mx, float * my, float * mz) {
|
||||
uint8_t data[7];
|
||||
uint8_t drdy;
|
||||
int16_t mxc, myc, mzc;
|
||||
readI2c(AK8963_SLAVE_ADDRESS, AK8963_ST1, 1, &drdy);
|
||||
if ( drdy & 0x01 ) { // check data ready
|
||||
readI2c(AK8963_SLAVE_ADDRESS, AK8963_HXL, 7, data);
|
||||
if ( !(data[6] & 0x08) ) { // check overflow
|
||||
mxc = ((int16_t)data[1] << 8) | data[0];
|
||||
myc = ((int16_t)data[3] << 8) | data[2];
|
||||
mzc = ((int16_t)data[5] << 8) | data[4];
|
||||
*mx = (float)mxc * _mres * _magXcoef;
|
||||
*my = (float)myc * _mres * _magYcoef;
|
||||
*mz = (float)mzc * _mres * _magZcoef;
|
||||
}
|
||||
}
|
||||
}
|
||||
float FaBo9Axis::readMagnetX() {
|
||||
uint8_t data[7];
|
||||
uint8_t drdy;
|
||||
int16_t mxc, myc, mzc;
|
||||
float mx;
|
||||
readI2c(AK8963_SLAVE_ADDRESS, AK8963_ST1, 1, &drdy);
|
||||
if ( drdy & 0x01 ) { // check data ready
|
||||
readI2c(AK8963_SLAVE_ADDRESS, AK8963_HXL, 7, data);
|
||||
if ( !(data[6] & 0x08) ) { // check overflow
|
||||
mxc = ((int16_t)data[1] << 8) | data[0];
|
||||
mx = (float)mxc * _mres * _magXcoef;
|
||||
}
|
||||
}
|
||||
return mx;
|
||||
}
|
||||
float FaBo9Axis::readMagnetY() {
|
||||
uint8_t data[7];
|
||||
uint8_t drdy;
|
||||
float my ;
|
||||
int16_t mxc, myc, mzc;
|
||||
readI2c(AK8963_SLAVE_ADDRESS, AK8963_ST1, 1, &drdy);
|
||||
if ( drdy & 0x01 ) { // check data ready
|
||||
readI2c(AK8963_SLAVE_ADDRESS, AK8963_HXL, 7, data);
|
||||
if ( !(data[6] & 0x08) ) { // check overflow
|
||||
myc = ((int16_t)data[3] << 8) | data[2];
|
||||
my = (float)myc * _mres * _magYcoef;
|
||||
}
|
||||
}
|
||||
return my;
|
||||
}
|
||||
|
||||
float FaBo9Axis::readMagnetZ() {
|
||||
uint8_t data[7];
|
||||
uint8_t drdy;
|
||||
float mz ;
|
||||
int16_t mxc, myc, mzc;
|
||||
readI2c(AK8963_SLAVE_ADDRESS, AK8963_ST1, 1, &drdy);
|
||||
if ( drdy & 0x01 ) { // check data ready
|
||||
readI2c(AK8963_SLAVE_ADDRESS, AK8963_HXL, 7, data);
|
||||
if ( !(data[6] & 0x08) ) { // check overflow
|
||||
mzc = ((int16_t)data[5] << 8) | data[4];
|
||||
mz = (float)mzc * _mres * _magZcoef;
|
||||
}
|
||||
}
|
||||
return mz;
|
||||
}
|
||||
/**
|
||||
@brief Read temperature
|
||||
@param [out] temperature temperature(degrees C)
|
||||
*/
|
||||
void FaBo9Axis::readTemperature(float * temperature) {
|
||||
uint8_t data[2];
|
||||
int16_t tmc;
|
||||
readI2c(_mpu9250addr, MPU9250_TEMP_OUT_H, 2, data);
|
||||
tmc = ((int16_t)data[0] << 8) | data[1];
|
||||
*temperature = ((float)tmc) / 333.87 + 21.0;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
@brief Write I2C
|
||||
@param [in] address I2C slave address
|
||||
@param [in] register_addr register address
|
||||
@param [in] data write data
|
||||
*/
|
||||
void FaBo9Axis::writeI2c(uint8_t address, uint8_t register_addr, uint8_t data) {
|
||||
Wire.beginTransmission(address);
|
||||
Wire.write(register_addr);
|
||||
Wire.write(data);
|
||||
Wire.endTransmission();
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Read I2C
|
||||
@param [in] address I2C slave address
|
||||
@param [in] register_addr register address
|
||||
@param [in] num read length
|
||||
@param [out] buffer read data
|
||||
*/
|
||||
void FaBo9Axis::readI2c(uint8_t address, uint8_t register_addr, uint8_t num, uint8_t * buffer) {
|
||||
Wire.beginTransmission(address);
|
||||
Wire.write(register_addr);
|
||||
Wire.endTransmission();
|
||||
uint8_t i = 0;
|
||||
Wire.requestFrom(address, num);
|
||||
while( Wire.available() ) {
|
||||
buffer[i++] = Wire.read();
|
||||
}
|
||||
}
|
||||
|
||||
222
arduino-cli/libraries/MPU9250/src/FaBo9Axis_MPU9250.h
Normal file
222
arduino-cli/libraries/MPU9250/src/FaBo9Axis_MPU9250.h
Normal file
@@ -0,0 +1,222 @@
|
||||
/**
|
||||
@file FaBo9Axis_MPU9250.h
|
||||
@brief This is a library for the FaBo 9Axis I2C Brick.
|
||||
|
||||
http://fabo.io/202.html
|
||||
|
||||
Released under APACHE LICENSE, VERSION 2.0
|
||||
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
@author FaBo<info@fabo.io>
|
||||
*/
|
||||
|
||||
#ifndef FABO9AXIS_MPU9250_H
|
||||
#define FABO9AXIS_MPU9250_H
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <Wire.h>
|
||||
|
||||
|
||||
#define MPU9250_SLAVE_ADDRESS 0x68 ///< MPU9250 Default I2C slave address
|
||||
#define AK8963_SLAVE_ADDRESS 0x0C ///< AK8963 I2C slave address
|
||||
|
||||
/// @name MPU-9250 Register Addresses
|
||||
/// @{
|
||||
#define MPU9250_SELF_TEST_X_GYRO 0x00
|
||||
#define MPU9250_SELF_TEST_Y_GYRO 0x01
|
||||
#define MPU9250_SELF_TEST_Z_GYRO 0x02
|
||||
#define MPU9250_SELF_TEST_X_ACCEL 0x0D
|
||||
#define MPU9250_SELF_TEST_Y_ACCEL 0x0E
|
||||
#define MPU9250_SELF_TEST_Z_ACCEL 0x0F
|
||||
#define MPU9250_XG_OFFSET_H 0x13
|
||||
#define MPU9250_XG_OFFSET_L 0x14
|
||||
#define MPU9250_YG_OFFSET_H 0x15
|
||||
#define MPU9250_YG_OFFSET_L 0x16
|
||||
#define MPU9250_ZG_OFFSET_H 0x17
|
||||
#define MPU9250_ZG_OFFSET_L 0x18
|
||||
#define MPU9250_SMPLRT_DIV 0x19
|
||||
#define MPU9250_CONFIG 0x1A
|
||||
#define MPU9250_GYRO_CONFIG 0x1B
|
||||
#define MPU9250_ACCEL_CONFIG 0x1C
|
||||
#define MPU9250_ACCEL_CONFIG_2 0x1D
|
||||
#define MPU9250_LP_ACCEL_ODR 0x1E
|
||||
#define MPU9250_WOM_THR 0x1F
|
||||
#define MPU9250_FIFO_EN 0x23
|
||||
#define MPU9250_I2C_MST_CTRL 0x24
|
||||
#define MPU9250_I2C_SLV0_ADDR 0x25
|
||||
#define MPU9250_I2C_SLV0_REG 0x26
|
||||
#define MPU9250_I2C_SLV0_CTRL 0x27
|
||||
#define MPU9250_I2C_SLV1_ADDR 0x28
|
||||
#define MPU9250_I2C_SLV1_REG 0x29
|
||||
#define MPU9250_I2C_SLV1_CTRL 0x2A
|
||||
#define MPU9250_I2C_SLV2_ADDR 0x2B
|
||||
#define MPU9250_I2C_SLV2_REG 0x2C
|
||||
#define MPU9250_I2C_SLV2_CTRL 0x2D
|
||||
#define MPU9250_I2C_SLV3_ADDR 0x2E
|
||||
#define MPU9250_I2C_SLV3_REG 0x2F
|
||||
#define MPU9250_I2C_SLV3_CTRL 0x30
|
||||
#define MPU9250_I2C_SLV4_ADDR 0x31
|
||||
#define MPU9250_I2C_SLV4_REG 0x32
|
||||
#define MPU9250_I2C_SLV4_DO 0x33
|
||||
#define MPU9250_I2C_SLV4_CTRL 0x34
|
||||
#define MPU9250_I2C_SLV4_DI 0x35
|
||||
#define MPU9250_I2C_MST_STATUS 0x36
|
||||
#define MPU9250_INT_PIN_CFG 0x37
|
||||
#define MPU9250_INT_ENABLE 0x38
|
||||
#define MPU9250_INT_STATUS 0x3A
|
||||
#define MPU9250_ACCEL_XOUT_H 0x3B
|
||||
#define MPU9250_ACCEL_XOUT_L 0x3C
|
||||
#define MPU9250_ACCEL_YOUT_H 0x3D
|
||||
#define MPU9250_ACCEL_YOUT_L 0x3E
|
||||
#define MPU9250_ACCEL_ZOUT_H 0x3F
|
||||
#define MPU9250_ACCEL_ZOUT_L 0x40
|
||||
#define MPU9250_TEMP_OUT_H 0x41
|
||||
#define MPU9250_TEMP_OUT_L 0x42
|
||||
#define MPU9250_GYRO_XOUT_H 0x43
|
||||
#define MPU9250_GYRO_XOUT_L 0x44
|
||||
#define MPU9250_GYRO_YOUT_H 0x45
|
||||
#define MPU9250_GYRO_YOUT_L 0x46
|
||||
#define MPU9250_GYRO_ZOUT_H 0x47
|
||||
#define MPU9250_GYRO_ZOUT_L 0x48
|
||||
#define MPU9250_EXT_SENS_DATA_00 0x49
|
||||
#define MPU9250_EXT_SENS_DATA_01 0x4A
|
||||
#define MPU9250_EXT_SENS_DATA_02 0x4B
|
||||
#define MPU9250_EXT_SENS_DATA_03 0x4C
|
||||
#define MPU9250_EXT_SENS_DATA_04 0x4D
|
||||
#define MPU9250_EXT_SENS_DATA_05 0x4E
|
||||
#define MPU9250_EXT_SENS_DATA_06 0x4F
|
||||
#define MPU9250_EXT_SENS_DATA_07 0x50
|
||||
#define MPU9250_EXT_SENS_DATA_08 0x51
|
||||
#define MPU9250_EXT_SENS_DATA_09 0x52
|
||||
#define MPU9250_EXT_SENS_DATA_10 0x53
|
||||
#define MPU9250_EXT_SENS_DATA_11 0x54
|
||||
#define MPU9250_EXT_SENS_DATA_12 0x55
|
||||
#define MPU9250_EXT_SENS_DATA_13 0x56
|
||||
#define MPU9250_EXT_SENS_DATA_14 0x57
|
||||
#define MPU9250_EXT_SENS_DATA_15 0x58
|
||||
#define MPU9250_EXT_SENS_DATA_16 0x59
|
||||
#define MPU9250_EXT_SENS_DATA_17 0x5A
|
||||
#define MPU9250_EXT_SENS_DATA_18 0x5B
|
||||
#define MPU9250_EXT_SENS_DATA_19 0x5C
|
||||
#define MPU9250_EXT_SENS_DATA_20 0x5D
|
||||
#define MPU9250_EXT_SENS_DATA_21 0x5E
|
||||
#define MPU9250_EXT_SENS_DATA_22 0x5F
|
||||
#define MPU9250_EXT_SENS_DATA_23 0x60
|
||||
#define MPU9250_I2C_SLV0_DO 0x63
|
||||
#define MPU9250_I2C_SLV1_DO 0x64
|
||||
#define MPU9250_I2C_SLV2_DO 0x65
|
||||
#define MPU9250_I2C_SLV3_DO 0x66
|
||||
#define MPU9250_I2C_MST_DELAY_CTRL 0x67
|
||||
#define MPU9250_SIGNAL_PATH_RESET 0x68
|
||||
#define MPU9250_MOT_DETECT_CTRL 0x69
|
||||
#define MPU9250_USER_CTRL 0x6A
|
||||
#define MPU9250_PWR_MGMT_1 0x6B
|
||||
#define MPU9250_PWR_MGMT_2 0x6C
|
||||
#define MPU9250_FIFO_COUNTH 0x72
|
||||
#define MPU9250_FIFO_COUNTL 0x73
|
||||
#define MPU9250_FIFO_R_W 0x74
|
||||
#define MPU9250_WHO_AM_I 0x75
|
||||
#define MPU9250_XA_OFFSET_H 0x77
|
||||
#define MPU9250_XA_OFFSET_L 0x78
|
||||
#define MPU9250_YA_OFFSET_H 0x7A
|
||||
#define MPU9250_YA_OFFSET_L 0x7B
|
||||
#define MPU9250_ZA_OFFSET_H 0x7D
|
||||
#define MPU9250_ZA_OFFSET_L 0x7E
|
||||
/// @}
|
||||
|
||||
/// @name Gyro Full Scale Select
|
||||
/// @{
|
||||
#define MPU9250_GFS_250 0x0 ///< +250dps
|
||||
#define MPU9250_GFS_500 0x1 ///< +500dps
|
||||
#define MPU9250_GFS_1000 0x2 ///< +1000dps
|
||||
#define MPU9250_GFS_2000 0x3 ///< +2000dps
|
||||
/// @}
|
||||
|
||||
/// @name Accel Full Scale Select
|
||||
/// @{
|
||||
#define MPU9250_AFS_2G 0x0 ///< 2g
|
||||
#define MPU9250_AFS_4G 0x1 ///< 4g
|
||||
#define MPU9250_AFS_8G 0x2 ///< 8g
|
||||
#define MPU9250_AFS_16G 0x3 ///< 16g
|
||||
/// @}
|
||||
|
||||
|
||||
/// @name AK8963 Register Addresses
|
||||
/// @{
|
||||
#define AK8963_WIA 0x00
|
||||
#define AK8963_INFO 0x01
|
||||
#define AK8963_ST1 0x02
|
||||
#define AK8963_HXL 0x03
|
||||
#define AK8963_HXH 0x04
|
||||
#define AK8963_HYL 0x05
|
||||
#define AK8963_HYH 0x06
|
||||
#define AK8963_HZL 0x07
|
||||
#define AK8963_HZH 0x08
|
||||
#define AK8963_ST2 0x09
|
||||
#define AK8963_CNTL1 0x0A
|
||||
#define AK8963_CNTL2 0x0B
|
||||
#define AK8963_ASTC 0x0C
|
||||
#define AK8963_TS1 0x0D
|
||||
#define AK8963_TS2 0x0E
|
||||
#define AK8963_I2CDIS 0x0F
|
||||
#define AK8963_ASAX 0x10
|
||||
#define AK8963_ASAY 0x11
|
||||
#define AK8963_ASAZ 0x12
|
||||
#define AK8963_RSV 0x13
|
||||
/// @}
|
||||
|
||||
|
||||
/// @name CNTL1 Mode select
|
||||
/// @{
|
||||
#define AK8963_MODE_DOWN 0x00 ///< Power down mode
|
||||
#define AK8963_MODE_ONE 0x01 ///< One shot data output
|
||||
#define AK8963_MODE_C8HZ 0x02 ///< Continous data output 8Hz
|
||||
#define AK8963_MODE_C100HZ 0x06 ///< Continous data output 100Hz
|
||||
#define AK8963_MODE_TRIG 0x04 ///< External trigger data output
|
||||
#define AK8963_MODE_TEST 0x08 ///< Self test
|
||||
#define AK8963_MODE_FUSE 0x0F ///< Fuse ROM access
|
||||
/// @}
|
||||
|
||||
/// @name Magneto Scale Select
|
||||
/// @{
|
||||
#define AK8963_BIT_14 0x0 ///< 14bit output
|
||||
#define AK8963_BIT_16 0x1 ///< 16bit output
|
||||
/// @}
|
||||
|
||||
|
||||
/**
|
||||
* @class FaBo9Axis
|
||||
* @brief FaBo 9Axis I2C Controll class
|
||||
*/
|
||||
class FaBo9Axis {
|
||||
public:
|
||||
FaBo9Axis(uint8_t addr = MPU9250_SLAVE_ADDRESS);
|
||||
bool begin(void);
|
||||
bool searchDevice(void);
|
||||
void configMPU9250(uint8_t gfs = MPU9250_GFS_250, uint8_t afs = MPU9250_AFS_2G);
|
||||
void configAK8963(uint8_t mode = AK8963_MODE_C8HZ, uint8_t mfs = AK8963_BIT_16);
|
||||
bool checkDataReady();
|
||||
void readAccelXYZ(float * ax, float * ay, float * az);
|
||||
float readAccelX();
|
||||
float readAccelY();
|
||||
float readAccelZ();
|
||||
void readGyroXYZ(float * gx, float * gy, float * gz);
|
||||
float readGyroX();
|
||||
float readGyroY();
|
||||
float readGyroZ();
|
||||
void readMagnetXYZ(float * mx, float * my, float * mz);
|
||||
float readMagnetX();
|
||||
float readMagnetY();
|
||||
float readMagnetZ();
|
||||
void readTemperature(float * temperature);
|
||||
void dumpConfig(void);
|
||||
private:
|
||||
uint8_t _mpu9250addr;
|
||||
float _gres, _ares, _mres;
|
||||
float _magXcoef, _magYcoef, _magZcoef;
|
||||
void writeI2c(byte address, uint8_t register_addr, uint8_t data);
|
||||
void readI2c(uint8_t address, uint8_t register_addr, uint8_t num, uint8_t * buffer);
|
||||
};
|
||||
|
||||
#endif // FABO9AXIS_MPU9250_H
|
||||
Reference in New Issue
Block a user