summaryrefslogtreecommitdiff
path: root/software
diff options
context:
space:
mode:
authorBernhard Tittelbach <xro@realraum.at>2012-05-20 02:42:45 +0000
committerBernhard Tittelbach <xro@realraum.at>2012-05-20 02:42:45 +0000
commita04c9c9a65eda73ce5b365a5a8adce807f8d1443 (patch)
tree646f436a2248e06e2f36e656681fe8ca17943ea1 /software
parentfixed adc read ??? (diff)
adc on/off
git-svn-id: https://svn.spreadspace.org/mur.sat@449 7de4ea59-55d0-425e-a1af-a3118ea81d4c
Diffstat (limited to 'software')
-rw-r--r--software/hhd70dongle/hhd70dongle.c3
-rw-r--r--software/hhd70dongle/util.c17
-rw-r--r--software/hhd70dongle/util.h2
3 files changed, 17 insertions, 5 deletions
diff --git a/software/hhd70dongle/hhd70dongle.c b/software/hhd70dongle/hhd70dongle.c
index bc62dea..9bf3e8b 100644
--- a/software/hhd70dongle/hhd70dongle.c
+++ b/software/hhd70dongle/hhd70dongle.c
@@ -106,6 +106,8 @@ int main(void)
write_buffer[3]='p';
write_buffer[4]='s';
write_buffer[5]=':';
+ adc_on();
+ _delay_ms(250);
usb_rawhid_send((uint8_t*)"temp c1101:",255);
debug_sprint_int16hex(write_buffer+6, c1101_measureTemp());
usb_rawhid_send(write_buffer+6,255);
@@ -113,6 +115,7 @@ int main(void)
usb_rawhid_send((uint8_t*)"temp atmega:",255);
debug_sprint_int16hex(write_buffer+10, adc_read(ADCMUX_ADC12));
usb_rawhid_send(write_buffer+10,255);
+ adc_off();
_delay_ms(250);
led_on();
usb_rawhid_send((uint8_t*)"TX Data: String",255);
diff --git a/software/hhd70dongle/util.c b/software/hhd70dongle/util.c
index 2c358fa..56fe575 100644
--- a/software/hhd70dongle/util.c
+++ b/software/hhd70dongle/util.c
@@ -70,19 +70,26 @@ void reset(void)
#endif
}
+//not switchin off adc produces slightly besser results
+void adc_on(void)
+{
+ ADCSRA = (1<<ADEN) | 0b00000111; // enable ADC, Prescaler 1:128
+}
+
+void adc_off(void)
+{
+ ADCSRA &= ~(1<<ADEN); // disable ADC -> save power
+}
+
+
uint8_t adc_read(uint8_t mux)
{
ADCSRB = (mux & 0x20); // select input
ADMUX = 0b11100000 | (mux & 0x1F); // select input cont'd
// select internal 2.56V reference,
// result is left justified
- ADCSRA = (1<<ADEN) | 0b00000111; // enable ADC, Prescaler 1:128
-
ADCSRA |= (1<<ADSC); // start the conversion
while (ADCSRA & (1<<ADSC)) ; // wait for result
-
- ADCSRA &= ~(1<<ADEN); // disable ADC -> save power
-
return ADCH;
}
diff --git a/software/hhd70dongle/util.h b/software/hhd70dongle/util.h
index 20068fd..4554af9 100644
--- a/software/hhd70dongle/util.h
+++ b/software/hhd70dongle/util.h
@@ -37,6 +37,8 @@
#define ADCMUX_ADC12 0b00100100
void reset(void);
+void adc_on(void);
+void adc_off(void);
uint8_t adc_read(uint8_t mux);
void debug_sprint_int16hex(uint8_t *buffer, int16_t num);