aboutsummaryrefslogtreecommitdiff
path: root/apps/systemcmds
diff options
context:
space:
mode:
authorpx4dev <px4@purgatory.org>2013-01-18 00:43:57 -0800
committerpx4dev <px4@purgatory.org>2013-01-18 00:43:57 -0800
commitbc35bb23dd8cb035c080f8ef8b4cd7a30d5184c2 (patch)
treec84795237631635d6441c9a6d68f5e18527fee75 /apps/systemcmds
parent7d7c352fb44b718cb96096a624a19b5225e39f92 (diff)
downloadpx4-firmware-bc35bb23dd8cb035c080f8ef8b4cd7a30d5184c2.tar.gz
px4-firmware-bc35bb23dd8cb035c080f8ef8b4cd7a30d5184c2.tar.bz2
px4-firmware-bc35bb23dd8cb035c080f8ef8b4cd7a30d5184c2.zip
HOTFIX: disable interrupt-driven I2C mode, configure pessimistic I2C timeout, correct handling of the NAK generation for I2C master reads.
This looks like it addresses the recent I2C lockup issue, unfortunately it also increases CPU consumption by ~5% for the I2C sensor bus.
Diffstat (limited to 'apps/systemcmds')
-rw-r--r--apps/systemcmds/eeprom/24xxxx_mtd.c27
-rw-r--r--apps/systemcmds/eeprom/eeprom.c13
2 files changed, 40 insertions, 0 deletions
diff --git a/apps/systemcmds/eeprom/24xxxx_mtd.c b/apps/systemcmds/eeprom/24xxxx_mtd.c
index 781b01065..e34be44e3 100644
--- a/apps/systemcmds/eeprom/24xxxx_mtd.c
+++ b/apps/systemcmds/eeprom/24xxxx_mtd.c
@@ -163,6 +163,8 @@ static ssize_t at24c_bwrite(FAR struct mtd_dev_s *dev, off_t startblock,
size_t nblocks, FAR const uint8_t *buf);
static int at24c_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg);
+void at24c_test(void);
+
/************************************************************************************
* Private Data
************************************************************************************/
@@ -219,6 +221,31 @@ static int at24c_erase(FAR struct mtd_dev_s *dev, off_t startblock, size_t nbloc
}
/************************************************************************************
+ * Name: at24c_test
+ ************************************************************************************/
+
+void at24c_test(void)
+{
+ uint8_t buf[CONFIG_AT24XX_MTD_BLOCKSIZE];
+ unsigned count = 0;
+ unsigned errors = 0;
+
+ for (count = 0; count < 10000; count++) {
+ ssize_t result = at24c_bread(&g_at24c.mtd, 0, 1, buf);
+ if (result == ERROR) {
+ if (errors++ > 2) {
+ vdbg("too many errors\n");
+ return;
+ }
+ } else if (result != 1) {
+ vdbg("unexpected %u\n", result);
+ }
+ if ((count % 100) == 0)
+ vdbg("test %u errors %u\n", count, errors);
+ }
+}
+
+/************************************************************************************
* Name: at24c_bread
************************************************************************************/
diff --git a/apps/systemcmds/eeprom/eeprom.c b/apps/systemcmds/eeprom/eeprom.c
index b4257cda9..49da51358 100644
--- a/apps/systemcmds/eeprom/eeprom.c
+++ b/apps/systemcmds/eeprom/eeprom.c
@@ -73,6 +73,7 @@ static void eeprom_erase(void);
static void eeprom_ioctl(unsigned operation);
static void eeprom_save(const char *name);
static void eeprom_load(const char *name);
+static void eeprom_test(void);
static bool attached = false;
static bool started = false;
@@ -93,6 +94,9 @@ int eeprom_main(int argc, char *argv[])
if (!strcmp(argv[1], "erase"))
eeprom_erase();
+ if (!strcmp(argv[1], "test"))
+ eeprom_test();
+
if (0) { /* these actually require a file on the filesystem... */
if (!strcmp(argv[1], "reformat"))
@@ -250,3 +254,12 @@ eeprom_load(const char *name)
exit(0);
}
+
+extern void at24c_test(void);
+
+static void
+eeprom_test(void)
+{
+ at24c_test();
+ exit(0);
+}