From 65ad2caf8a4cc7797a24317e45ac5f6449c2dad3 Mon Sep 17 00:00:00 2001 From: stac Date: Wed, 15 Sep 2010 14:20:53 +0000 Subject: [PATCH] i2c: Make transaction initiator available in txn list The info field in the pios_i2c_txn list can now be used to provide a const string which describes the context for this transaction. This is very helpful when diagnosing an error that occurs somewhere in the middle of the I2C FSM since the FSM runs primarily in the ISR where the original context for the transactions is no longer available in the traceback. git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1622 ebee16cc-31ac-478f-84a7-5cbb03baadba --- flight/PiOS/Common/pios_bmp085.c | 3 +++ flight/PiOS/Common/pios_hmc5843.c | 3 +++ flight/PiOS/inc/pios_i2c.h | 1 + 3 files changed, 7 insertions(+) diff --git a/flight/PiOS/Common/pios_bmp085.c b/flight/PiOS/Common/pios_bmp085.c index aecf8ab37..2b829ba9d 100644 --- a/flight/PiOS/Common/pios_bmp085.c +++ b/flight/PiOS/Common/pios_bmp085.c @@ -204,12 +204,14 @@ bool PIOS_BMP085_Read(uint8_t address, uint8_t *buffer, uint8_t len) const struct pios_i2c_txn txn_list[] = { { + .info = __func__, .addr = BMP085_I2C_ADDR, .rw = PIOS_I2C_TXN_WRITE, .len = sizeof(addr_buffer), .buf = addr_buffer, }, { + .info = __func__, .addr = BMP085_I2C_ADDR, .rw = PIOS_I2C_TXN_READ, .len = len, @@ -238,6 +240,7 @@ bool PIOS_BMP085_Write(uint8_t address, uint8_t buffer) const struct pios_i2c_txn txn_list[] = { { + .info = __func__, .addr = BMP085_I2C_ADDR, .rw = PIOS_I2C_TXN_WRITE, .len = sizeof(data), diff --git a/flight/PiOS/Common/pios_hmc5843.c b/flight/PiOS/Common/pios_hmc5843.c index a66adf8eb..3ce0d06b8 100644 --- a/flight/PiOS/Common/pios_hmc5843.c +++ b/flight/PiOS/Common/pios_hmc5843.c @@ -214,12 +214,14 @@ bool PIOS_HMC5843_Read(uint8_t address, uint8_t *buffer, uint8_t len) const struct pios_i2c_txn txn_list[] = { { + .info = __func__, .addr = PIOS_HMC5843_I2C_ADDR, .rw = PIOS_I2C_TXN_WRITE, .len = sizeof(addr_buffer), .buf = addr_buffer, }, { + .info = __func__, .addr = PIOS_HMC5843_I2C_ADDR, .rw = PIOS_I2C_TXN_READ, .len = len, @@ -247,6 +249,7 @@ bool PIOS_HMC5843_Write(uint8_t address, uint8_t buffer) const struct pios_i2c_txn txn_list[] = { { + .info = __func__, .addr = PIOS_HMC5843_I2C_ADDR, .rw = PIOS_I2C_TXN_WRITE, .len = sizeof(data), diff --git a/flight/PiOS/inc/pios_i2c.h b/flight/PiOS/inc/pios_i2c.h index 51b3cdecc..f2109ef49 100644 --- a/flight/PiOS/inc/pios_i2c.h +++ b/flight/PiOS/inc/pios_i2c.h @@ -40,6 +40,7 @@ enum pios_i2c_txn_direction { }; struct pios_i2c_txn { + const char * info; uint16_t addr; enum pios_i2c_txn_direction rw; uint32_t len;