altos: Get telemini to copy current MS5607 state to ring.
authorKeith Packard <keithp@keithp.com>
Tue, 27 Aug 2013 00:15:55 +0000 (17:15 -0700)
committerKeith Packard <keithp@keithp.com>
Tue, 27 Aug 2013 00:15:55 +0000 (17:15 -0700)
The ADC code is responsible for actually inserting the non-ADC data
into the ring, so do the copy there.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/cc1111/ao_adc.c
src/telemini-v2.0/ao_pins.h

index 1523f94a278056dcf3e59ab54248c560752529a6..97a39c4d92a6f66a545253fc5e20a18c7286b32a 100644 (file)
@@ -164,7 +164,7 @@ ao_adc_isr(void) __interrupt 1
 #endif 
 
 #ifdef FETCH_ADC
 #endif 
 
 #ifdef FETCH_ADC
-       FETCH_ADC()
+       FETCH_ADC();
 #define GOT_ADC
 #endif
 
 #define GOT_ADC
 #endif
 
index fac6c535e60176aab569885a7970f7024be858bc..c1a36f8c0c0bd4852fec2351722468f87f5a6607 100644 (file)
@@ -128,26 +128,32 @@ struct ao_adc {
 
 #define AO_ADC_PINS    ((1 << 0) | (1 << 1) | (1 << 4))
 
 
 #define AO_ADC_PINS    ((1 << 0) | (1 << 1) | (1 << 4))
 
-#define FETCH_ADC()                                                    \
-       a = (uint8_t __xdata *) (&ao_data_ring[ao_data_head].adc);      \
-       switch (sequence) {                                             \
-       case 4:                                                         \
-               a += 4;                                                 \
-               sequence = 0;                                           \
-               break;                                                  \
-       case 1:                                                         \
-               a += 2;                                                 \
-               sequence = 4;                                           \
-               break;                                                  \
-       case 0:                                                         \
-               sequence = 1;                                           \
-               break;                                                  \
-       }                                                               \
-       a[0] = ADCL;                                                    \
-       a[1] = ADCH;                                                    \
-       if (sequence) {                                                 \
-               ADCCON3 = ADCCON3_EREF_VDD | ADCCON3_EDIV_512 | sequence; \
-               return;                                                 \
-       }
+#define FETCH_ADC() do {                                               \
+               a = (uint8_t __xdata *) (&ao_data_ring[ao_data_head].adc); \
+               switch (sequence) {                                     \
+               case 4:                                                 \
+                       a += 4;                                         \
+                       sequence = 0;                                   \
+                       break;                                          \
+               case 1:                                                 \
+                       a += 2;                                         \
+                       sequence = 4;                                   \
+                       break;                                          \
+               case 0:                                                 \
+                       sequence = 1;                                   \
+                       break;                                          \
+               }                                                       \
+               a[0] = ADCL;                                            \
+               a[1] = ADCH;                                            \
+               if (sequence) {                                         \
+                       ADCCON3 = ADCCON3_EREF_VDD | ADCCON3_EDIV_512 | sequence; \
+                       return;                                         \
+               }                                                       \
+               AO_DATA_PRESENT(AO_DATA_ADC);                           \
+               if (ao_data_present != AO_DATA_ALL)                     \
+                       return;                                         \
+               ao_data_ring[ao_data_head].ms5607_raw.pres = ao_ms5607_current.pres; \
+               ao_data_ring[ao_data_head].ms5607_raw.temp = ao_ms5607_current.temp; \
+       } while (0)
 
 #endif /* _AO_PINS_H_ */
 
 #endif /* _AO_PINS_H_ */