summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2013-05-19 20:07:52 -0700
committerKeith Packard <keithp@keithp.com>2013-05-19 20:39:18 -0700
commitd51c9fda3478f205e4bcdf1b7bf21eb1e0a516bc (patch)
tree47244c49f505ba711af16e1f434027e2884096b8
parent6343bd774f542a4f915cf1fca2053d03e93bf2c3 (diff)
altos/lpc: Pull ADC data from the correct registers
Was just stepping through register space arbitrarily, which would have worked for EasyMini, but might have failed later if the ADC pin usage wasn't consecutive. Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--src/lpc/ao_adc_lpc.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/lpc/ao_adc_lpc.c b/src/lpc/ao_adc_lpc.c
index 70e8b2d6..9ecc7c13 100644
--- a/src/lpc/ao_adc_lpc.c
+++ b/src/lpc/ao_adc_lpc.c
@@ -86,34 +86,38 @@ static uint8_t ao_adc_ready;
void lpc_adc_isr(void)
{
+ uint32_t stat = lpc_adc.stat;
uint16_t *out = (uint16_t *) &ao_data_ring[ao_data_head].adc;
vuint32_t *in = &lpc_adc.dr[0];
+ lpc_adc.cr = 0;
+ lpc_adc.stat = 0;
+
/* Store converted values in packet */
#if AO_ADC_0
- *out++ = ((uint16_t) *in++) >> 1;
+ *out++ = lpc_adc.dr[0] >> 1;
#endif
#if AO_ADC_1
- *out++ = ((uint16_t) *in++) >> 1;
+ *out++ = lpc_adc.dr[1] >> 1;
#endif
#if AO_ADC_2
- *out++ = ((uint16_t) *in++) >> 1;
+ *out++ = lpc_adc.dr[2] >> 1;
#endif
#if AO_ADC_3
- *out++ = ((uint16_t) *in++) >> 1;
+ *out++ = lpc_adc.dr[3] >> 1;
#endif
#if AO_ADC_4
- *out++ = ((uint16_t) *in++) >> 1;
+ *out++ = lpc_adc.dr[4] >> 1;
#endif
#if AO_ADC_5
- *out++ = ((uint16_t) *in++) >> 1;
+ *out++ = lpc_adc.dr[5] >> 1;
#endif
#if AO_ADC_6
- *out++ = ((uint16_t) *in++) >> 1;
+ *out++ = lpc_adc.dr[6] >> 1;
#endif
#if AO_ADC_7
- *out++ = ((uint16_t) *in++) >> 1;
+ *out++ = lpc_adc.dr[7] >> 1;
#endif
AO_DATA_PRESENT(AO_DATA_ADC);