void get_temperature(void) { uint16_t q_temp; adc10_read(10, &q_temp, REFVSEL_0); adc10_halt(); s.int_temp = (int8_t) calc_temp(q_temp); }
void adc_read() { uint16_t q_bat = 0, q_raw = 0; uint32_t v_bat, v_raw; adc10_read(3, &q_bat, REFVSEL_1); adc10_read(2, &q_raw, REFVSEL_1); v_bat = (uint32_t) q_bat *s.vref * DIV_BAT / 10000; v_raw = (uint32_t) q_raw *s.vref * DIV_RAW / 10000; stat.v_bat = v_bat; stat.v_raw = v_raw; adc10_halt(); }