aboutsummaryrefslogtreecommitdiffstats
path: root/klippy
diff options
context:
space:
mode:
authorYifei Ding <dingyifeiair@gmail.com>2022-11-19 06:58:24 -0800
committerGitHub <noreply@github.com>2022-11-19 09:58:24 -0500
commitd17ef95a3c940b674bbda91573066f20200c902d (patch)
tree3154e56892cfc299968ccd1644f3dd8aca913e32 /klippy
parent8a06528747674ff06d922ba3231b080deda8d1ab (diff)
downloadkutter-d17ef95a3c940b674bbda91573066f20200c902d.tar.gz
kutter-d17ef95a3c940b674bbda91573066f20200c902d.tar.xz
kutter-d17ef95a3c940b674bbda91573066f20200c902d.zip
mpu9250: add MPU6500 (#5767)
Signed-off-by: Yifei Ding <yifeiding@protonmail.com>
Diffstat (limited to 'klippy')
-rw-r--r--klippy/extras/mpu9250.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/klippy/extras/mpu9250.py b/klippy/extras/mpu9250.py
index c588eaf0..419207fc 100644
--- a/klippy/extras/mpu9250.py
+++ b/klippy/extras/mpu9250.py
@@ -9,8 +9,16 @@ from . import bus, motion_report, adxl345
MPU9250_ADDR = 0x68
-MPU9250_DEV_ID = 0x73
-MPU6050_DEV_ID = 0x68
+MPU_DEV_IDS = {
+ 0x74: "mpu-9515",
+ 0x73: "mpu-9255",
+ 0x71: "mpu-9250",
+ 0x70: "mpu-6500",
+ 0x68: "mpu-6050",
+ #everything above are normal MPU IDs
+ 0x75: "mpu-unknown (DEFECTIVE! USE WITH CAUTION!)",
+ 0x69: "mpu-unknown (DEFECTIVE! USE WITH CAUTION!)",
+ }
# MPU9250 registers
REG_DEVID = 0x75
@@ -189,12 +197,14 @@ class MPU9250:
# In case of miswiring, testing MPU9250 device ID prevents treating
# noise or wrong signal as a correctly initialized device
dev_id = self.read_reg(REG_DEVID)
- if dev_id != MPU9250_DEV_ID and dev_id != MPU6050_DEV_ID:
+ if dev_id not in MPU_DEV_IDS.keys():
raise self.printer.command_error(
- "Invalid mpu9250/mpu6050 id (got %x).\n"
+ "Invalid mpu id (got %x).\n"
"This is generally indicative of connection problems\n"
"(e.g. faulty wiring) or a faulty chip."
% (dev_id))
+ else:
+ logging.info("Found %s with id %x"% (MPU_DEV_IDS[dev_id], dev_id))
# Setup chip in requested query rate
self.set_reg(REG_PWR_MGMT_1, SET_PWR_MGMT_1_WAKE)
self.set_reg(REG_PWR_MGMT_2, SET_PWR_MGMT_2_ACCEL_ON)