summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2012-06-06 01:44:57 +0000
committerpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2012-06-06 01:44:57 +0000
commitc74aee1fd199a074945059542297ed82dc2df3db (patch)
treee47988218982531e9c9d129ce3170d7efe1a3534
parent9c344d90362db4b1a8b36e0678242af0298b1e1e (diff)
Fix a bad interrupt state in the PIC32 IDLE loop when the work queue is enabled
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4805 7fd9a85b-ad96-42d3-883c-3090e2eb8679
-rw-r--r--nuttx/ChangeLog6
-rw-r--r--nuttx/arch/mips/src/common/up_idle.c24
-rw-r--r--nuttx/arch/mips/src/mips32/up_initialstate.c2
-rw-r--r--nuttx/arch/mips/src/mips32/up_irq.c2
-rw-r--r--nuttx/configs/pic32mx7mmb/README.txt3
-rw-r--r--nuttx/configs/pic32mx7mmb/src/up_touchscreen.c10
-rw-r--r--nuttx/mm/mm_sem.c4
-rw-r--r--nuttx/sched/os_bringup.c2
-rw-r--r--nuttx/sched/sched_free.c2
-rw-r--r--nuttx/sched/work_thread.c2
10 files changed, 42 insertions, 15 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog
index a4d1a472e7..25f29319d2 100644
--- a/nuttx/ChangeLog
+++ b/nuttx/ChangeLog
@@ -2890,3 +2890,9 @@
LCD on the PIC32MX7 MMB board.
* configs/pic32mx7mmb/src/up_touchscreen.c: Add an ACD-based touchscreen
driver for the PIC32MX7 MMB board.
+ * arch/mips/src/common/up_idle.c: Strange but important fix. For some still-
+ unknown reason, interrupts are left in an unhealthy state in the IDLE
+ when the work queue is enabled. This is partially because some interrupt
+ related logic is not built in that case. Simply disabling then re-
+ enabling interrupts restores the proper state.
+
diff --git a/nuttx/arch/mips/src/common/up_idle.c b/nuttx/arch/mips/src/common/up_idle.c
index 239aa3c308..4e2cc542be 100644
--- a/nuttx/arch/mips/src/common/up_idle.c
+++ b/nuttx/arch/mips/src/common/up_idle.c
@@ -1,8 +1,8 @@
/****************************************************************************
* arch/mips/src/common/up_idle.c
*
- * Copyright (C) 2011 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ * Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -81,9 +81,27 @@ void up_idle(void)
sched_process_timer();
#else
- /* This would be an appropriate place to put some MCU-specific logig to
+ /* This would be an appropriate place to put some MCU-specific logic to
* sleep in a reduced power mode until an interrupt occurs to save power
*/
+
+ /* This is a kludge that I still don't understand. The call to kmm_trysemaphore()
+ * in the os_start.c IDLE loop seems necessary for the good health of the IDLE
+ * loop. When the work queue is enabled, this logic is removed from the IDLE
+ * loop and it appears that we are somehow left idling with interrupts non-
+ * functional. The following should be no-op, it just disables then re-enables
+ * interrupts. But it fixes the problem and will stay here until I understand
+ * the problem/fix better.
+ *
+ * And no, the contents of the CP0 status register are not incorrect. But for
+ * some reason the status register needs to be re-written again on this thread
+ * for it to take effect. This might be a PIC32-only issue?
+ */
+
+#ifdef CONFIG_SCHED_WORKQUEUE
+ irqstate_t flags = irqsave();
+ irqrestore(flags);
+#endif
#endif
}
diff --git a/nuttx/arch/mips/src/mips32/up_initialstate.c b/nuttx/arch/mips/src/mips32/up_initialstate.c
index cc0cd227e1..0c24d1ee03 100644
--- a/nuttx/arch/mips/src/mips32/up_initialstate.c
+++ b/nuttx/arch/mips/src/mips32/up_initialstate.c
@@ -2,7 +2,7 @@
* arch/mips/src/mips32/up_initialstate.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ * Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/nuttx/arch/mips/src/mips32/up_irq.c b/nuttx/arch/mips/src/mips32/up_irq.c
index 80ab7f78af..b13ae6294e 100644
--- a/nuttx/arch/mips/src/mips32/up_irq.c
+++ b/nuttx/arch/mips/src/mips32/up_irq.c
@@ -2,7 +2,7 @@
* arch/mips/src/mips32/up_irq.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ * Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/nuttx/configs/pic32mx7mmb/README.txt b/nuttx/configs/pic32mx7mmb/README.txt
index e20c1f6766..e94c143b4a 100644
--- a/nuttx/configs/pic32mx7mmb/README.txt
+++ b/nuttx/configs/pic32mx7mmb/README.txt
@@ -767,7 +767,8 @@ Where <subdir> is one of the following:
In defconfig (or nuttx/.config), set:
- CONFIG_INPUT=y
+ CONFIG_INPUT=y : Enable input device support
+ CONFIG_SCHED_WORKQUEUE=y : Work queue support needed
In appconfig (or apps/.config), uncomment:
diff --git a/nuttx/configs/pic32mx7mmb/src/up_touchscreen.c b/nuttx/configs/pic32mx7mmb/src/up_touchscreen.c
index 97d0270c59..2cffbe93ef 100644
--- a/nuttx/configs/pic32mx7mmb/src/up_touchscreen.c
+++ b/nuttx/configs/pic32mx7mmb/src/up_touchscreen.c
@@ -187,7 +187,7 @@ struct tc_dev_s
uint8_t nwaiters; /* Number of threads waiting for touchscreen data */
uint8_t id; /* Current touch point ID */
volatile bool penchange; /* An unreported event is buffered */
- uint16_t value; /* Partial sample value */
+ uint16_t value; /* Partial sample value (Y+ or X-) */
uint16_t newy; /* New, un-thresholded Y value */
sem_t devsem; /* Manages exclusive access to this structure */
sem_t waitsem; /* Used to wait for the availability of data */
@@ -733,6 +733,7 @@ static void tc_worker(FAR void *arg)
value = MAX_ADC - tc_adc_convert();
priv->newy = (value + priv->value) >> 1;
+ ivdbg("Y-=%d Y+=%d Y=%d\n", priv->value, value, priv->newy);
/* Start X+ sampling */
@@ -751,7 +752,7 @@ static void tc_worker(FAR void *arg)
case TC_XPSAMPLE:
{
- /* Convert and save the Y- sample value */
+ /* Convert and save the X+ sample value */
priv->value = tc_adc_convert();
@@ -772,10 +773,11 @@ static void tc_worker(FAR void *arg)
case TC_XMSAMPLE: /* Allowing time for the X- sampling */
{
- /* Read and calculate the Y+ axis position */
+ /* Read and calculate the X- axis position */
value = MAX_ADC - tc_adc_convert();
newx = (value + priv->value) >> 1;
+ ivdbg("X+=%d X-=%d Y=%d\n", priv->value, value, newx);
/* Samples are available */
@@ -1067,7 +1069,7 @@ static ssize_t tc_read(FAR struct file *filep, FAR char *buffer, size_t len)
report = (FAR struct touch_sample_s *)buffer;
memset(report, 0, SIZEOF_TOUCH_SAMPLE_S(1));
report->npoints = 1;
- report->point[0].id = priv->id;
+ report->point[0].id = sample.id;
report->point[0].x = sample.x;
report->point[0].y = sample.y;
diff --git a/nuttx/mm/mm_sem.c b/nuttx/mm/mm_sem.c
index 4b7563c0b5..a2d9d5cd1b 100644
--- a/nuttx/mm/mm_sem.c
+++ b/nuttx/mm/mm_sem.c
@@ -2,7 +2,7 @@
* mm/mm_sem.c
*
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ * Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -129,7 +129,7 @@ int mm_trysemaphore(void)
}
else
{
- /* Try to tak the semaphore (perhaps waiting) */
+ /* Try to take the semaphore (perhaps waiting) */
if (sem_trywait(&g_mm_semaphore) != 0)
{
diff --git a/nuttx/sched/os_bringup.c b/nuttx/sched/os_bringup.c
index eb1875a69a..646f491583 100644
--- a/nuttx/sched/os_bringup.c
+++ b/nuttx/sched/os_bringup.c
@@ -2,7 +2,7 @@
* sched/os_bringup.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ * Author: Gregory Nutt <gnutt@nuttx.org>
*
* With extensions by:
*
diff --git a/nuttx/sched/sched_free.c b/nuttx/sched/sched_free.c
index 2bdf9670ed..e7c8bf56b0 100644
--- a/nuttx/sched/sched_free.c
+++ b/nuttx/sched/sched_free.c
@@ -2,7 +2,7 @@
* sched/sched_free.c
*
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ * Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/nuttx/sched/work_thread.c b/nuttx/sched/work_thread.c
index a0e0d78e98..fe14ae5e58 100644
--- a/nuttx/sched/work_thread.c
+++ b/nuttx/sched/work_thread.c
@@ -2,7 +2,7 @@
* sched/work_thread.c
*
* Copyright (C) 2009-2011 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ * Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions