uint16_t period; //measurement period in timer ticks (2ms)
uint16_t uselcd; //set to 0 to disable LCD (0xb)
uint16_t average; //how many samples to average (0xc)
+ uint16_t multiplex; //set to 0 to disable multiplexing the channels (0xd)
};
void set_inhibit_signals(int on_off) {
// PORTC = (PORTC & 0x3F) | (on_off << 6);
- if(on_off == 0) {
+ if ((on_off == 0) || (calib_settings.multiplex == 0)) {
MUX_C_ON();
MUX_T_ON();
}
}
void select_channel(void) {
- if (current_channel == 8) {
- // temperature measurement
- set_inhibit_signals(0);
+ if (calib_settings.multiplex == 0) {
+ PORTA = (PORTA & 0x8F) | (0x00 << 4);
}
else {
- // update the select outputs
- PORTA = (PORTA & 0x8F) | (current_channel << 4);
- // clear inhibit signals
- set_inhibit_signals(0);
+ if (current_channel == 8) {
+ // temperature measurement
+ set_inhibit_signals(0);
+ }
+ else {
+ // update the select outputs
+ PORTA = (PORTA & 0x8F) | (current_channel << 4);
+ // clear inhibit signals
+ set_inhibit_signals(0);
+ }
}
}
con = ADCL;
con += (ADCH<<8);
- if (con < connect_threshold) {
+ if (con < connect_threshold || calib_settings.multiplex == 0) {
adc_result = SPI_transceive_16bit(conf_register);
}
}
else if(measurement_step < (CONNECTED_SENSORS*4) && (measurement_step & 0x3) == 0x3) {
set_inhibit_signals(1);
- if (con < connect_threshold) {
+ if (con < connect_threshold || calib_settings.multiplex == 0) {
// read value
adc_result += SPI_transceive_16bit(0x0000);
adc_result /= 2;
#define ISMYADDR() (rxbuf[2] == '0')
uint8_t rxcnt = 0, txpoint = 0;
-volatile uint8_t txcnt = 0;
+volatile uint8_t txcnt = 0;
+volatile uint8_t busy = 0;
uint8_t rxbuf[15];
uint8_t txbuf[15];
if(rxbuf[0] == 'A') rxbuf[2]++;
else rxbuf[2]--;
sei();
- while(TX_BUSY());
+ while (TX_BUSY()) {};
+ while (busy == 1) {};
+ busy = 1;
memcpy ((uint8_t*)txbuf,(uint8_t*)rxbuf,i);
STARTTX(i);
}
void send_answer_hex(uint8_t type, uint8_t chan, uint32_t v) {
sei();
+ while (busy == 1) {};
+ busy = 1;
while(TX_BUSY());
txbuf[0]='A';
txbuf[1]=type;
txpoint = 0;
txcnt = 0;
UCSR0B &= ~(1<< UDRIE0);
-
+ busy = 0;
}
}
\ No newline at end of file