-
Notifications
You must be signed in to change notification settings - Fork 13.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
new InvenSense icm20948 driver on SPI with AK09916 mag #14567
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
src/drivers/imu/invensense/icm20948/AKM_AK09916_registers.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/**************************************************************************** | ||
* | ||
* Copyright (c) 2019 PX4 Development Team. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in | ||
* the documentation and/or other materials provided with the | ||
* distribution. | ||
* 3. Neither the name PX4 nor the names of its contributors may be | ||
* used to endorse or promote products derived from this software | ||
* without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS | ||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | ||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
****************************************************************************/ | ||
|
||
/** | ||
* @file AKM_AK09916_registers.hpp | ||
* | ||
* Asahi Kasei Microdevices (AKM) AK09916 registers. | ||
* | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <cstdint> | ||
|
||
namespace AKM_AK09916 | ||
{ | ||
|
||
// TODO: move to a central header | ||
static constexpr uint8_t Bit0 = (1 << 0); | ||
static constexpr uint8_t Bit1 = (1 << 1); | ||
static constexpr uint8_t Bit2 = (1 << 2); | ||
static constexpr uint8_t Bit3 = (1 << 3); | ||
static constexpr uint8_t Bit4 = (1 << 4); | ||
static constexpr uint8_t Bit5 = (1 << 5); | ||
static constexpr uint8_t Bit6 = (1 << 6); | ||
static constexpr uint8_t Bit7 = (1 << 7); | ||
|
||
static constexpr uint32_t I2C_SPEED = 400 * 1000; // 400 kHz I2C serial interface | ||
static constexpr uint8_t I2C_ADDRESS_DEFAULT = 0b0001100; | ||
|
||
static constexpr uint8_t WHOAMI = 0x09; | ||
|
||
enum class Register : uint8_t { | ||
WIA = 0x01, // Device ID | ||
|
||
ST1 = 0x10, // Status 1 | ||
HXL = 0x11, | ||
HXH = 0x12, | ||
HYL = 0x13, | ||
HYH = 0x14, | ||
HZL = 0x15, | ||
HZH = 0x16, | ||
|
||
ST2 = 0x18, // Status 2 | ||
|
||
CNTL2 = 0x31, // Control 2 | ||
CNTL3 = 0x32, // Control 3 | ||
}; | ||
|
||
// ST1 | ||
enum ST1_BIT : uint8_t { | ||
DOR = Bit1, // Data overrun | ||
DRDY = Bit0, // Data is ready | ||
}; | ||
|
||
// ST2 | ||
enum ST2_BIT : uint8_t { | ||
BITM = Bit4, // Output bit setting (mirror) | ||
HOFL = Bit3, // Magnetic sensor overflow | ||
}; | ||
|
||
// CNTL2 | ||
enum CNTL2_BIT : uint8_t { | ||
MODE1 = Bit1, // Continuous measurement mode 1 (10Hz) | ||
MODE2 = Bit2, // Continuous measurement mode 2 (20Hz) | ||
MODE3 = Bit2 | Bit1, // Continuous measurement mode 3 (50Hz) | ||
MODE4 = Bit3, // Continuous measurement mode 4 (100Hz) | ||
}; | ||
|
||
// CNTL3 | ||
enum CNTL3_BIT : uint8_t { | ||
SRST = Bit0, | ||
}; | ||
|
||
} // namespace AKM_AK09916 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
############################################################################ | ||
# | ||
# Copyright (c) 2020 PX4 Development Team. All rights reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions | ||
# are met: | ||
# | ||
# 1. Redistributions of source code must retain the above copyright | ||
# notice, this list of conditions and the following disclaimer. | ||
# 2. Redistributions in binary form must reproduce the above copyright | ||
# notice, this list of conditions and the following disclaimer in | ||
# the documentation and/or other materials provided with the | ||
# distribution. | ||
# 3. Neither the name PX4 nor the names of its contributors may be | ||
# used to endorse or promote products derived from this software | ||
# without specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS | ||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | ||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
# POSSIBILITY OF SUCH DAMAGE. | ||
# | ||
############################################################################ | ||
px4_add_module( | ||
MODULE drivers__imu__icm20948 | ||
MAIN icm20948 | ||
COMPILE_FLAGS | ||
-DDEBUG_BUILD | ||
-O0 | ||
SRCS | ||
AKM_AK09916_registers.hpp | ||
ICM20948.cpp | ||
ICM20948.hpp | ||
ICM20948_AK09916.cpp | ||
ICM20948_AK09916.hpp | ||
icm20948_main.cpp | ||
InvenSense_ICM20948_registers.hpp | ||
DEPENDS | ||
px4_work_queue | ||
drivers_accelerometer | ||
drivers_gyroscope | ||
drivers_magnetometer | ||
) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note, I wouldn't typically do this, but the IMU portion of the old icm20948 never worked properly in the first place.