41 #include "lib/sensors.h"
43 #define ADC12MCTL_NO(adcno) ((unsigned char *) ADC12MCTL0_)[adcno]
45 static uint16_t adc_on;
46 static uint16_t ready;
60 ADC12CTL0 = REF2_5V + SHT0_6 + SHT1_6 + MSC + REFON;
62 ADC12CTL1 = SHP + CONSEQ_3;
65 for(c = 0; c < 16; c++) {
67 ADC12MCTL_NO(c) &= ~EOS;
68 if(adc_on & (1 << c)) {
71 ADC12CTL1 |= (c * CSTARTADD_1);
78 ADC12MCTL_NO(last) |= EOS;
92 ADC12CTL1 &= ~CONSEQ_3;
95 while(ADC12CTL1 & ADC12BUSY);
102 sky_sensors_status(uint16_t input,
int type)
104 if(type == SENSORS_ACTIVE) {
105 return (adc_on & input) == input;
107 if(type == SENSORS_READY) {
108 ready |= ADC12IFG & adc_on & input;
109 return (ready & adc_on & input) == input;
115 sky_sensors_configure(uint16_t input, uint8_t ref,
int type,
int value)
119 if(type == SENSORS_ACTIVE) {
124 P6SEL |= input & 0xff;
127 for(c = 0; c < 16; c++) {
128 if(input & (1 << c)) {
129 ADC12MCTL_NO(c) = (c * INCH_1) | ref;
136 P6SEL &= ~(input & 0xff);