From 68bed71ba990ade28739716d9faba86b47a451a7 Mon Sep 17 00:00:00 2001 From: patacongo Date: Wed, 6 Jun 2012 01:44:57 +0000 Subject: [PATCH] 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 --- configs/pic32mx7mmb/README.txt | 3 ++- configs/pic32mx7mmb/src/up_touchscreen.c | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/configs/pic32mx7mmb/README.txt b/configs/pic32mx7mmb/README.txt index e20c1f6766..e94c143b4a 100644 --- a/configs/pic32mx7mmb/README.txt +++ b/configs/pic32mx7mmb/README.txt @@ -767,7 +767,8 @@ Where 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/configs/pic32mx7mmb/src/up_touchscreen.c b/configs/pic32mx7mmb/src/up_touchscreen.c index 97d0270c59..2cffbe93ef 100644 --- a/configs/pic32mx7mmb/src/up_touchscreen.c +++ b/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;