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>
This commit is contained in:
committed by
KevinOConnor
parent
39f08aeda1
commit
08a85ba869
@@ -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];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user