From a83c3cfeb35ae6bd308cb0ce17af1e510de6e476 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Sat, 10 Oct 2015 00:15:01 -0600 Subject: Made a simple program to blink out temperature measurements. Added some basic temperature stuff to header files. --- tk-voltage.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tk-voltage.h') diff --git a/tk-voltage.h b/tk-voltage.h index 5eaf0d4..8421ef3 100644 --- a/tk-voltage.h +++ b/tk-voltage.h @@ -23,6 +23,20 @@ #include "tk-attiny.h" #include "tk-calibration.h" +#ifdef TEMPERATURE_MON +inline void ADC_on_temperature() { + // TODO: (?) enable ADC Noise Reduction Mode, Section 17.7 on page 128 + // (apparently can only read while the CPU is in idle mode though) + // select ADC4 by writing 0b00001111 to ADMUX + // 1.1v reference, left-adjust, ADC4 + ADMUX = (1 << V_REF) | (1 << ADLAR) | TEMP_CHANNEL; + // disable digital input on ADC pin to reduce power consumption + //DIDR0 |= (1 << TEMP_DIDR); + // enable, start, prescale + ADCSRA = (1 << ADEN ) | (1 << ADSC ) | ADC_PRSCL; +} +#endif // TEMPERATURE_MON + #ifdef VOLTAGE_MON inline void ADC_on() { // disable digital input on ADC pin to reduce power consumption -- cgit v1.2.3