altos/lpc: Pull ADC data from the correct registers
authorKeith Packard <keithp@keithp.com>
Mon, 20 May 2013 03:07:52 +0000 (20:07 -0700)
committerKeith Packard <keithp@keithp.com>
Mon, 20 May 2013 03:39:18 +0000 (20:39 -0700)
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>
src/lpc/ao_adc_lpc.c

index 70e8b2d68e6663d4b0b66e1a1d79d684713a6b51..9ecc7c13f1e313d572d98e1bad45d4eb4aefcbd0 100644 (file)
@@ -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);