aboutsummaryrefslogtreecommitdiffstats
path: root/src/sensor_mpu9250.c
Commit message (Collapse)AuthorAgeFilesLines
* mpu: shutdown on i2c errorsTimofey Titovets2024-10-261-6/+12
| | | | Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
* i2ccmds: abstract i2c dev from bus implementationTimofey Titovets2024-10-261-5/+4
| | | | | | | | Added wrapper around sw/hw bus API, pins.py code will ensure that pins will not mix between HW/SW buses. Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
* sensor_mpu9250: No need to schedule start of bulk readingKevin O'Connor2024-01-191-98/+27
| | | | | | It's simpler and faster to enable the mpu9250 in the python code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sensor_bulk: New C file with helper code for sending bulk sensor measurementsKevin O'Connor2024-01-191-34/+10
| | | | | | | | | | Refactor the low-level "bulk sensor" management code in the mcu. This updates the sensor_adxl345.c, sensor_mpu9250.c, sensor_lis2dw.c, and sensor_angle.c code to use the same "bulk sensor" messages. All of these sensors will now send "sensor_bulk_data" and "sensor_bulk_status" messages. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sensor_mpu9250: No need to send messages when stopping queriesKevin O'Connor2024-01-191-9/+0
| | | | | | Simplify the mcu code as any messages are ignored by the host anyway. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sensor_mpu9250: Check for overflows on each query_mpu9250_status commandKevin O'Connor2024-01-071-10/+12
| | | | | | | | | | | | Move overflow detection from mp9250_stop() to command_query_mpu9250_status(). Currently the host ignores any contents returned from a stop request, so overflow reporting at that point has limited utility. In practice, this change will result in one additional i2c transaction to the mpu9250 device every 100ms. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sensor_mpu9250: Simplify mp9250_query()Kevin O'Connor2024-01-071-14/+10
| | | | | | | | The mpu9250 code always reads from the sensor in 48 byte chunks and always sends an mpu9250_data message immediately after that. Make that more clear in the querying code. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sensor_mpu9250: Fix timing in command_query_mpu9250_status()Kevin O'Connor2024-01-071-8/+9
| | | | | | | | | | | | Commit 80a7744b optimized the fifo tracking code. However, it introduced an error in the time tracking in command_query_mpu9250_status(). The purpose of that function is to provide a precise timestamp of the total number of messages produced at the time of that call. Thus, the returned fifo value needs to be the fifo level in the chip at the time of the call (not the value read during previous checks). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* sensor_mpu9250: Fix or improve reliability (#6170)Dr. Matthew Swabey2023-04-191-48/+54
| | | | | | | | | | | | | | | | | | | Fixes common MPU-9250 accelerometer issues for RPi Linux MCU and improves reliability on all other architectures by adjusting the MPU-* reading algorithm to only read whole Klipper messages' worth of data from MPU-* and eliminating many unnecessary checks of the MPU FIFO fill-level that consumed bus bandwidth needed for data transfer. Fixes intermittent "Lost communication with MCU 'rpi'" due to "Timer too close" and transposed / corrupted data due to FIFO overrun/data loss when using MPU-* accelerometers. In addition FIFO overrun checks are performed by testing the MPU interrupt flag vs. inferring from the FIFO fill level. Stress tested for 13hrs with two MPU-6500 attached to one I2C bus on RPi and one on a PR2040 Stress tested for 23hrs with two MPU-6500 attached to one I2C bus on RPi and one on a ATmega328P (Seeduino Nano) Signed-off-by: Matthew Swabey <matthew@swabey.org>
* mpu9250: Adding support for MPU-9250 (and MPU-6050) accelerometerbluesforte2022-06-161-0/+277
Add support for mpu9250 accelerometer over I2C bus. Signed-off-by: Harry Beyel <harry3b9@gmail.com>