diff options
| author | Selene ToyKeeper | 2015-10-18 17:09:10 -0600 |
|---|---|---|
| committer | Selene ToyKeeper | 2015-10-18 17:09:10 -0600 |
| commit | 8ae82aa0bf6280674216deff2370561e9ba996e9 (patch) | |
| tree | 0b4eb48d1dcda163b55b7991e2b4aeec71f98869 | |
| parent | merged TK refactoring effort and bistro project from sandbox: (diff) | |
| parent | Removed the need to specify header file paths. (diff) | |
| download | anduril-8ae82aa0bf6280674216deff2370561e9ba996e9.tar.gz anduril-8ae82aa0bf6280674216deff2370561e9ba996e9.tar.bz2 anduril-8ae82aa0bf6280674216deff2370561e9ba996e9.zip | |
Merged many updates from tiny25/bistro branch.
Developed most of "bistro" firmware, based on blf-a6 but greatly improved.
Made a simple program to blink out temperature measurements on tiny25.
Added pseudo-random generator and strobe.
Re-organized some battcheck and otc measurement data.
Removed the need to specify paths to tk-*.h headers.
Diffstat (limited to '')
| -rwxr-xr-x | bin/build-25.sh | 2 | ||||
| -rwxr-xr-x | bin/build.sh | 2 | ||||
| -rw-r--r-- | tk-attiny.h | 3 | ||||
| -rw-r--r-- | tk-random.h | 29 | ||||
| -rw-r--r-- | tk-voltage.h | 14 |
5 files changed, 48 insertions, 2 deletions
diff --git a/bin/build-25.sh b/bin/build-25.sh index 9a3de00..618b94a 100755 --- a/bin/build-25.sh +++ b/bin/build-25.sh @@ -8,7 +8,7 @@ export ATTINY=25 export MCU=attiny$ATTINY export CC=avr-gcc export OBJCOPY=avr-objcopy -export CFLAGS="-Wall -g -Os -mmcu=$MCU -c -std=gnu99 -DATTINY=$ATTINY" +export CFLAGS="-Wall -g -Os -mmcu=$MCU -c -std=gnu99 -DATTINY=$ATTINY -I.." export OFLAGS="-Wall -g -Os -mmcu=$MCU" export LDFLAGS= export OBJCOPYFLAGS='--set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0 --no-change-warnings -O ihex' diff --git a/bin/build.sh b/bin/build.sh index 935310a..0d53b57 100755 --- a/bin/build.sh +++ b/bin/build.sh @@ -8,7 +8,7 @@ export ATTINY=13 export MCU=attiny$ATTINY export CC=avr-gcc export OBJCOPY=avr-objcopy -export CFLAGS="-Wall -g -Os -mmcu=$MCU -c -std=gnu99 -DATTINY=$ATTINY" +export CFLAGS="-Wall -g -Os -mmcu=$MCU -c -std=gnu99 -DATTINY=$ATTINY -I.." export OFLAGS="-Wall -g -Os -mmcu=$MCU" export LDFLAGS= export OBJCOPYFLAGS='--set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0 --no-change-warnings -O ihex' 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-random.h b/tk-random.h new file mode 100644 index 0000000..d559659 --- /dev/null +++ b/tk-random.h @@ -0,0 +1,29 @@ +#ifndef TK_RANDOM_H +#define TK_RANDOM_H +/* + * Smaller, pseudo-random function(s). + * + * Copyright (C) 2015 Selene ToyKeeper + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +uint8_t pgm_rand() { + static uint16_t offset = 255; + offset = (offset + 1) & 0x3ff | 0x0100; + return pgm_read_byte(offset); +} + +#endif // TK_RANDOM_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 |
