diff options
author | Timofey Titovets <nefelim4ag@gmail.com> | 2024-09-13 22:02:05 +0200 |
---|---|---|
committer | KevinOConnor <kevin@koconnor.net> | 2024-10-26 22:06:30 -0400 |
commit | 08a85ba869c3232ca7063c737c238ca41e20885e (patch) | |
tree | 85f6db1bf9f85a6957bacd525ec336e58408fe0d /src/sensor_mpu9250.c | |
parent | 39f08aeda184c5dcf257f88f66b3173f9593f1b7 (diff) | |
download | kutter-08a85ba869c3232ca7063c737c238ca41e20885e.tar.gz kutter-08a85ba869c3232ca7063c737c238ca41e20885e.tar.xz kutter-08a85ba869c3232ca7063c737c238ca41e20885e.zip |
i2ccmds: abstract i2c dev from bus implementation
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>
Diffstat (limited to 'src/sensor_mpu9250.c')
-rw-r--r-- | src/sensor_mpu9250.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/sensor_mpu9250.c b/src/sensor_mpu9250.c index 23c02921..ee04e922 100644 --- a/src/sensor_mpu9250.c +++ b/src/sensor_mpu9250.c @@ -13,7 +13,6 @@ #include "command.h" // DECL_COMMAND #include "sched.h" // DECL_TASK #include "sensor_bulk.h" // sensor_bulk_report -#include "board/gpio.h" // i2c_read #include "i2ccmds.h" // i2cdev_oid_lookup // Chip registers @@ -77,7 +76,7 @@ get_fifo_status(struct mpu9250 *mp) { uint8_t reg[] = {AR_FIFO_COUNT_H}; uint8_t msg[2]; - i2c_read(mp->i2c->i2c_config, sizeof(reg), reg, sizeof(msg), msg); + i2c_dev_read(mp->i2c, sizeof(reg), reg, sizeof(msg), msg); uint16_t fifo_bytes = ((msg[0] & 0x1f) << 8) | msg[1]; if (fifo_bytes > mp->fifo_max) mp->fifo_max = fifo_bytes; @@ -95,7 +94,7 @@ mp9250_query(struct mpu9250 *mp, uint8_t oid) // If we have enough bytes to fill the buffer do it and send report if (mp->fifo_pkts_bytes >= BYTES_PER_BLOCK) { uint8_t reg = AR_FIFO; - i2c_read(mp->i2c->i2c_config, sizeof(reg), ® + i2c_dev_read(mp->i2c, sizeof(reg), ® , BYTES_PER_BLOCK, &mp->sb.data[0]); mp->sb.data_count = BYTES_PER_BLOCK; mp->fifo_pkts_bytes -= BYTES_PER_BLOCK; @@ -144,7 +143,7 @@ command_query_mpu9250_status(uint32_t *args) // Detect if a FIFO overrun occurred uint8_t int_reg[] = {AR_INT_STATUS}; uint8_t int_msg; - i2c_read(mp->i2c->i2c_config, sizeof(int_reg), int_reg, sizeof(int_msg), + i2c_dev_read(mp->i2c, sizeof(int_reg), int_reg, sizeof(int_msg), &int_msg); if (int_msg & FIFO_OVERFLOW_INT) mp->sb.possible_overflows++; @@ -153,7 +152,7 @@ command_query_mpu9250_status(uint32_t *args) uint8_t reg[] = {AR_FIFO_COUNT_H}; uint8_t msg[2]; uint32_t time1 = timer_read_time(); - i2c_read(mp->i2c->i2c_config, sizeof(reg), reg, sizeof(msg), msg); + i2c_dev_read(mp->i2c, sizeof(reg), reg, sizeof(msg), msg); uint32_t time2 = timer_read_time(); uint16_t fifo_bytes = ((msg[0] & 0x1f) << 8) | msg[1]; |