aboutsummaryrefslogtreecommitdiff
path: root/tk-attiny.h
diff options
context:
space:
mode:
authorSelene ToyKeeper2019-08-05 01:44:30 -0600
committerSelene ToyKeeper2019-08-05 01:44:30 -0600
commit24f290888e4132e8f67989de3fa42f492dc5bb8b (patch)
treef82fd0f22b3a979c1a63e1dcb21ee253cc67335b /tk-attiny.h
parentreplaced deprecated avr-size with avr-objdump in build.sh (diff)
parentmerged a sanitized copy of the Emisar D4v2 branch; history summarized below: (diff)
downloadanduril-24f290888e4132e8f67989de3fa42f492dc5bb8b.tar.gz
anduril-24f290888e4132e8f67989de3fa42f492dc5bb8b.tar.bz2
anduril-24f290888e4132e8f67989de3fa42f492dc5bb8b.zip
merged Emisar D4v2 branch, or at least a sanitized version of it
Diffstat (limited to '')
-rw-r--r--tk-attiny.h55
1 files changed, 52 insertions, 3 deletions
diff --git a/tk-attiny.h b/tk-attiny.h
index 3c985f2..947a87c 100644
--- a/tk-attiny.h
+++ b/tk-attiny.h
@@ -28,24 +28,26 @@
/******************** hardware-specific values **************************/
#if (ATTINY == 13)
#define F_CPU 4800000UL
- #define EEPSIZE 64
+ //#define EEPSIZE 64
#define V_REF REFS0
#define BOGOMIPS 950
#define ADMUX_VCC 0b00001100
#define DELAY_ZERO_TIME 252
+ #define SWITCH_PORT PINB // PINA or PINB or PINC
#elif (ATTINY == 25)
// TODO: Use 6.4 MHz instead of 8 MHz?
#define F_CPU 8000000UL
- #define EEPSIZE 128
+ //#define EEPSIZE 128
#define V_REF REFS1
#define BOGOMIPS (F_CPU/4000)
#define ADMUX_VCC 0b00001100
#define ADMUX_THERM 0b10001111
#define DELAY_ZERO_TIME 1020
+ #define SWITCH_PORT PINB // PINA or PINB or PINC
#elif (ATTINY == 85)
// TODO: Use 6.4 MHz instead of 8 MHz?
#define F_CPU 8000000UL
- #define EEPSIZE 512
+ //#define EEPSIZE 512
#define V_REF REFS1
#define BOGOMIPS (F_CPU/4000)
// (1 << V_REF) | (0 << ADLAR) | (VCC_CHANNEL)
@@ -53,10 +55,30 @@
// (1 << V_REF) | (0 << ADLAR) | (THERM_CHANNEL)
#define ADMUX_THERM 0b10001111
#define DELAY_ZERO_TIME 1020
+ #define SWITCH_PORT PINB // PINA or PINB or PINC
+#elif (ATTINY == 1634)
+ #define F_CPU 8000000UL
+ #define V_REF REFS1
+ #define BOGOMIPS (F_CPU/4000)
+ // (1 << V_REF) | (0 << ADLAR) | (VCC_CHANNEL)
+ #define ADMUX_VCC 0b00001101
+ // (1 << V_REF) | (0 << ADLAR) | (THERM_CHANNEL)
+ #define ADMUX_THERM 0b10001110
+ #define DELAY_ZERO_TIME 1020
+ //#define SWITCH_PORT PINA // set this in hwdef
#else
#error Hey, you need to define ATTINY.
#endif
+// auto-detect eeprom size from avr-libc headers
+#ifndef EEPSIZE
+#ifdef E2SIZE
+#define EEPSIZE E2SIZE
+#else
+#define EEPSIZE (E2END+1)
+#endif
+#endif
+
#include <avr/interrupt.h>
@@ -86,4 +108,31 @@
#error Hey, you need to define an I/O pin layout.
#endif
+#if (ATTINY==25) || (ATTINY==45) || (ATTINY==85)
+ // use clock_prescale_set(n) instead; it's safer
+ //#define CLOCK_DIVIDER_SET(n) {CLKPR = 1<<CLKPCE; CLKPR = n;}
+#elif (ATTINY==1634)
+ // make it a NOP for now
+ // FIXME
+ //#define clock_prescale_set(x) ((void)0)
+ //#define clock_prescale_set(n) {cli(); CCP = 0xD8; CLKPR = n; sei();}
+ //#define clock_prescale_set(n) {cli(); CCP = 0xD8; CLKPR = n; sei();}
+ inline void clock_prescale_set(uint8_t n) {cli(); CCP = 0xD8; CLKPR = n; sei();}
+ typedef enum
+ {
+ clock_div_1 = 0,
+ clock_div_2 = 1,
+ clock_div_4 = 2,
+ clock_div_8 = 3,
+ clock_div_16 = 4,
+ clock_div_32 = 5,
+ clock_div_64 = 6,
+ clock_div_128 = 7,
+ clock_div_256 = 8
+ } clock_div_t;
+
+#else
+#error Unable to define MCU macros.
+#endif
+
#endif // TK_ATTINY_H