Fix a bad interrupt state in the PIC32 IDLE loop when the work queue is enabled
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4805 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
1a2fce33e3
commit
cb4999caa8
@ -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.
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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:
|
||||
*
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user