From: Philipp Klaus Date: Fri, 7 Aug 2015 07:01:31 +0000 (+0200) Subject: pt100: compile errors fixed X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=263c9904682544e387f1dc8dcf2accb827ae1c50;p=avr.git pt100: compile errors fixed --- diff --git a/pt100/main.h b/pt100/main.h index dda6c1b..6fed221 100644 --- a/pt100/main.h +++ b/pt100/main.h @@ -47,7 +47,7 @@ void do_measurement_step(void); extern volatile uint16_t control_reg; extern volatile uint8_t keys_pressed; -extern uint8_t connected_sensors; +extern uint8_t num_connected_sensors; extern volatile uint16_t time; extern volatile uint8_t measurement_active; extern struct calib_t calib_settings; diff --git a/pt100/tempmeas.c b/pt100/tempmeas.c index 93d93d3..ab16256 100644 --- a/pt100/tempmeas.c +++ b/pt100/tempmeas.c @@ -5,7 +5,7 @@ uint8_t measurement_step; uint8_t current_channel = 0; - +uint8_t num_connected_sensors = 8; //factors: gain_current has 2^29, ADC has 2^7 steps per mV //hence shift by 36 necessary, 6 as part of multiplication by 1E6 @@ -39,7 +39,38 @@ int32_t res_to_temp(int16_t res) { return result; } +void set_inhibit_signals(int on_off) { + PORTC = (PORTC & 0x3F) | (on_off << 6); + } + +void select_channel(void) { + 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); + } + } + + +char SPI_transceive(unsigned char cData){ + SPDR = cData; + while (!(SPSR & (1<>8); + low = SPI_transceive(data&0xFF); + return (high << 8) | low; + } //measurement_active gets set once per second @@ -65,18 +96,18 @@ int32_t res_to_temp(int16_t res) { //35 send ADC temperature void do_measurement_step(void) { - if(measurement_step < (CONNECTED_SENSORS*4) && measurement_step & 0x3 == 0x0) { + if(measurement_step < (CONNECTED_SENSORS*4) && (measurement_step & 0x3) == 0x0) { LED1_ON(); select_channel(); } - else if(measurement_step < (CONNECTED_SENSORS*4) && measurement_step & 0x3 == 0x1) { + else if(measurement_step < (CONNECTED_SENSORS*4) && (measurement_step & 0x3) == 0x1) { ADCSRA |= (1<>8); - low = SPI_transceive(data&0xFF); - return (high << 8) | low; - } - -char SPI_transceive(unsigned char cData){ - SPDR = cData; - while (!(SPSR & (1<