aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSelene ToyKeeper2015-10-10 00:15:01 -0600
committerSelene ToyKeeper2015-10-10 00:15:01 -0600
commita83c3cfeb35ae6bd308cb0ce17af1e510de6e476 (patch)
tree32f6a728686e48959849c26e42efd2fcbbdd3ea8
parentmerged trunk (diff)
downloadanduril-a83c3cfeb35ae6bd308cb0ce17af1e510de6e476.tar.gz
anduril-a83c3cfeb35ae6bd308cb0ce17af1e510de6e476.tar.bz2
anduril-a83c3cfeb35ae6bd308cb0ce17af1e510de6e476.zip
Made a simple program to blink out temperature measurements.
Added some basic temperature stuff to header files.
-rw-r--r--tk-attiny.h3
-rw-r--r--tk-voltage.h14
2 files changed, 17 insertions, 0 deletions
diff --git a/tk-attiny.h b/tk-attiny.h
index 4fee640..6390416 100644
--- a/tk-attiny.h
+++ b/tk-attiny.h
@@ -70,6 +70,9 @@
#define ADC_DIDR ADC1D // Digital input disable bit corresponding with PB2
#define ADC_PRSCL 0x06 // clk/64
+//#define TEMP_DIDR ADC4D
+#define TEMP_CHANNEL 0b00001111
+
#endif // FET_7135_LAYOUT
#ifdef FERRERO_ROCHER_LAYOUT
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
If you find this content useful please consider a small donation via bitcoin: bitcoin:1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2?amount=0.001&message=Donation Scraping git contents via cgit is very resource intensive. The continued hosting of these git repositories is entirely financed by your bitcoin contributions. For donations of a least 1 mBTC you include your IP address in the message of your bitcoin donation. This will remove this message in the future for requests from your IP, which will significantly reduce token usage. In any case, any contributions to bitcoin address 1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2 are very welcome. Thanks in advance for you contribution to a self-sustaining ecosystem.