aboutsummaryrefslogtreecommitdiff
path: root/apps/px4io/px4io.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2013-01-27 11:06:13 +1100
committerLorenz Meier <lm@inf.ethz.ch>2013-02-14 23:06:52 +0100
commit6eb69b07a8fd44fff1bfcf77bf4622f4dd044eef (patch)
treedae8be8b3b90dd58bc5f9d3f62981519a72709b7 /apps/px4io/px4io.c
parentbfecfbf5eef422e0ee069a17ff2482b352e29386 (diff)
downloadpx4-firmware-6eb69b07a8fd44fff1bfcf77bf4622f4dd044eef.tar.gz
px4-firmware-6eb69b07a8fd44fff1bfcf77bf4622f4dd044eef.tar.bz2
px4-firmware-6eb69b07a8fd44fff1bfcf77bf4622f4dd044eef.zip
Merged debug level commits from Tridge
Diffstat (limited to 'apps/px4io/px4io.c')
-rw-r--r--apps/px4io/px4io.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/apps/px4io/px4io.c b/apps/px4io/px4io.c
index 8e0e52f04..b7e6ccb21 100644
--- a/apps/px4io/px4io.c
+++ b/apps/px4io/px4io.c
@@ -63,11 +63,12 @@ struct sys_state_s system_state;
static struct hrt_call serial_dma_call;
-// global debug level for isr_debug()
+/* global debug level for isr_debug() */
volatile uint8_t debug_level = 0;
-volatile uint32_t i2c_resets = 0;
volatile uint32_t i2c_loop_resets = 0;
+struct hrt_call loop_overtime_call;
+
/*
a set of debug buffers to allow us to send debug information from ISRs
@@ -111,6 +112,19 @@ static void show_debug_messages(void)
}
}
+/*
+ catch I2C lockups
+ */
+static void loop_overtime(void *arg)
+{
+ debug("RESETTING\n");
+ i2c_loop_resets++;
+ i2c_dump();
+ i2c_reset();
+ hrt_call_after(&loop_overtime_call, 50000, (hrt_callout)loop_overtime, NULL);
+}
+
+
int user_start(int argc, char *argv[])
{
/* run C++ ctors before we go any further */
@@ -152,7 +166,6 @@ int user_start(int argc, char *argv[])
(main_t)controls_main,
NULL);
-
struct mallinfo minfo = mallinfo();
debug("free %u largest %u\n", minfo.mxordblk, minfo.fordblks);
@@ -168,6 +181,11 @@ int user_start(int argc, char *argv[])
/* XXX we should use CONFIG_IDLE_CUSTOM and take over the idle thread instead of running two additional tasks */
uint8_t counter=0;
for (;;) {
+ /*
+ if we are not scheduled for 100ms then reset the I2C bus
+ */
+ hrt_call_after(&loop_overtime_call, 100000, (hrt_callout)loop_overtime, NULL);
+
poll(NULL, 0, 10);
perf_begin(mixer_perf);
mixer_tick();
@@ -175,10 +193,9 @@ int user_start(int argc, char *argv[])
show_debug_messages();
if (counter++ == 200) {
counter = 0;
- isr_debug(0, "tick debug=%u status=0x%x resets=%u loop_resets=%u",
+ isr_debug(1, "tick debug=%u status=0x%x resets=%u",
(unsigned)debug_level,
(unsigned)r_status_flags,
- (unsigned)i2c_resets,
(unsigned)i2c_loop_resets);
}
}